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

break!: mappings overhaul #65

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

break!: mappings overhaul #65

wants to merge 3 commits into from

Conversation

fdschmidt93
Copy link
Member

@fdschmidt93 fdschmidt93 commented Jan 13, 2022

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 (- from nvim-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.

@ikerurda
Copy link
Contributor

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.

@fdschmidt93
Copy link
Member Author

fdschmidt93 commented Jan 13, 2022

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?

@fdschmidt93
Copy link
Member Author

fdschmidt93 commented Jan 13, 2022

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. 😅

Thoughts?

@ikerurda
Copy link
Contributor

Generally LGTM, but remember to change all the mappings in the docs :)

@fdschmidt93
Copy link
Member Author

Good catch, thanks :)

@fdschmidt93 fdschmidt93 mentioned this pull request Jan 13, 2022
@benfrain
Copy link

benfrain commented Jan 13, 2022

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

README.md Outdated Show resolved Hide resolved
@gegoune
Copy link

gegoune commented Jan 13, 2022

<C-a> also goes in pair with nvim-tree.lua.

@fdschmidt93
Copy link
Member Author

{ key = "a", cb = tree_cb("create") },

as per nvim-tree 😆

I don't mind one way or another.

@fdschmidt93
Copy link
Member Author

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.

@LamprosPitsillos
Copy link

LamprosPitsillos commented Jan 20, 2022

First time looking at this. Sorry if it’s been addressed but you asked for feedback…

Why no for ‘add’ instead of for ‘create’?

My mind would go to ‘adding’ a file/folder rather than ‘creating’ it

Why not n for "new" ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants