Make lspconfig mappings configurable.
This commit is contained in:
parent
1cd5150b70
commit
31e551af30
@ -190,6 +190,27 @@ M.mappings.plugins = {
|
|||||||
esc_insertmode = { "jk" }, -- multiple mappings allowed
|
esc_insertmode = { "jk" }, -- multiple mappings allowed
|
||||||
},
|
},
|
||||||
|
|
||||||
|
lspconfig = {
|
||||||
|
declaration = "gD",
|
||||||
|
definition = "gd",
|
||||||
|
hover = "K",
|
||||||
|
implementation = "gi",
|
||||||
|
signature_help = "gk",
|
||||||
|
add_workspace_folder = "<leader>wa",
|
||||||
|
remove_workspace_folder = "<leader>wr",
|
||||||
|
list_workspace_folders = "<leader>wl",
|
||||||
|
type_definition = "<leader>D",
|
||||||
|
rename = "<leader>rn",
|
||||||
|
code_action = "<leader>ca",
|
||||||
|
references = "gr",
|
||||||
|
show_line_diagnostics = "ge",
|
||||||
|
goto_prev = "[d",
|
||||||
|
goto_next = "]d",
|
||||||
|
set_loclist = "<leader>q",
|
||||||
|
formatting = "<leader>fm",
|
||||||
|
range_code_action = "<leader>ca",
|
||||||
|
},
|
||||||
|
|
||||||
nvimtree = {
|
nvimtree = {
|
||||||
toggle = "<C-n>",
|
toggle = "<C-n>",
|
||||||
focus = "<leader>e",
|
focus = "<leader>e",
|
||||||
|
@ -138,6 +138,30 @@ M.dashboard = function()
|
|||||||
map("n", m.session_save, ":SessionSave <CR>")
|
map("n", m.session_save, ":SessionSave <CR>")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.lspconfig = function()
|
||||||
|
local m = plugin_maps.lspconfig
|
||||||
|
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
map("n", m.declaration, "<cmd>lua vim.lsp.buf.declaration()<CR>")
|
||||||
|
map("n", m.definition, "<cmd>lua vim.lsp.buf.definition()<CR>")
|
||||||
|
map("n", m.hover, "<cmd>lua vim.lsp.buf.hover()<CR>")
|
||||||
|
map("n", m.implementation, "<cmd>lua vim.lsp.buf.implementation()<CR>")
|
||||||
|
map("n", m.signature_help, "<cmd>lua vim.lsp.buf.signature_help()<CR>")
|
||||||
|
map("n", m.add_workspace_folder, "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
|
||||||
|
map("n", m.remove_workspace_folder, "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>")
|
||||||
|
map("n", m.list_workspace_folders, "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>")
|
||||||
|
map("n", m.type_definition, "<cmd>lua vim.lsp.buf.type_definition()<CR>")
|
||||||
|
map("n", m.rename, "<cmd>lua vim.lsp.buf.rename()<CR>")
|
||||||
|
map("n", m.code_action, "<cmd>lua vim.lsp.buf.code_action()<CR>")
|
||||||
|
map("n", m.references, "<cmd>lua vim.lsp.buf.references()<CR>")
|
||||||
|
map("n", m.show_line_diagnostics, "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>")
|
||||||
|
map("n", m.goto_prev, "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>")
|
||||||
|
map("n", m.goto_next, "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>")
|
||||||
|
map("n", m.set_loclist, "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>")
|
||||||
|
map("n", m.formatting, "<cmd>lua vim.lsp.buf.formatting()<CR>")
|
||||||
|
map("v", m.range_code_action, "<cmd>lua vim.lsp.buf.range_code_action()<CR>")
|
||||||
|
end
|
||||||
|
|
||||||
M.nvimtree = function()
|
M.nvimtree = function()
|
||||||
map("n", plugin_maps.nvimtree.toggle, ":NvimTreeToggle <CR>")
|
map("n", plugin_maps.nvimtree.toggle, ":NvimTreeToggle <CR>")
|
||||||
map("n", plugin_maps.nvimtree.focus, ":NvimTreeFocus <CR>")
|
map("n", plugin_maps.nvimtree.focus, ":NvimTreeFocus <CR>")
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
require("plugins.configs.others").lsp_handlers()
|
require("plugins.configs.others").lsp_handlers()
|
||||||
|
|
||||||
local function on_attach(_, bufnr)
|
local function on_attach(_, bufnr)
|
||||||
local function buf_set_keymap(...)
|
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
|
||||||
end
|
|
||||||
local function buf_set_option(...)
|
local function buf_set_option(...)
|
||||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
vim.api.nvim_buf_set_option(bufnr, ...)
|
||||||
end
|
end
|
||||||
@ -11,28 +8,7 @@ local function on_attach(_, bufnr)
|
|||||||
-- Enable completion triggered by <c-x><c-o>
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
|
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||||
|
|
||||||
-- Mappings.
|
require("core.mappings").lspconfig()
|
||||||
local opts = { noremap = true, silent = true }
|
|
||||||
|
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
||||||
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)
|
|
||||||
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "gk", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "ge", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>fm", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
|
||||||
buf_set_keymap("v", "<space>ca", "<cmd>lua vim.lsp.buf.range_code_action()<CR>", opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
Loading…
Reference in New Issue
Block a user