diff options
author | kylo252 <[email protected]> | 2022-07-04 19:26:33 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-07-04 19:26:33 +0200 |
commit | 6d43a7946489764b57d2771fcfba260109ef984b (patch) | |
tree | 528a0407cbbfc9392071d8be4fb957b970860d9e /lua | |
parent | 8dca3a915cc30718b3f6392fdfd2ab9c26bf1f60 (diff) |
refactor(whichkey): use vim.keymap.set directly (#2786)
Diffstat (limited to 'lua')
-rw-r--r-- | lua/lvim/core/terminal.lua | 21 | ||||
-rw-r--r-- | lua/lvim/lsp/init.lua | 19 |
2 files changed, 7 insertions, 33 deletions
diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index 6c190dd5..6f543d06 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -41,7 +41,6 @@ M.config = function() -- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"} execs = { { "lazygit", "<leader>gg", "LazyGit", "float" }, - { "lazygit", "<c-\\><c-g>", "LazyGit", "float" }, }, } end @@ -76,23 +75,9 @@ M.add_exec = function(opts) return end - local exec_func = string.format( - "<cmd>lua require('lvim.core.terminal')._exec_toggle({ cmd = '%s', count = %d, direction = '%s'})<CR>", - opts.cmd, - opts.count, - opts.direction - ) - - require("lvim.keymappings").load { - normal_mode = { [opts.keymap] = exec_func }, - term_mode = { [opts.keymap] = exec_func }, - } - - local wk_status_ok, wk = pcall(require, "which-key") - if not wk_status_ok then - return - end - wk.register({ [opts.keymap] = { opts.label } }, { mode = "n" }) + vim.keymap.set({ "n", "t" }, opts.keymap, function() + M._exec_toggle { cmd = opts.cmd, count = opts.count, direction = opts.direction } + end, { desc = opts.label, noremap = true, silent = true }) end M._exec_toggle = function(opts) diff --git a/lua/lvim/lsp/init.lua b/lua/lvim/lsp/init.lua index 1b1fb1bd..4d975963 100644 --- a/lua/lvim/lsp/init.lua +++ b/lua/lvim/lsp/init.lua @@ -10,21 +10,10 @@ local function add_lsp_buffer_keybindings(bufnr) visual_mode = "v", } - if lvim.builtin.which_key.active then - -- Remap using which_key - local status_ok, wk = pcall(require, "which-key") - if not status_ok then - return - end - for mode_name, mode_char in pairs(mappings) do - wk.register(lvim.lsp.buffer_mappings[mode_name], { mode = mode_char, buffer = bufnr }) - end - else - -- Remap using nvim api - for mode_name, mode_char in pairs(mappings) do - for key, remap in pairs(lvim.lsp.buffer_mappings[mode_name]) do - vim.api.nvim_buf_set_keymap(bufnr, mode_char, key, remap[1], { noremap = true, silent = true }) - end + for mode_name, mode_char in pairs(mappings) do + for key, remap in pairs(lvim.lsp.buffer_mappings[mode_name]) do + local opts = { buffer = bufnr, desc = remap[2], noremap = true, silent = true } + vim.keymap.set(mode_char, key, remap[1], opts) end end end |