.files/.config/nvim/plugin/lsp.lua

74 lines
1.9 KiB
Lua

local mylsp = require("lsp")
local servers = {
clangd = {}, -- C/CPP
cssls = {}, -- CSS
html = {}, -- HTML
jsonls = {}, -- JSON
lemminx = {}, -- XML
phpactor = {}, -- PHP
pylsp = {}, -- Python
pyright = {},
taplo = {}, -- TOML
texlab = {}, -- texlab
ts_ls = {}, -- TypeScript
vimls = {}, -- Vim Script
ocamllsp = {}, -- OCaml
gleam = {}, -- Gleam
yamlls = {}, -- yaml
gopls = {}, -- Golang
elmls = {}, -- elm
-- -- fix this, it shows spamming message on top
-- golangci_lint_ls = {},
fish_lsp = {},
bashls = {},
tinymist = {},
lua_ls = {},
nil_ls = { -- Nix
["nil"] = { formatting = { command = { "alejandra" } } },
},
}
vim.diagnostic.config {
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "E",
[vim.diagnostic.severity.WARN] = "W",
[vim.diagnostic.severity.INFO] = "H",
[vim.diagnostic.severity.HINT] = "·",
},
},
severity_sort = true,
underline = {
severity = {
vim.diagnostic.severity.ERROR,
vim.diagnostic.severity.WARN,
},
},
}
-- Helix style border
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
opts = opts or {}
opts.border = mylsp.border
return orig_util_open_floating_preview(contents, syntax, opts, ...)
end
-- Set log level
vim.lsp.set_log_level("off")
-- It is not recommended to break lspconfig into different settings
-- related: https://github.com/neovim/nvim-lspconfig/issues/970#issuecomment-860080502
for name, config in pairs(servers) do
require("lspconfig")[name].setup {
capabilities = mylsp.capabilities,
settings = config,
on_attach = function(client, bufno) mylsp.on_attach(client, bufno) end,
}
end