diff --git a/lua/core/autocommands.lua b/lua/core/autocommands.lua index 636f798..96f84cf 100644 --- a/lua/core/autocommands.lua +++ b/lua/core/autocommands.lua @@ -157,3 +157,12 @@ vim.api.nvim_create_autocmd("TermLeave", { vim.cmd.checktime() end, }) + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "vim", "help" }, + callback = function(args) + vim.keymap.set("n", "K", function() + vim.cmd("help " .. vim.fn.expand("")) + end, { buffer = args.buf }) + end, +}) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 839ff5c..924b0b2 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -94,13 +94,6 @@ vim.keymap.set({ "x" }, ">", ">gv") -- Remove default mappings vim.keymap.set("", "", "") vim.keymap.set("n", "gr", "") -vim.keymap.set("n", "K", function() - if vim.bo.filetype == "vim" or vim.bo.filetype == "help" then - vim.cmd("help " .. vim.fn.expand("")) - else - vim.cmd("Man " .. vim.fn.expand("")) - end -end) -- Remove right-click menu items vim.cmd.aunmenu({ "PopUp.-1-" }) diff --git a/lua/lsp/keymap.lua b/lua/lsp/keymap.lua index e857105..9d721c3 100644 --- a/lua/lsp/keymap.lua +++ b/lua/lsp/keymap.lua @@ -42,15 +42,15 @@ function Keymap.set_defaults(bufnr) }, { mode = { "n" }, lhs = "gD", rhs = vim.lsp.buf.declaration }, { - mode = { "n", "i" }, - lhs = "", + mode = "n", + lhs = "K", rhs = function() vim.lsp.buf.hover({ border = "rounded", max_width = 80 }) end, }, { - mode = { "n", "i" }, - lhs = "", + mode = "i", + lhs = "", rhs = function() vim.lsp.buf.signature_help({ border = "rounded",