mappings: Allow to remove plugin mappings in chadrc
This enables us to disable a plugin mappings individually for eg: M.mappings.plugins = { telelscope = { find_hiddenfiles = false } } This will disable the telelscope find_hiddenfiles mapping. It's also helpful when we want to use the mapping used by find_hiddenfiles for something else
This commit is contained in:
parent
4c85f25a09
commit
bad06dc44f
|
@ -166,7 +166,7 @@ M.mappings = {
|
|||
}
|
||||
|
||||
-- plugins related mappings
|
||||
|
||||
-- To disable a mapping, equate the variable to "" or false or nil in chadrc
|
||||
M.mappings.plugins = {
|
||||
bufferline = {
|
||||
next_buffer = "<TAB>",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local utils = require "core.utils"
|
||||
|
||||
local config = utils.load_config()
|
||||
local map = utils.map
|
||||
local map_wrapper = utils.map
|
||||
|
||||
local maps = config.mappings
|
||||
local plugin_maps = maps.plugins
|
||||
|
@ -9,41 +9,52 @@ local nvChad_options = config.options.nvChad
|
|||
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- This is a wrapper function made to disable a plugin mapping from chadrc
|
||||
-- If keys are nil, false or empty string, then the mapping will be not applied
|
||||
-- Useful when one wants to use that keymap for any other purpose
|
||||
local map = function(...)
|
||||
local keys = select(2, ...)
|
||||
if not keys or keys == "" then
|
||||
return
|
||||
end
|
||||
map_wrapper(...)
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
-- these mappings will only be called during initialization
|
||||
M.misc = function()
|
||||
local function non_config_mappings()
|
||||
-- Don't copy the replaced text after pasting in visual mode
|
||||
map("v", "p", '"_dP')
|
||||
map_wrapper("v", "p", '"_dP')
|
||||
|
||||
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
|
||||
-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
|
||||
-- empty mode is same as using :map
|
||||
-- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
|
||||
map("", "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
|
||||
map("", "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
|
||||
map("", "<Down>", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
|
||||
map("", "<Up>", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
|
||||
map_wrapper("", "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
|
||||
map_wrapper("", "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
|
||||
map_wrapper("", "<Down>", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
|
||||
map_wrapper("", "<Up>", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
|
||||
|
||||
-- use ESC to turn off search highlighting
|
||||
map("n", "<Esc>", ":noh <CR>")
|
||||
map_wrapper("n", "<Esc>", ":noh <CR>")
|
||||
|
||||
-- center cursor when moving (goto_definition)
|
||||
|
||||
-- yank from current cursor to end of line
|
||||
map("n", "Y", "yg$")
|
||||
map_wrapper("n", "Y", "yg$")
|
||||
end
|
||||
|
||||
local function optional_mappings()
|
||||
-- don't yank text on cut ( x )
|
||||
if not nvChad_options.copy_cut then
|
||||
map({ "n", "v" }, "x", '"_x')
|
||||
map_wrapper({ "n", "v" }, "x", '"_x')
|
||||
end
|
||||
|
||||
-- don't yank text on delete ( dd )
|
||||
if not nvChad_options.copy_del then
|
||||
map({ "n", "v" }, "d", '"_d')
|
||||
map_wrapper({ "n", "v" }, "d", '"_d')
|
||||
end
|
||||
|
||||
-- navigation within insert mode
|
||||
|
|
Loading…
Reference in New Issue