break!: mappings overhaul
Following the reddit discussion, I've deeply reconsidered mappings once more.
I really like the suggestion from @David-Kunz to map going upwards to h (with - alias) and move quite some it ouf of the way of mapping to much CTRL-KEY to leave space for users.
Please note this is only a first crack at a over haul.
I'm CCing all people of the previous PR in hopes to get feedback :) sorry for the noise.
Logic:
- free up as many
<C-KEY>mappings as possible for the user - Mirror insert/normal mode where possible
- Special actions ideally grouped/mnemoics, something related (
-fromnvim-tree,~as home, "" being close to~`
I guess some of the single character bindings can be controversial, but my initial feeling is in 99% of usages users won't need them in insert-mode. I'd very much welcome feedback.
@jamestrew @ikerurda @AckslD @adgai19 @Jidbo @nawordar @zeina99 @jacksonludwig @weseven @Diskriminantti
-- default insert mode mappings -- NOT NEEDED TO CONFIGURE
["<A-a>"] = fb_actions.create, -- add file/dir at `path` (trailing separator creates dir)
["<A-r>"] = fb_actions.rename, -- rename multi-selected files/folders
["<A-m>"] = fb_actions.move, -- move multi-selected files/folders to current `path`
["<A-y>"] = fb_actions.copy, -- copy multi-selected files/folders to current `path`
["<A-d>"] = fb_actions.remove, -- remove multi-selected files/folders to current `path`
["<A-o>"] = fb_actions.open, -- open file/folder with default system application
["<C-f>"] = fb_actions.toggle_browser, -- toggle between file and folder browser
["<C-h>"] = actions.goto_parent_dir, -- goto parent directory; alias to normal-mode
["="] = fb_actions.change_cwd, -- change nvim cwd to selected file (parent) or folder
["~"] = fb_actions.goto_home_dir, -- go to home directory
["`"] = fb_actions.goto_cwd, -- go to cwd
["+"] = fb_actions.toggle_all, -- toggle selection of all shown entries ignoring `.` and `..`
[";"] = fb_actions.toggle_hidden, -- toggle showing hidden files and folders
-- remove a mapping
["KEY"] = false,
-- your custom function
["KEY"] = function(prompt_bufnr)
print("Implement your custom function; see actions.lua for inspiration")
end,
-- default normal mode mappings -- NOT NEEDED TO CONFIGURE
["a"] = fb_actions.create, -- create file/dir at `path` (trailing separator creates dir)
["r"] = fb_actions.rename, -- rename multi-selected files/folders
["m"] = fb_actions.move, -- move multi-selected files/folders to current `path`
["y"] = fb_actions.copy, -- copy multi-selected files/folders to current `path`
["d"] = fb_actions.remove, -- remove multi-selected files/folders to current `path`
["o"] = fb_actions.open, -- open file/folder with default system application
["f"] = fb_actions.toggle_browser, -- toggle between file and folder browser
-- normal mode movement
["h"] = actions.goto_parent_dir, -- goto parent directory
["j"] = actions.move_selection_next, -- next entry
["k"] = actions.move_selection_previous, -- previous entry
["l"] = actions.select_default, -- confirm selection
-- directories
["="] = fb_actions.change_cwd, -- change nvim cwd to selected file (parent) or folder
["~"] = fb_actions.goto_home_dir, -- go to home directory
["`"] = fb_actions.goto_cwd, -- go to home directory
["+"] = fb_actions.toggle_all, -- toggle selection of all shown entries ignoring `.` and `..`
[";"] = fb_actions.toggle_hidden, -- toggle showing hidden files and folders
As a reference dired mappings though it seems super involved to enable virtually any file system operation at the cost of ease for the 95% of things.
I'm aware default mappings can be overwritten but I'm not 100% sure about these...
["<Leader>"] = fb_actions.change_cwd, -- change nvim cwd to selected file (parent) or folder ["-"] = fb_actions.goto_parent_dir, -- change nvim cwd to selected file (parent) or folder
The <leader> mapping is very personal and many times may be set to <space> (very common in file names) or other common keystrokes. I think we should avoid it. Same with "-" (very common in filenames).
Also, I think we should try to maintain some logic between the insert and normal mappings.
Thanks for chiming in :)
The
mapping is very personal and many times may be set to (very common in file names) or other common keystrokes. I think we should avoid it.
Yeah, agree that one needs to go for something better. Any ideas?
Same with "-" (very common in filenames).
Agreed, as mentioned in my OP. Not sure whether to just leave it to <C-h> then as the mirror to the normal mode mapping.
Also, I think we should try to maintain some logic between the insert and normal mappings.
Isn't there a consistent logic apart from these two problematic mappings across normal and insert mode? Would you say more changes than apart from your two mentioned mappings are required?
I've now changed change_cwd to = (just non-intrusive) and removed - entirely as h in terms of movement is really nice in normal mode.
E: the alternative always of course is to stay more in line with #62 I don't care so much, I just would like to make the best default experience for the largest user base possible. :sweat_smile:
Thoughts?
Generally LGTM, but remember to change all the mappings in the docs :)
Good catch, thanks :)
First time looking at this. Sorry if it’s been addressed but you asked for feedback…
Why no <A-a> for ‘add’ instead of <A-c> for ‘create’?
My mind would go to ‘adding’ a file/folder rather than ‘creating’ it
<C-a> also goes in pair with nvim-tree.lua.
{ key = "a", cb = tree_cb("create") },
as per nvim-tree :laughing:
I don't mind one way or another.
I'll try and leave this up for a couple of days (latest up until Monday); I hope this is generally is a change users would like.
Ideally, let's try and await more feedback.
First time looking at this. Sorry if it’s been addressed but you asked for feedback…
Why no <A-a> for ‘add’ instead of <A-c> for ‘create’?
My mind would go to ‘adding’ a file/folder rather than ‘creating’ it
Why not n for "new" ?