with keybinds
This commit is contained in:
@@ -14,7 +14,7 @@ function M.config()
|
||||
local function on_attach(client, bufnr)
|
||||
require("nvim-navic").attach(client, bufnr)
|
||||
require("plugins.lsp.formatting").setup(client, bufnr)
|
||||
--require("plugins.lsp.keys").setup(client, bufnr)
|
||||
require("plugins.lsp.keys").setup(client, bufnr)
|
||||
end
|
||||
|
||||
---@type lspconfig.options
|
||||
@@ -87,10 +87,9 @@ function M.config()
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
flags = {
|
||||
debounce_text_change = 150,
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
}
|
||||
|
||||
for server, opts in pairs(servers) do
|
||||
opts = vim.tbl_deep_extend("force", {}, options, opts or {})
|
||||
require("lspconfig")[server].setup(opts)
|
||||
|
70
lua/plugins/lsp/keys.lua
Normal file
70
lua/plugins/lsp/keys.lua
Normal file
@@ -0,0 +1,70 @@
|
||||
local wk = require("which-key")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.setup(client, buffer)
|
||||
local cap = client.server_capabilities
|
||||
|
||||
local keymap = {
|
||||
buffer = buffer,
|
||||
["<leader>"] = {
|
||||
c = {
|
||||
name = "+code",
|
||||
r = {
|
||||
vim.lsp.buf.rename,
|
||||
"Rename",
|
||||
cond = cap.renameProvider,
|
||||
},
|
||||
a = {
|
||||
{ vim.lsp.buf.code_action, "Code Action" },
|
||||
{ "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action", mode = "v" },
|
||||
},
|
||||
f = {
|
||||
{
|
||||
require("plugins.lsp.formatting").format,
|
||||
"Format Document",
|
||||
cond = cap.documentFormatting,
|
||||
},
|
||||
{
|
||||
require("plugins.lsp.formatting").format,
|
||||
"Format Range",
|
||||
cond = cap.documentRangeFormatting,
|
||||
mode = "v",
|
||||
},
|
||||
},
|
||||
d = { vim.diagnostic.open_float, "Line Diagnostics" },
|
||||
l = {
|
||||
name = "+lsp",
|
||||
i = { "<cmd>LspInfo<cr>", "Lsp Info" },
|
||||
a = { "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", "Add Folder" },
|
||||
r = { "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", "Remove Folder" },
|
||||
l = { "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", "List Folders" },
|
||||
},
|
||||
},
|
||||
x = {
|
||||
d = { "<cmd>Telescope diagnostics<cr>", "Search Diagnostics" },
|
||||
},
|
||||
},
|
||||
g = {
|
||||
name = "+goto",
|
||||
d = { "<cmd>Telescope lsp_definitions<cr>", "Goto Definition" },
|
||||
r = { "<cmd>Telescope lsp_references<cr>", "References" },
|
||||
R = { "<cmd>Trouble lsp_references<cr>", "Trouble References" },
|
||||
D = { "<cmd>Telescope lsp_declarations<CR>", "Goto Declaration" },
|
||||
s = { "<cmd>lua vim.lsp.buf.signature_help()<CR>", "Signature Help" },
|
||||
I = { "<cmd>Telescope lsp_implementations<CR>", "Goto Implementation" },
|
||||
t = { "<cmd>Telescope lsp_type_definitions<cr>", "Goto Type Definition" },
|
||||
},
|
||||
["K"] = { "<cmd>lua vim.lsp.buf.hover()<CR>", "Hover" },
|
||||
["[d"] = { "<cmd>lua vim.diagnostic.goto_prev()<CR>", "Next Diagnostic" },
|
||||
["]d"] = { "<cmd>lua vim.diagnostic.goto_next()<CR>", "Prev Diagnostic" },
|
||||
["[e"] = { "<cmd>lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})<CR>", "Next Error" },
|
||||
["]e"] = { "<cmd>lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})<CR>", "Prev Error" },
|
||||
["[w"] = { "<cmd>lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.WARNING})<CR>", "Next Warning" },
|
||||
["]w"] = { "<cmd>lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.WARNING})<CR>", "Prev Warning" },
|
||||
}
|
||||
|
||||
wk.register(keymap)
|
||||
end
|
||||
|
||||
return M
|
Reference in New Issue
Block a user