LazyVim icon indicating copy to clipboard operation
LazyVim copied to clipboard

Add cwd and vertical/horizontal keybindings to mini.files

Open dusty-phillips opened this issue 2 years ago • 7 comments

  • Makes the toggle_hidden keybinding configurable via mappings
  • Adds new mini.files keybindings for opening files in a vertical split, with both go_in and go_in_plus modes (configurable via mappings)
  • Adds new keybinding to change working directory from mini.files (configurable via mappings)

Closes #2692

dusty-phillips avatar Mar 10 '24 13:03 dusty-phillips

I'm very excited about these proposed enhancements for the mini.files extra. I've recently discovered mini.files, which has allowed me to completely disable neo-tree.

Re: which bindings to use, I'd vote for C-w v,V,s,S as pressing those bindings while in mini.files windows doesn't make sense and does weird stuff to the screen anyways, so might as well use them as they were intended :-) But, really, it doesn't matter too much as I generally launch mini.files in the window I want to open the file in anyways.

I'm just happy to have discovered it as it's so much faster using mini.files to navigate than a sidebar. I tried oil as well, but oil is much slower, and it's preview is ridiculously slow as it opens the whole file. Plus, mini gives you context.

pkazmier avatar Mar 14 '24 16:03 pkazmier

s is used to search. I would use it to move around quickly even in mini.files.

briandipalma avatar Mar 15 '24 17:03 briandipalma

  • Rebased and fixed conflicts.
  • Switched to <ctrl-w>s and <ctrl-w>v for opening in splits

Tangentially related: my book recommends remapping \ to ctrl-w, and I suggest this could be a default in LazyVim. Then we don't need space-| and space- anymore because \v and \s are just as easy to type.

@folke is there anything you'd like me to do to get this into core and/or do you prefer not to have it merged so I can close it?

dusty-phillips avatar May 23 '24 13:05 dusty-phillips

Kinda naive question, but is there a specific reason we use 2 separate autocmds on the same event?

dpetka2001 avatar May 23 '24 14:05 dpetka2001

Kinda naive question, but is there a specific reason we use 2 separate autocmds on the same event?

It was cause in my local config I wanted to keep my changes separate from the LazyVim configuration, but since this IS the (proposed) LazyVim configuration it doesn't make sense here. I think I pulled a folke and pushed a change for it while you were asking the question. 😂

dusty-phillips avatar May 23 '24 14:05 dusty-phillips

The last change you pushed actually reduced the number of autocmds from 3 to 2. There are still 2 separate autocmds, as far as I can see.

dpetka2001 avatar May 23 '24 14:05 dpetka2001

I think that's just me being daft.

dusty-phillips avatar May 23 '24 16:05 dusty-phillips

Thanks!

folke avatar Jun 05 '24 21:06 folke

Hi @dusty-phillips, I'm getting an error from this PR:  Error 12:55:46 PM msg_show.lua_error Error detected while processing User Autocommands for "MiniFilesBufferCreate": 12:55:46 PM msg_show Error executing lua callback: ...LazyVim/lua/lazyvim/plugins/extras/editor/mini-files.lua:85: attempt to index field 'mappings' (a nil value) stack traceback: ...LazyVim/lua/lazyvim/plugins/extras/editor/mini-files.lua:85: in function <...LazyVim/lua/lazyvim/plugins/extras/editor/mini-files.lua:80> [C]: in function 'nvim_exec_autocmds' ...hna/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:2619: in function 'trigger_event' ...hna/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:1890: in function 'buffer_create' ...hna/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:1756: in function 'view_ensure_proper' ...hna/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:1529: in function 'explorer_refresh_depth_window' ...hna/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:1321: in function 'explorer_refresh' ...hna/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:714: in function 'open' ...LazyVim/lua/lazyvim/plugins/extras/editor/mini-files.lua:19: in function <...LazyVim/lua/lazyvim/plugins/extras/editor/mini-files.lua:18> Reverting to d704ca4c1b761303c0c1119341a566d161ab12a3, I do not see these errors. Seems to be upset about opts.mappings. I can dive a bit deeper into why this is happening, but I wanted to post now for awareness. (posted this message initially on the commit)

krishna-bala avatar Jun 06 '24 18:06 krishna-bala

@krishna-bala If you'd like you can check out #3507 to see if it works correctly. Hopefully I didn't miss anything.

dpetka2001 avatar Jun 06 '24 18:06 dpetka2001