mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 22:59:15 +00:00
99 lines
2.6 KiB
Lua
99 lines
2.6 KiB
Lua
local mylsp = require("lsp")
|
|
|
|
local servers = {
|
|
clangd = {},
|
|
cssls = {},
|
|
html = {},
|
|
jsonls = {},
|
|
ts_ls = {},
|
|
|
|
taplo = {},
|
|
yamlls = {},
|
|
|
|
bashls = {},
|
|
fish_lsp = {},
|
|
|
|
pyright = {},
|
|
lua_ls = {},
|
|
gopls = {},
|
|
-- -- fix this, it shows spamming message on top
|
|
-- golangci_lint_ls = {},
|
|
tinymist = {},
|
|
nil_ls = {
|
|
settings = {
|
|
["nil"] = { formatting = { command = { "alejandra" } } },
|
|
},
|
|
},
|
|
}
|
|
|
|
vim.diagnostic.config {
|
|
signs = {
|
|
text = {
|
|
[vim.diagnostic.severity.ERROR] = "E",
|
|
[vim.diagnostic.severity.WARN] = "W",
|
|
[vim.diagnostic.severity.INFO] = "I",
|
|
[vim.diagnostic.severity.HINT] = "H",
|
|
},
|
|
},
|
|
severity_sort = true,
|
|
underline = {
|
|
severity = {
|
|
vim.diagnostic.severity.ERROR,
|
|
vim.diagnostic.severity.WARN,
|
|
},
|
|
},
|
|
}
|
|
|
|
do
|
|
local index = 1
|
|
|
|
---@type vim.diagnostic.Opts[]
|
|
local modes = {
|
|
{
|
|
virtual_text = false,
|
|
virtual_lines = { severity = { vim.diagnostic.severity.ERROR } },
|
|
},
|
|
{ virtual_text = false, virtual_lines = false },
|
|
{ virtual_text = true, virtual_lines = false },
|
|
}
|
|
vim.diagnostic.config(modes[index])
|
|
|
|
---@param direction 'forward' | 'backward'
|
|
local function cycle_diagnostic_modes(direction)
|
|
if direction == "forward" then
|
|
index = (index % #modes) + 1
|
|
else
|
|
index = (index - 2 + #modes) % #modes + 1
|
|
end
|
|
|
|
vim.diagnostic.config(modes[index])
|
|
end
|
|
|
|
vim.keymap.set("n", "]d", function() cycle_diagnostic_modes("forward") end)
|
|
vim.keymap.set("n", "[d", function() cycle_diagnostic_modes("backward") end)
|
|
end
|
|
|
|
-- Helix style border
|
|
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
|
---@diagnostic disable-next-line: duplicate-set-field
|
|
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, user_config in pairs(servers) do
|
|
local default_config = {
|
|
capabilities = mylsp.capabilities,
|
|
settings = user_config,
|
|
on_attach = function(client, bufno) mylsp.on_attach(client, bufno) end,
|
|
}
|
|
local merged_config = vim.tbl_deep_extend("force", default_config, user_config)
|
|
|
|
require("lspconfig")[name].setup(merged_config)
|
|
end
|