From 1b9bf76dcd7f5eec405a7bde7832aec988d76c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 9 Jul 2025 10:33:25 +0200 Subject: [PATCH] nvim/lsp: flatten lspconfig configuration --- .config/nvim/plugin/lsp.lua | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/.config/nvim/plugin/lsp.lua b/.config/nvim/plugin/lsp.lua index c8fa1488..ed169743 100644 --- a/.config/nvim/plugin/lsp.lua +++ b/.config/nvim/plugin/lsp.lua @@ -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