mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
nvim/lsp: flatten lspconfig configuration
This commit is contained in:
parent
ce5e5610e1
commit
1b9bf76dcd
1 changed files with 5 additions and 30 deletions
|
|
@ -1,10 +1,5 @@
|
|||
local map = vim.keymap.set
|
||||
local mylsp = require("lsp")
|
||||
|
||||
----------------------
|
||||
-- Language servers --
|
||||
----------------------
|
||||
-- NOTE: put settings into `settings`
|
||||
-- use another `on_attach` field if needed
|
||||
local servers = {
|
||||
clangd = {}, -- C/CPP
|
||||
cssls = {}, -- CSS
|
||||
|
|
@ -32,25 +27,13 @@ local servers = {
|
|||
|
||||
tinymist = {},
|
||||
|
||||
lua_ls = { -- Lua
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
checkThirdParty = "Disable",
|
||||
library = { vim.env.VIMRUNTIME },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
lua_ls = {},
|
||||
|
||||
nil_ls = { -- Nix
|
||||
settings = { ["nil"] = { formatting = { command = { "alejandra" } } } },
|
||||
["nil"] = { formatting = { command = { "alejandra" } } },
|
||||
},
|
||||
}
|
||||
|
||||
-------------
|
||||
-- Helpers --
|
||||
-------------
|
||||
vim.diagnostic.config {
|
||||
signs = {
|
||||
text = {
|
||||
|
|
@ -69,8 +52,6 @@ vim.diagnostic.config {
|
|||
},
|
||||
}
|
||||
|
||||
local mylsp = require("lsp")
|
||||
|
||||
-- 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, ...)
|
||||
|
|
@ -82,18 +63,12 @@ end
|
|||
-- Set log level
|
||||
vim.lsp.set_log_level("off")
|
||||
|
||||
----------
|
||||
-- Init --
|
||||
----------
|
||||
-- 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.settings,
|
||||
on_attach = function(client, bufno)
|
||||
mylsp.on_attach(client, bufno);
|
||||
(config.on_attach or function(...) end)(client, bufno)
|
||||
end,
|
||||
settings = config,
|
||||
on_attach = function(client, bufno) mylsp.on_attach(client, bufno) end,
|
||||
}
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue