168 lines
4.8 KiB
Lua
168 lines
4.8 KiB
Lua
return {
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
dependencies = {
|
|
{ "mason-org/mason.nvim", opts = {} },
|
|
"mason-org/mason-lspconfig.nvim",
|
|
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
|
},
|
|
config = function()
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
|
|
callback = function(event)
|
|
-- NOTE: This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
|
|
local function client_supports_method(client, method, bufnr)
|
|
if vim.fn.has("nvim-0.11") == 1 then
|
|
return client:supports_method(method, bufnr)
|
|
else
|
|
return client.supports_method(method, { bufnr = bufnr })
|
|
end
|
|
end
|
|
|
|
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
|
if
|
|
client
|
|
and client_supports_method(
|
|
client,
|
|
vim.lsp.protocol.Methods.textDocument_documentHighlight,
|
|
event.buf
|
|
)
|
|
then
|
|
local highlight_augroup =
|
|
vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
|
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
|
buffer = event.buf,
|
|
group = highlight_augroup,
|
|
callback = vim.lsp.buf.document_highlight,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
|
buffer = event.buf,
|
|
group = highlight_augroup,
|
|
callback = vim.lsp.buf.clear_references,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("LspDetach", {
|
|
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
|
|
callback = function(event2)
|
|
vim.lsp.buf.clear_references()
|
|
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
|
|
end,
|
|
})
|
|
end
|
|
end,
|
|
})
|
|
|
|
vim.diagnostic.config({
|
|
severity_sort = true,
|
|
float = { border = "rounded", source = "if_many" },
|
|
underline = { severity = vim.diagnostic.severity.ERROR },
|
|
signs = vim.g.have_nerd_font and {
|
|
text = {
|
|
[vim.diagnostic.severity.ERROR] = " ",
|
|
[vim.diagnostic.severity.WARN] = " ",
|
|
[vim.diagnostic.severity.INFO] = " ",
|
|
[vim.diagnostic.severity.HINT] = " ",
|
|
},
|
|
} or {},
|
|
virtual_text = {
|
|
source = "if_many",
|
|
spacing = 2,
|
|
format = function(diagnostic)
|
|
local diagnostic_message = {
|
|
[vim.diagnostic.severity.ERROR] = diagnostic.message,
|
|
[vim.diagnostic.severity.WARN] = diagnostic.message,
|
|
[vim.diagnostic.severity.INFO] = diagnostic.message,
|
|
[vim.diagnostic.severity.HINT] = diagnostic.message,
|
|
}
|
|
return diagnostic_message[diagnostic.severity]
|
|
end,
|
|
},
|
|
})
|
|
|
|
local border = "rounded"
|
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
|
|
|
|
vim.lsp.handlers["textDocument/signatureHelp"] =
|
|
vim.lsp.with(vim.lsp.handlers.signature_help, { border = border })
|
|
|
|
require("lspconfig.ui.windows").default_options = {
|
|
border = border,
|
|
}
|
|
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
capabilities.offsetEncoding = { "utf-16" }
|
|
|
|
local servers = {
|
|
lua_ls = {
|
|
settings = {
|
|
Lua = {
|
|
completion = {
|
|
callSnippet = "Replace",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
pylsp = {
|
|
settings = {
|
|
configurationSources = { "pycodestyle" },
|
|
plugins = {
|
|
pyflakes = { enabled = true },
|
|
mccabe = { enabled = true },
|
|
pycodestyle = { enabled = true },
|
|
pydocstyle = { enabled = true },
|
|
yapf = { enabled = true },
|
|
},
|
|
},
|
|
},
|
|
astro = {},
|
|
clangd = {},
|
|
csharp_ls = {},
|
|
gopls = {},
|
|
hls = { settings = { haskell = { formattingProvider = "ormolu" } } },
|
|
java_language_server = {},
|
|
nixd = {},
|
|
sqls = {},
|
|
zls = {},
|
|
}
|
|
|
|
local ensure_installed = vim.tbl_keys(servers or {})
|
|
vim.list_extend(ensure_installed, {})
|
|
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
|
|
|
|
require("mason-lspconfig").setup({
|
|
ensure_installed = {},
|
|
automatic_installation = false,
|
|
handlers = {
|
|
function(server_name)
|
|
local server = servers[server_name] or {}
|
|
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
|
|
require("lspconfig")[server_name].setup(server)
|
|
end,
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
{
|
|
"mrcjkb/rustaceanvim",
|
|
version = "^6",
|
|
ft = { "rust" },
|
|
config = function()
|
|
vim.g.rustaceanvim = {
|
|
tools = {
|
|
autoSetHints = true,
|
|
hover_with_actions = true,
|
|
},
|
|
}
|
|
end,
|
|
},
|
|
{
|
|
"pmizio/typescript-tools.nvim",
|
|
ft = { "typescript", "typescriptreact", "javascript", "javascriptreact" },
|
|
opts = {
|
|
separate_diagnostic_server = true,
|
|
expose_as_code_action = "all",
|
|
},
|
|
},
|
|
}
|