-
Notifications
You must be signed in to change notification settings - Fork 932
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
Add cwd and vertical/horizontal keybindings to mini.files #2695
base: main
Are you sure you want to change the base?
Conversation
@@ -32,7 +32,7 @@ return { | |||
require("mini.files").setup(opts) | |||
|
|||
local show_dotfiles = true | |||
local filter_show = function(fs_entry) | |||
local filter_show = function(_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stylelua was warning me about unused variable here.
@@ -45,12 +45,69 @@ return { | |||
require("mini.files").refresh({ content = { filter = new_filter } }) | |||
end | |||
|
|||
local map_split = function(buf_id, lhs, direction, close_on_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is modified from the example in the mini.files repo quite a bit. notably, I made it open the selected file after creating the split, and added close_on_file so that we can have _plus
keybindings. I also made the keybindings configurable via opts.mappings.
"n", | ||
opts.mappings.toggle_hidden or "g.", | ||
toggle_dotfiles, | ||
{ buffer = buf_id, desc = "Toggle hidden files" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added description here, though I also have a separate PR open for that in case you don't want to accept these more invasive changes.
vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id }) | ||
vim.keymap.set( | ||
"n", | ||
opts.mappings.toggle_hidden or "g.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added ability to configure this existing mapping from opts
map_split(buf_id, opts.mappings.go_in_horizontal or "gs", "horizontal", false) | ||
map_split(buf_id, opts.mappings.go_in_vertical or "gv", "vertical", false) | ||
map_split(buf_id, opts.mappings.go_in_horizontal_plus or "gS", "horizontal", true) | ||
map_split(buf_id, opts.mappings.go_in_vertical_plus or "gV", "vertical", true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first two mappings (as well as gc
below) were suggested by mini.files documentation. I don't care for them as they conflict with existing mappings. Happy to change them to something more Lazy, but I'm not sure what they should be. Some ideas:
<space>|
and<space><minus>
, overwriting the LazyVim keymappings for opening new windows in splits, but not obvious what to do with the*_plus
versions.<C-w>v, <C-w>V,
sand
S`, overwriting the standard vim keymappings for opening new windows in splits.\v
,\V
,\s
,\S
which is what I'll use because I have\
mapped to<C-w>
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. |
|
Tangentially related: my book recommends remapping @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? |
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. 😂 |
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. |
* Makes the toggle_hidden keybinding configurable via mappings * Adds new mini.files keybindings for opening files in a vertical or horizontal 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)
I think that's just me being daft. |
Closes #2692