mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-11-17 17:26:27 +00:00
Add function for wrapping prefixed keymap groups
This commit is contained in:
parent
6d2acddc56
commit
cf97331465
@ -65,6 +65,12 @@ local function default_attach(client, bufnr)
|
||||
-- Mappings
|
||||
-- TODO: Maybe prefix all of these for easier discovery
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
local lsp_keymap = utils.keymap_group("n", "<leader>l", opts, bufnr)
|
||||
lsp_keymap("h", "<cmd>lua vim.lsp.buf.hover()<CR>")
|
||||
lsp_keymap("r", "<cmd>lua vim.lsp.buf.rename()<CR>")
|
||||
lsp_keymap("e", "<cmd>lua vim.lsp.diagnostics.show_line_diagnostics()<CR>")
|
||||
|
||||
buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
|
@ -200,4 +200,17 @@ function M.map_version_rule(rules)
|
||||
return latest_value
|
||||
end
|
||||
|
||||
function M.keymap_group(mode, prefix, opts, bufnr)
|
||||
local map_fn = vim.api.nvim_set_keymap
|
||||
if bufnr ~= nil then
|
||||
map_fn = function(...)
|
||||
return vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
end
|
||||
|
||||
return function(keys, rhs, new_opts)
|
||||
map_fn(mode, prefix .. keys, rhs, new_opts or opts)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
Loading…
Reference in New Issue
Block a user