Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk renaming is broken #135

Closed
syhol opened this issue Jun 25, 2024 · 7 comments · Fixed by #152
Closed

Bulk renaming is broken #135

syhol opened this issue Jun 25, 2024 · 7 comments · Fixed by #152
Labels
enhancement New feature or request

Comments

@syhol
Copy link

syhol commented Jun 25, 2024

Screen.Recording.2024-06-25.at.14.53.08.mov

Bulk renaming puts the window into a strange broken state and ctrl+c is the only way to break out of it. This works fine when I run yazi directly outside of of neovim.

Recreation steps:
Install Yazi, version: Yazi 0.2.5 (Homebrew 2024-04-23)
Install Neovim, version: NVIM v0.10.0 / Build type: Release / LuaJIT 2.1.1713773202
Setup the plugin with recommended settings, but changed opts.open_for_directories to true:

---@type LazySpec
return {
  'mikavilpas/yazi.nvim',
  dependencies = {
    'nvim-lua/plenary.nvim',
  },
  event = 'VeryLazy',
  keys = {
    -- 👇 in this section, choose your own keymappings!
    {
      '<leader>-',
      function()
        require('yazi').yazi()
      end,
      desc = 'Open the file manager',
    },
    {
      -- Open in the current working directory
      '<leader>cw',
      function()
        require('yazi').yazi(nil, vim.fn.getcwd())
      end,
      desc = "Open the file manager in nvim's working directory",
    },
  },
  ---@type YaziConfig
  opts = {
    open_for_directories = true,
  },
}

Open a new neovim session:
nvim .
Enter visual mode:
v
Rename:
r
Then it's in this stuck state.

@mikavilpas
Copy link
Owner

Hi! This is a known issue - for now this cannot be done in yazi.nvim.

I have laid out some plans for addressing this in sxyazi/yazi#989 - you can track that issue if you're interested.

Let's keep this issue open!

@mikavilpas
Copy link
Owner

I was able to implement a proof-of-concept for bulk renaming! It's still a bit work in progress, but can be tried out here #152

It currently requires a yazi version built from source along with its new ya command line helper application. I use ya to read events sent from yazi and eventually want to move to supporting only it, but I think I will have to maintain both the new ya approach and the current (hacky) approach separately so users have some time to move to the new system.

@mikavilpas
Copy link
Owner

It seems that currently the proof-of-concept in #152 can only work locally, but it can't work in continuous integration - the build system doesn't have easy access to the bleeding edge version of yazi. Right now on the master branch, the latest release of yazi is installed in CI, and this has worked well.

But the old tests were simple unit tests and basically only depended on the yazi application being found - it was never actually interacted with. With the recent addition of full integration tests, yazi.nvim now tests all interaction with yazi exactly as a user would, so all the tested features need to be available.

I think the simplest, fastest solution to this is to build (and cache) yazi from source in CI. This might be possible to remove once the next stable version of yazi is released.

@mikavilpas
Copy link
Owner

Although a bit more complicated, the building from source could also be done in yazi, and I could install a prebuilt binary for CI, e.g. with cargo-binstall.

@sxyazi I'm curious if you have given any thought to the possibility of building "nightly releases" in yazi.

@mikavilpas
Copy link
Owner

mini update: Building from source and caching seems to work! I used https://github.com/baptiste0928/cargo-install

mikavilpas added a commit that referenced this issue Jul 7, 2024
This change is optional, and by default is not enabled for users.

To opt in, you need to do the following:
- install the latest `yazi` from source
- install the latest `ya` from source. `ya` is the standalone command
  line tool for yazi. You can read
  <sxyazi/yazi#914> for more information.
- set the new config option `use_ya_for_events_reading = true` (it's
  `false` by default for now)
- run `:checkhealth yazi` to verify that `ya` is found and that the
  healthcheck passes

Bulk renaming in yazi is done by
- selecting multiple files in yazi
- pressing `r` to rename the files. This will open `$EDITOR`, typically
  Neovim, inside yazi.
- The nested Neovim will display the selected file names, one per line.
  The user can then edit the names as needed.
- save and quit the nested Neovim instance. This will rename the files
  in yazi.

<https://yazi-rs.github.io/docs/configuration/keymap/#manager.rename>

---

Technical details for developers:

- in the future, once the next release of yazi is out, yazi.nvim may
  automatically use `ya` for reading events. This would then be the
  default behavior. `ya` may enable more advanced features in the
  future.
- `yazi` is now built from source in continuous integration
- the integration testing system, although perhaps innovative, is still
  taking shape. I believe in time it will stabilize, but I don't want to
  cement the design too much until the best structure becomes evident in
  time.

Closes #135
mikavilpas added a commit that referenced this issue Jul 7, 2024
This change is optional, and by default is not enabled for users.

To opt in, you need to do the following:
- install the latest `yazi` from source
- install the latest `ya` from source. `ya` is the standalone command
  line tool for yazi. You can read
  <sxyazi/yazi#914> for more information.
- set the new config option `use_ya_for_events_reading = true` (it's
  `false` by default for now)
- run `:checkhealth yazi` to verify that `ya` is found and that the
  healthcheck passes

Bulk renaming in yazi is done by
- selecting multiple files in yazi
- pressing `r` to rename the files. This will open `$EDITOR`, typically
  Neovim, inside yazi.
- The nested Neovim will display the selected file names, one per line.
  The user can then edit the names as needed.
- save and quit the nested Neovim instance. This will rename the files
  in yazi.

<https://yazi-rs.github.io/docs/configuration/keymap/#manager.rename>

---

Technical details for developers:

- in the future, once the next release of yazi is out, yazi.nvim may
  automatically use `ya` for reading events. This would then be the
  default behavior. `ya` may enable more advanced features in the
  future.
- `yazi` is now built from source in continuous integration
- the integration testing system, although perhaps innovative, is still
  taking shape. I believe in time it will stabilize, but I don't want to
  cement the design too much until the best structure becomes evident in
  time.

Closes #135
@mikavilpas
Copy link
Owner

The feature is now ready to be tried out in #152

@sxyazi
Copy link

sxyazi commented Jul 7, 2024

@sxyazi I'm curious if you have given any thought to the possibility of building "nightly releases" in yazi.

Yeah I'll give it a try, probably just need to make some little changes to the existing release workflow.

@mikavilpas mikavilpas added enhancement New feature or request and removed blocked help wanted Extra attention is needed labels Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants