diff options
| author | 2025-10-13 18:41:35 +0200 | |
|---|---|---|
| committer | 2025-10-13 18:42:14 +0200 | |
| commit | a9aa8f182cd17771c85ab9f7f4ee5d7ec9f46305 (patch) | |
| tree | 523a61d76b653f75edbf296fc630baec68cff54b | |
| parent | 18a0931e8e7bcbfeeefa0e149b4a1ae122e02e18 (diff) | |
chore: update lspconfig usage, split off server configsHEADorigin/mainmain
| -rw-r--r-- | lua/lsp-config.lua | 68 | ||||
| -rw-r--r-- | lua/plugins.lua | 42 |
2 files changed, 78 insertions, 32 deletions
diff --git a/lua/lsp-config.lua b/lua/lsp-config.lua new file mode 100644 index 0000000..fede73c --- /dev/null +++ b/lua/lsp-config.lua @@ -0,0 +1,68 @@ +return { + { name = 'intelephense' }, + { name = 'bashls' }, + { name = 'pylsp', config = { settings = { pylsp = { plugins = { pycodestyle = { enabled = false } } } } } }, + { name = 'clangd' }, + { name = 'ltex', config = { debounce_text_changes = 300, settings = { ltex = { language = "it-IT" } } } }, + { name = 'buf_ls' }, + { name = 'ts_ls' }, + { name = 'html' }, + { name = 'ruby_lsp' }, + { name = 'elixirls', config = { cmd= {"/usr/bin/elixir-ls" } } }, + { name = 'gopls' }, + { name = 'dartls' }, + -- { name = 'rust_analyzer', config = { settings = { ['rust-analyzer'] = { checkOnSave = { command = "clippy" } } } } }, + -- { name = 'java_language_server', config = { cmd = { '/home/alemi/dev/software/java-language-server/dist/lang_server_linux.sh' } } }, + -- { name = 'kotlin_language_server' }, + { + name = 'lua_ls', + config = { + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if + path ~= vim.fn.stdpath('config') + and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) + then + return + end + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using (most + -- likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Tell the language server how to find Lua modules same way as Neovim + -- (see `:h lua-module-load`) + path = { + 'lua/?.lua', + 'lua/?/init.lua', + }, + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME, + -- Depending on the usage, you might want to add additional paths + -- here. + -- '${3rd}/luv/library', + -- '${3rd}/busted/library', + }, + -- Or pull in all of 'runtimepath'. + -- NOTE: this is a lot slower and will cause issues when working on + -- your own configuration. + -- See https://github.com/neovim/nvim-lspconfig/issues/3189 + -- library = { + -- vim.api.nvim_get_runtime_file('', true), + -- }, + }, + }) + end, + settings = { + Lua = { telemetry = { enable = false } } + }, + }, + }, +} diff --git a/lua/plugins.lua b/lua/plugins.lua index 3e9ef6f..02a99af 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -32,18 +32,6 @@ return { 'fidian/hexmode', -- convert buffers into hex view with xxd 'alemidev/vim-combo', -- track code combos - { - "folke/lazydev.nvim", - ft = "lua", -- only load on lua files - opts = { - library = { - -- See the configuration section for more details - -- Load luvit types when the `vim.uv` word is found - { path = "luvit-meta/library", words = { "vim%.uv" } }, - }, - }, - }, - 'tpope/vim-fugitive', -- better git commands 'tpope/vim-surround', -- text object motions for surrounding @@ -232,26 +220,16 @@ return { config = function () local core_capabilities = vim.lsp.protocol.make_client_capabilities() local cmp_capabilities = require('cmp_nvim_lsp').default_capabilities(core_capabilities) - local capabilities = vim.tbl_deep_extend('force', core_capabilities, cmp_capabilities) - local lspconfig = require("lspconfig") - lspconfig.intelephense.setup({capabilities=capabilities, on_attach=set_lsp_binds}) - lspconfig.bashls.setup({capabilities=capabilities, on_attach=set_lsp_binds}) - lspconfig.pylsp.setup({capabilites = capabilities, on_attach = set_lsp_binds, settings = { pylsp = { plugins = { pycodestyle = { enabled = false } } } } }) - lspconfig.clangd.setup({capabilities=capabilities, on_attach=set_lsp_binds}) - lspconfig.ltex.setup({capabilities=capabilities, on_attach=set_lsp_binds, debounce_text_changes = 300, settings = { ltex = { language = "it-IT" }}}) - lspconfig.lua_ls.setup({capabilites=capabilities, on_attach=set_lsp_binds, settings = { - Lua = { telemetry = { enable = false }, workspace = { checkThirdParty = false }} - }}) -- default-on telemetry is never ok ... - lspconfig.buf_ls.setup({capabilities=capabilities, on_attach=set_lsp_binds}) - lspconfig.ts_ls.setup({capabilities=capabilities, on_attach=set_lsp_binds}) - lspconfig.html.setup({capabilities=capabilities, on_attach=set_lsp_binds}) - lspconfig.ruby_lsp.setup({capabilities=capabilities, on_attach=set_lsp_binds}) - lspconfig.elixirls.setup({capabilites=capabilities, on_attach=set_lsp_binds, cmd= {"/usr/bin/elixir-ls"}}) - lspconfig.gopls.setup({capabilities=capabilities, on_attach=set_lsp_binds}) - lspconfig.dartls.setup({capabilities=capabilities, on_attach=set_lsp_binds}) - -- lspconfig.rust_analyzer.setup({capabilities=capabilities, on_attach=set_lsp_binds, settings = { ['rust-analyzer'] = { checkOnSave = { command = "clippy"}}}}) - -- lspconfig.java_language_server.setup({capabilities=capabilities, on_attach=set_lsp_binds, cmd = { '/home/alemi/dev/software/java-language-server/dist/lang_server_linux.sh' }}) - -- lspconfig.kotlin_language_server.setup({capabilities=capabilities, on_attach=set_lsp_binds}) + local capabilities_keybinds_config = { + on_attach = set_lsp_binds, + capabilities = vim.tbl_deep_extend('force', core_capabilities, cmp_capabilities), + } + local lsp_config = require('lsp-config') + for _, server in pairs(lsp_config) do + local config = vim.tbl_deep_extend('force', server.config or {}, capabilities_keybinds_config) + vim.lsp.enable(server.name) + vim.lsp.config(server.name, config) + end end }, |
