mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-12-22 23:17:35 +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
|
-- Mappings
|
||||||
-- TODO: Maybe prefix all of these for easier discovery
|
-- TODO: Maybe prefix all of these for easier discovery
|
||||||
local opts = { noremap = true, silent = true }
|
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.declaration()<CR>", opts)
|
||||||
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<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)
|
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
|
return latest_value
|
||||||
end
|
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
|
return M
|
||||||
|
Loading…
Reference in New Issue
Block a user