Neovim/lua/plugins/lsp.lua

54 lines
1.7 KiB
Lua

return {
{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim"
},
opts = {
diagnostics = {
underline = true,
update_in_insert = true,
virtual_text = {
spacing = 4,
source = "if_many",
prefix = "",
},
severity_sort = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = require("options").lsp.icons.Error,
[vim.diagnostic.severity.WARN] = require("options").lsp.icons.Warn,
[vim.diagnostic.severity.HINT] = require("options").lsp.icons.Hint,
[vim.diagnostic.severity.INFO] = require("options").lsp.icons.Info,
},
},
},
},
config = function(_, opts)
local options = require("options")
require("mason").setup()
require("mason-lspconfig").setup()
-- automatically register lsp handler installed with mason
require("mason-lspconfig").setup_handlers {
-- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have
-- a dedicated handler.
function (server_name) -- default handler (optional)
require("lspconfig")[server_name].setup {}
end,
}
-- set custom icons
for name, icon in pairs(options.lsp.icons) do
name = "DiagnosticSign" .. name
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
end
vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
end
}
}