2024-09-19 12:58:41 -03:00
|
|
|
local on_lsp_attach = function(_client, _bufnr)
|
|
|
|
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration)
|
|
|
|
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
|
|
|
|
|
vim.keymap.set("n", "K", vim.lsp.buf.hover)
|
|
|
|
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation)
|
|
|
|
|
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help)
|
|
|
|
|
vim.keymap.set("n", "<Leader>D", vim.lsp.buf.type_definition)
|
|
|
|
|
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename)
|
|
|
|
|
vim.keymap.set("n", "<Leader>ca", vim.lsp.buf.code_action)
|
|
|
|
|
vim.keymap.set("n", "gr", vim.lsp.buf.references)
|
|
|
|
|
vim.keymap.set("n", "<Leader>e", vim.diagnostic.open_float)
|
2025-07-27 21:10:46 -04:00
|
|
|
vim.keymap.set("n", "[d", function() vim.diagnostic.jump({ count = -1 }) end)
|
|
|
|
|
vim.keymap.set("n", "]d", function() vim.diagnostic.jump({ count = 1 }) end)
|
2024-09-19 12:58:41 -03:00
|
|
|
vim.keymap.set("n", "<Leader>q", vim.diagnostic.setloclist)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
{
|
|
|
|
|
"neovim/nvim-lspconfig",
|
|
|
|
|
event = "VeryLazy",
|
|
|
|
|
config = function()
|
|
|
|
|
local lsp = require("lspconfig")
|
|
|
|
|
-- Use an on_attach function to only map the following keys
|
|
|
|
|
-- after the language server attaches to the current buffer
|
|
|
|
|
|
|
|
|
|
-- Use a loop to conveniently call 'setup' on multiple servers and
|
|
|
|
|
-- map buffer local keybindings when the language server attaches
|
|
|
|
|
local servers = {
|
|
|
|
|
clangd = {
|
|
|
|
|
filetypes = { "c", "cpp" }
|
|
|
|
|
},
|
|
|
|
|
dotls = {},
|
|
|
|
|
eslint = {},
|
|
|
|
|
gopls = {},
|
|
|
|
|
jsonls = {},
|
|
|
|
|
lua_ls = {
|
|
|
|
|
settings = {
|
|
|
|
|
Lua = {
|
|
|
|
|
runtime = { version = "LuaJIT" },
|
|
|
|
|
diagnostics = {
|
|
|
|
|
globals = { "vim" },
|
|
|
|
|
unusedLocalExclude = { "_*" },
|
|
|
|
|
},
|
|
|
|
|
workspace = {
|
|
|
|
|
checkThirdParty = false,
|
|
|
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
|
|
|
},
|
|
|
|
|
telemetry = { enable = false },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
pylsp = {},
|
|
|
|
|
rust_analyzer = {
|
|
|
|
|
settings = {
|
|
|
|
|
['rust-analyzer'] = {
|
|
|
|
|
cargo = {
|
|
|
|
|
features = "all"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
taplo = {},
|
|
|
|
|
texlab = {},
|
|
|
|
|
tflint = {},
|
|
|
|
|
ts_ls = {},
|
|
|
|
|
biome = {
|
|
|
|
|
cmd = { "pnpm", "exec", "biome", "lsp-proxy" }
|
|
|
|
|
},
|
2025-02-27 20:02:27 -03:00
|
|
|
tinymist = {},
|
2024-09-19 12:58:41 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
|
|
|
lsp.util.default_config = vim.tbl_deep_extend("force", lsp.util.default_config, { capabilities = capabilities })
|
|
|
|
|
for server, add_to_config in pairs(servers) do
|
|
|
|
|
local config = {
|
|
|
|
|
on_attach = on_lsp_attach,
|
|
|
|
|
flags = {
|
|
|
|
|
debounce_text_changes = 150,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
for k, v in pairs(add_to_config) do
|
|
|
|
|
config[k] = v
|
|
|
|
|
end
|
|
|
|
|
lsp[server].setup(config)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
|
|
|
lazy = true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"https://git.sr.ht/~whynothugo/lsp_lines.nvim",
|
|
|
|
|
enabled = false,
|
|
|
|
|
opts = {},
|
|
|
|
|
init = function()
|
|
|
|
|
-- Disable virtual_text since it's redundant due to lsp_lines.
|
|
|
|
|
vim.diagnostic.config({
|
|
|
|
|
virtual_text = false,
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
}
|