From 922761455bffd18b525b9d7cbd24599bc9e46fa0 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sun, 4 Feb 2024 12:44:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20lsp=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/nvim/lua/settings/lsp.lua | 134 ++++++++++++++++--------------- home-manager/headless/neovim.nix | 3 +- 2 files changed, 70 insertions(+), 67 deletions(-) diff --git a/config/nvim/lua/settings/lsp.lua b/config/nvim/lua/settings/lsp.lua index be5d6c8..ebd8a2e 100644 --- a/config/nvim/lua/settings/lsp.lua +++ b/config/nvim/lua/settings/lsp.lua @@ -1,91 +1,93 @@ -- LSP servers local servers = { - lua_ls = { - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - }, - }, - nil_ls = {}, - statix = {}, - biome = {}, - tsserver = {}, - jsonls = {}, - cssls = {}, - eslint = {}, - bashls = {}, - texlab = {}, - ltex = {}, + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, + nil_ls = {}, + statix = {}, + biome = {}, + tsserver = {}, + jsonls = {}, + cssls = {}, + eslint = {}, + bashls = {}, + texlab = {}, + ltex = {}, - lemminx = {}, - jdtls = {}, - kotlin_language_server = {} + lemminx = {}, + jdtls = {}, + kotlin_language_server = {}, } local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) local on_attach = function(client, bufnr) - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end + local nmap = function(keys, func, desc) + if desc then + desc = "LSP: " .. desc + end - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) - end + vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) + end - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - nmap('cf', vim.lsp.buf.format, '[C]ode [F]ormat') - nmap('cr', vim.lsp.buf.rename, '[C]ode [R]ename') + nmap("ca", vim.lsp.buf.code_action, "[C]ode [A]ction") + nmap("cf", vim.lsp.buf.format, "[C]ode [F]ormat") + nmap("cr", vim.lsp.buf.rename, "[C]ode [R]ename") - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + nmap("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") + nmap("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") - -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- See `:help K` for why this keymap + nmap("K", vim.lsp.buf.hover, "Hover Documentation") + nmap("", vim.lsp.buf.signature_help, "Signature Documentation") - -- Lesser used LSP functionality - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') + -- Lesser used LSP functionality + nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") + nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + nmap("wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") + nmap("wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") + nmap("wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, "[W]orkspace [L]ist Folders") - if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format({ bufnr = bufnr }) - end, - }) - end + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + end end -- Setup neovim lua configuration -require('neodev').setup() +require("neodev").setup() -local lsp = require 'lspconfig' +local lsp = require("lspconfig") for server_name, config in pairs(servers) do - lsp[server_name].setup { - on_attach = on_attach, - settings = config, - } + lsp[server_name].setup({ + on_attach = on_attach, + settings = config, + }) end -local null_ls = require 'null-ls' +local null_ls = require("null-ls") null_ls.setup({ - sources = { - null_ls.builtins.diagnostics.luacheck, - null_ls.builtins.formatting.stylua, - null_ls.builtins.diagnostics.ktlint, - null_ls.builtins.formatting.ktlint - } + sources = { + null_ls.builtins.diagnostics.luacheck, + null_ls.builtins.diagnostics.tidy, + null_ls.builtins.diagnostics.ktlint, + null_ls.builtins.formatting.stylua, + null_ls.builtins.formatting.ktlint, + null_ls.builtins.formatting.tidy, + }, }) -local telescope = require 'telescope' -telescope.load_extension('ui-select') +local telescope = require("telescope") +telescope.load_extension("ui-select") diff --git a/home-manager/headless/neovim.nix b/home-manager/headless/neovim.nix index 19db553..b48a02b 100644 --- a/home-manager/headless/neovim.nix +++ b/home-manager/headless/neovim.nix @@ -25,8 +25,9 @@ nil statix - # XML + # XML/HTML lemminx + html-tidy # Kotlin/Java jdt-language-server