diff options
-rw-r--r-- | lua/lv-which-key/config.lua | 30 | ||||
-rw-r--r-- | lua/lv-which-key/init.lua | 29 |
2 files changed, 24 insertions, 35 deletions
diff --git a/lua/lv-which-key/config.lua b/lua/lv-which-key/config.lua index bd244d74..d4c3f6bd 100644 --- a/lua/lv-which-key/config.lua +++ b/lua/lv-which-key/config.lua @@ -45,16 +45,28 @@ O.plugin.which_key = { noremap = true, -- use `noremap` when creating keymaps nowait = true, -- use `nowait` when creating keymaps }, + vopts = { + mode = "v", -- VISUAL mode + prefix = "<leader>", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps + }, + -- NOTE: Prefer using : over <cmd> as the latter avoids going back in normal-mode. + -- see https://neovim.io/doc/user/map.html#:map-cmd + vmappings ={ + ["/"] = { ":CommentToggle<CR>", "Comment" }, + }, mappings = { - ["w"] = "Save", - ["q"] = "Quit", - ["."] = "LunarConfig", - ["/"] = "Comment", - ["c"] = "Close Buffer", - ["e"] = "Explorer", - ["f"] = "Find File", - ["h"] = "No Highlight", - [";"] = "Dashboard", + ["w"] = { "<cmd>w!<CR>", "Save" }, + ["q"] = { "<cmd>q!<CR>", "Quit" }, + ["/"] = { "<cmd>CommentToggle<CR>", "Comment" }, + ["c"] = { "<cmd>BufferClose<CR>", "Close Buffer" }, + ["e"] = { "<cmd>lua require'lv-nvimtree'.toggle_tree()<CR>", "Explorer" }, + ["f"] = { "<cmd>Telescope find_files<CR>", "Find File" }, + ["h"] = { '<cmd>let @/=""<CR>', "No Highlight" }, + [";"] = { "<cmd>Dashboard<CR>", "Dashboard" }, p = { name = "Packer", c = { "<cmd>PackerCompile<cr>", "Compile" }, diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index 81542ca4..37feca95 100644 --- a/lua/lv-which-key/init.lua +++ b/lua/lv-which-key/init.lua @@ -18,34 +18,10 @@ else end local opts = O.plugin.which_key.opts - --- Comments -vim.api.nvim_set_keymap("n", "<leader>/", ":CommentToggle<CR>", { noremap = true, silent = true }) -vim.api.nvim_set_keymap("v", "<leader>/", ":CommentToggle<CR>", { noremap = true, silent = true }) --- dashboard -vim.api.nvim_set_keymap("n", "<Leader>;", ":Dashboard<CR>", { noremap = true, silent = true }) --- Save -vim.api.nvim_set_keymap("n", "<leader>w", ":w!<CR>", { noremap = true, silent = true }) --- no hl -vim.api.nvim_set_keymap("n", "<Leader>h", ':let @/=""<CR>', { noremap = true, silent = true }) --- Quit -vim.api.nvim_set_keymap("n", "<leader>q", ":q!<CR>", { noremap = true, silent = true }) --- open lv-config -vim.api.nvim_set_keymap( - "n", - "<leader>.", - ":e " .. CONFIG_PATH .. "/lv-config.lua<CR>", - { noremap = true, silent = true } -) --- explorer -vim.api.nvim_set_keymap( - "n", - "<Leader>e", - ":lua require'lv-nvimtree'.toggle_tree()<CR>", - { noremap = true, silent = true } -) +local vopts = O.plugin.which_key.vopts local mappings = O.plugin.which_key.mappings +local vmappings = O.plugin.which_key.vmappings; -- if O.plugin.ts_playground.active then -- vim.api.nvim_set_keymap("n", "<leader>Th", ":TSHighlightCapturesUnderCursor<CR>", { noremap = true, silent = true }) @@ -84,3 +60,4 @@ end local wk = require "which-key" wk.register(mappings, opts) +wk.register(vmappings, vopts) |