map lsp, goto {tdDri}, action {Ra}, diag {npq}

This commit is contained in:
leafee98 2023-12-15 13:06:43 +08:00
parent fdab14f6dc
commit e4de3f2670

View file

@ -15,6 +15,7 @@ function setup_keymap_lsp()
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
@ -26,10 +27,9 @@ function setup_keymap_lsp()
vim.keymap.set("n", "<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<leader>f", function()
vim.keymap.set("n", "gR", vim.lsp.buf.rename, opts)
vim.keymap.set({ "n", "v" }, "ga", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "g=", function()
vim.lsp.buf.format { async = true }
end, opts)
end,
@ -92,10 +92,13 @@ return {
setup_keymap_lsp()
end,
keys = {
{ "<leader>e", vim.diagnostic.open_float, mode = "n" },
{ "[d", vim.diagnostic.goto_prev, mode = "n" },
{ "]d", vim.diagnostic.goto_next, mode = "n" },
{ "<leader>q", vim.diagnostic.setloclist, mode = "n" }
{ "gs", "<cmd>LspStart<cr>", mode = "n" },
{ "gS", "<cmd>LspStop<cr>", mode = "n" },
{ "gI", "<cmd>LspInfo<cr>", mode = "n" },
{ "ge", vim.diagnostic.open_float, mode = "n" },
{ "gp", vim.diagnostic.goto_prev, mode = "n" },
{ "gn", vim.diagnostic.goto_next, mode = "n" },
{ "gq", vim.diagnostic.setloclist, mode = "n" }
},
},
}