88 lines
3.5 KiB
Lua
88 lines
3.5 KiB
Lua
local M = { "williamboman/mason-lspconfig.nvim" }
|
|
local f = require("funcs")
|
|
local serverconf = require("config.lsp")
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
capabilities.textDocument.completion.completionItem.documentationFormat = { "markdown", "plaintext" }
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
capabilities.textDocument.completion.completionItem.preselectSupport = true
|
|
capabilities.textDocument.completion.completionItem.insertReplaceSupport = true
|
|
capabilities.textDocument.completion.completionItem.labelDetailsSupport = true
|
|
capabilities.textDocument.completion.completionItem.deprecatedSupport = true
|
|
capabilities.textDocument.completion.completionItem.commitCharactersSupport = true
|
|
capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } }
|
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|
properties = { "documentation", "detail", "additionalTextEdits" },
|
|
}
|
|
capabilities.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true }
|
|
|
|
local function merge(table, overwrite)
|
|
overwrite = overwrite or {}
|
|
return table and vim.tbl_deep_extend("force", table, overwrite) or overwrite
|
|
end
|
|
|
|
M.dependencies = { "mason.nvim", "neoconf.nvim", "neodev.nvim" }
|
|
|
|
M.cmd = { "LspInstall", "LspUninstall" }
|
|
|
|
M.config = function()
|
|
local icons = require("config.icons")
|
|
local signs = {
|
|
{ name = "DiagnosticSignError", text = icons.Error, texthl = "DiagnosticSignError" },
|
|
{ name = "DiagnosticSignWarn", text = icons.Warn, texthl = "DiagnosticSignWarn" },
|
|
{ name = "DiagnosticSignHint", text = icons.Hint, texthl = "DiagnosticSignHint" },
|
|
{ name = "DiagnosticSignInfo", text = icons.Info, texthl = "DiagnosticSignInfo" },
|
|
{ name = "DapStopped", text = icons.DapStopped, texthl = "DiagnosticWarn" },
|
|
{ name = "DapBreakpoint", text = icons.DapBreakpoint, texthl = "DiagnosticInfo" },
|
|
{ name = "DapBreakpointRejected", text = icons.DapBreakpointRejected, texthl = "DiagnosticError" },
|
|
{ name = "DapBreakpointCondition", text = icons.DapBreakpointCondition, texthl = "DiagnosticInfo" },
|
|
{ name = "DapLogPoint", text = icons.DapLogPoint, texthl = "DiagnosticInfo" },
|
|
}
|
|
for _, sign in ipairs(signs) do
|
|
vim.fn.sign_define(sign.name, sign)
|
|
end
|
|
|
|
vim.diagnostic.config({
|
|
virtual_text = true,
|
|
signs = {
|
|
text = {
|
|
[vim.diagnostic.severity.ERROR] = icons.Error,
|
|
[vim.diagnostic.severity.HINT] = icons.Hint,
|
|
[vim.diagnostic.severity.WARN] = icons.Warn,
|
|
[vim.diagnostic.severity.INFO] = icons.Info,
|
|
},
|
|
active = signs,
|
|
},
|
|
update_in_insert = true,
|
|
underline = true,
|
|
severity_sort = true,
|
|
float = {
|
|
focused = false,
|
|
style = "minimal",
|
|
border = "rounded",
|
|
source = "always",
|
|
header = "",
|
|
prefix = "",
|
|
},
|
|
})
|
|
|
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded", silent = true })
|
|
vim.lsp.handlers["textDocument/signatureHelp"] =
|
|
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded", silent = true })
|
|
|
|
local mlsp = require("mason-lspconfig")
|
|
mlsp.setup({ ensure_installed = serverconf.required })
|
|
|
|
mlsp.setup_handlers({
|
|
function(server)
|
|
if not f.has_value(serverconf.ignore, server) then
|
|
local ls = require("lspconfig")[server]
|
|
local ls_opts = merge(ls, { capabilities = capabilities, on_attach = require("funcs").lsp_on_attach })
|
|
local opts = merge(ls_opts, serverconf.handlers[server])
|
|
require("lspconfig")[server].setup(opts)
|
|
end
|
|
end,
|
|
})
|
|
end
|
|
|
|
return M
|