Files
nvim/lua/lsp.lua
T
warg 2bc21b248c feat(lsp): refactor
* Move configs into config subdirectory
 * Move LSP logic into classes
 * Make it possible to define mason package in lsp config,
   including nested dependency resolution and post install
   steps
 * replace jedi_language_server with pylsp
2024-04-14 15:41:39 +02:00

79 lines
1.8 KiB
Lua

local module_name = "lsp"
local utils = require("utils")
---@class ServerConfig
local Server = require("lsp.server")
local M = {}
---@type table<string, ServerConfig>
local servers = {
bashls = {},
clangd = {},
cmake = {},
diagnosticls = {},
gopls = {},
groovyls = {},
intelephense = {},
pylsp = {},
lemminx = {},
lua_ls = {},
rust_analyzer = {},
zls = {},
}
for name, _ in pairs(servers) do
utils.try_require(
"lsp.config." .. name,
module_name,
---@param cfg ServerConfig
function (cfg)
cfg.name = name
servers[name] = Server:new(cfg)
end
)
end
--- Setup diagnostics UI
local function setup_diagnostics()
-- https://github.com/neovim/nvim-lspconfig/wiki/UI-Customization#customizing-how-diagnostics-are-displayed
vim.diagnostic.config({
underline = true,
signs = true,
virtual_text = {
prefix = "",
format = function (diagnostic)
return diagnostic.message
end,
},
float = {
show_header = false,
source = true,
border = "single",
focusable = false,
format = function (diagnostic)
return string.format("%s", diagnostic.message)
end,
},
update_in_insert = false,
severity_sort = false,
})
local signs = { Error = "󰅚 ", Warn = "󰀪 ", Hint = "󰌶 ", Info = "", }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl, })
end
end
function M.setup()
setup_diagnostics()
for _, server in pairs(servers) do
if server.enable then
server:register()
end
end
end
return M