feat: Add more easily customizable mappings.

Closes: #131
This commit is contained in:
TJ DeVries
2020-10-08 21:39:43 -04:00
parent fa17b37dad
commit c2c4626c3d
4 changed files with 125 additions and 50 deletions

View File

@@ -59,52 +59,24 @@ function config.set_defaults(defaults)
-- Last argument will be the search term (passed in during execution)
set("vimgrep_arguments", {'rg', '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'})
-- TODO: Shortenpath
-- Decide how to propagate that to all the opts everywhere.
-- TODO: Add motions to keybindings
-- TODO: Add relative line numbers?
set("default_mappings", {
i = {
["<C-n>"] = actions.move_selection_next,
["<C-p>"] = actions.move_selection_previous,
["<C-c>"] = actions.close,
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
["<CR>"] = actions.goto_file_selection_edit,
["<C-x>"] = actions.goto_file_selection_split,
["<C-v>"] = actions.goto_file_selection_vsplit,
["<C-t>"] = actions.goto_file_selection_tabedit,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
-- TODO: When we implement multi-select, you can turn this back on :)
-- ["<Tab>"] = actions.add_selection,
},
n = {
["<esc>"] = actions.close,
["<CR>"] = actions.goto_file_selection_edit,
["<C-x>"] = actions.goto_file_selection_split,
["<C-v>"] = actions.goto_file_selection_vsplit,
["<C-t>"] = actions.goto_file_selection_tabedit,
-- TODO: This would be weird if we switch the ordering.
["j"] = actions.move_selection_next,
["k"] = actions.move_selection_previous,
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
},
})
-- To disable a keymap, put [map] = false
-- So, to not map "<C-n>", just put
--
-- ...,
-- ["<C-n>"] = false,
-- ...,
--
-- Into your config.
--
-- Otherwise, just set the mapping to the function that you want it to be.
--
-- ...,
-- ["<C-i>"] = actions.goto_file_selection_split
-- ...,
--
set("mappings", {})
-- NOT STABLE. DO NOT USE
set("horizontal_config", {