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 = {
|
local servers = {
|
||||||
clangd = {}, -- C/CPP
|
clangd = {}, -- C/CPP
|
||||||
cssls = {}, -- CSS
|
cssls = {}, -- CSS
|
||||||
|
|
@ -32,25 +27,13 @@ local servers = {
|
||||||
|
|
||||||
tinymist = {},
|
tinymist = {},
|
||||||
|
|
||||||
lua_ls = { -- Lua
|
lua_ls = {},
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
workspace = {
|
|
||||||
checkThirdParty = "Disable",
|
|
||||||
library = { vim.env.VIMRUNTIME },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
nil_ls = { -- Nix
|
nil_ls = { -- Nix
|
||||||
settings = { ["nil"] = { formatting = { command = { "alejandra" } } } },
|
["nil"] = { formatting = { command = { "alejandra" } } },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-------------
|
|
||||||
-- Helpers --
|
|
||||||
-------------
|
|
||||||
vim.diagnostic.config {
|
vim.diagnostic.config {
|
||||||
signs = {
|
signs = {
|
||||||
text = {
|
text = {
|
||||||
|
|
@ -69,8 +52,6 @@ vim.diagnostic.config {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local mylsp = require("lsp")
|
|
||||||
|
|
||||||
-- Helix style border
|
-- Helix style border
|
||||||
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
||||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||||
|
|
@ -82,18 +63,12 @@ end
|
||||||
-- Set log level
|
-- Set log level
|
||||||
vim.lsp.set_log_level("off")
|
vim.lsp.set_log_level("off")
|
||||||
|
|
||||||
----------
|
|
||||||
-- Init --
|
|
||||||
----------
|
|
||||||
-- It is not recommended to break lspconfig into different settings
|
-- It is not recommended to break lspconfig into different settings
|
||||||
-- related: https://github.com/neovim/nvim-lspconfig/issues/970#issuecomment-860080502
|
-- related: https://github.com/neovim/nvim-lspconfig/issues/970#issuecomment-860080502
|
||||||
for name, config in pairs(servers) do
|
for name, config in pairs(servers) do
|
||||||
require("lspconfig")[name].setup {
|
require("lspconfig")[name].setup {
|
||||||
capabilities = mylsp.capabilities,
|
capabilities = mylsp.capabilities,
|
||||||
settings = config.settings,
|
settings = config,
|
||||||
on_attach = function(client, bufno)
|
on_attach = function(client, bufno) mylsp.on_attach(client, bufno) end,
|
||||||
mylsp.on_attach(client, bufno);
|
|
||||||
(config.on_attach or function(...) end)(client, bufno)
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue