79 lines
2.2 KiB
Lua
79 lines
2.2 KiB
Lua
-- Servers start through native vim.lsp.enable. nvim-lspconfig only supplies
|
|
-- defaults; overrides live in lsp/<server>.lua. Called from plugins/lsp.lua.
|
|
local M = {}
|
|
|
|
M.servers = {
|
|
"nixd",
|
|
"lua_ls",
|
|
"bashls",
|
|
"yamlls",
|
|
"jsonls",
|
|
"marksman",
|
|
"rust_analyzer",
|
|
"gopls",
|
|
"vtsls",
|
|
"eslint",
|
|
"basedpyright",
|
|
"ruff",
|
|
"intelephense",
|
|
"tinymist",
|
|
}
|
|
|
|
local function restart()
|
|
vim.cmd(vim.fn.exists(":lsp") == 2 and "lsp restart" or "LspRestart")
|
|
end
|
|
|
|
function M.setup()
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
group = vim.api.nvim_create_augroup("core.lsp", { clear = true }),
|
|
callback = function(ev)
|
|
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
|
if not client then
|
|
return
|
|
end
|
|
if vim.b[ev.buf].bigfile then
|
|
vim.schedule(function()
|
|
vim.lsp.buf_detach_client(ev.buf, client.id)
|
|
end)
|
|
return
|
|
end
|
|
if client.name == "ruff" then
|
|
client.server_capabilities.hoverProvider = false -- basedpyright owns hover
|
|
end
|
|
if client.name == "vtsls" then
|
|
-- prettierd formats TypeScript
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
client.server_capabilities.documentRangeFormattingProvider = false
|
|
end
|
|
|
|
local function map(lhs, rhs, desc)
|
|
vim.keymap.set("n", lhs, rhs, { buffer = ev.buf, desc = desc })
|
|
end
|
|
map("<leader>li", "<cmd>checkhealth vim.lsp<cr>", "LSP info")
|
|
map("<leader>lr", restart, "Restart LSP servers")
|
|
end,
|
|
})
|
|
|
|
-- No inline text; the diagnostic under the cursor opens in a float on CursorHold.
|
|
vim.diagnostic.config({
|
|
virtual_text = false,
|
|
signs = true,
|
|
underline = true,
|
|
update_in_insert = false,
|
|
severity_sort = true,
|
|
float = { border = "rounded", source = true },
|
|
})
|
|
vim.api.nvim_create_autocmd("CursorHold", {
|
|
group = vim.api.nvim_create_augroup("core.lsp.float", { clear = true }),
|
|
callback = function()
|
|
vim.diagnostic.open_float(nil, { focusable = false, scope = "cursor", prefix = " " })
|
|
end,
|
|
})
|
|
|
|
vim.lsp.inlay_hint.enable(true) -- gopls and lua_ls hints; <leader>ui toggles
|
|
|
|
vim.lsp.enable(M.servers)
|
|
end
|
|
|
|
return M
|