return { { "neovim/nvim-lspconfig", dependencies = { "j-hui/fidget.nvim", "folke/neodev.nvim", "RRethy/vim-illuminate", "hrsh7th/cmp-nvim-lsp", }, config = function() local map = require("helpers.keys").map map('n', 'e', vim.diagnostic.open_float, "lsp: open diagnostics float") map('n', '[d', vim.diagnostic.goto_prev, "lsp: goto previous diagnostic") map('n', ']d', vim.diagnostic.goto_next, "lsp: goto next diagnostic") -- neodev setup before lsp config require("neodev").setup() -- set up cool signs for diagnostics local signs = { Error = " ", Warn = "", Hint = "", Info = "" } for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) end -- Diagnostic config local config = { virtual_text = false, signs = { active = signs, }, update_in_insert = true, underline = true, severity_sort = true, float = { focusable = true, style = "minimal", border = "rounded", source = "always", header = "", prefix = "", }, } vim.diagnostic.config(config) -- this function gets run when an lsp connects to a particular buffer. local on_attach = function(_, bufnr) map = require("helpers.keys").lsp_map map("lr", vim.lsp.buf.rename, bufnr, "lsp: rename symbol") map("la", vim.lsp.buf.code_action, bufnr, "lsp: code action") map("ld", vim.lsp.buf.type_definition, bufnr, "lsp: type definition") map("ls", require("telescope.builtin").lsp_document_symbols, bufnr, "lsp: document symbols") map("gd", vim.lsp.buf.definition, bufnr, "lsp: goto definition") map("gD", vim.lsp.buf.declaration, bufnr, "lsp: goto declaration") map("gr", require("telescope.builtin").lsp_references, bufnr, "lsp: goto references") map("gI", vim.lsp.buf.implementation, bufnr, "lsp: goto implementation") map("K", vim.lsp.buf.hover, bufnr, "lsp: hover documentation") map("", vim.lsp.buf.signature_help, bufnr, "lsp: signature help") -- Create a command `:Format` local to the LSP buffer vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) vim.lsp.buf.format() end, { desc = "lsp: format current buffer" }) map("fm", "Format", bufnr, "lsp: format current buffer") end -- nvim-cmp supports additional completion capabilities, so broadcast that to servers local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) -- pkgbuild require("lspconfig").pkgbuild_language_server.setup({}) -- lua require("lspconfig")["lua_ls"].setup({ on_attach = on_attach, capabilities = capabilities, settings = { Lua = { completion = { callSnippet = "Replace", }, diagnostics = { globals = { "vim" }, }, workspace = { library = { [vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.stdpath("config") .. "/lua"] = true, }, }, }, }, }) -- python require("lspconfig")["pylsp"].setup({ on_attach = on_attach, capabilities = capabilities, settings = { pylsp = { plugins = { -- we had to disable this here for ruff + black to work pycodestyle = { enabled = false, }, ruff = { enabled = true, extendSelect = { "I" }, }, black = { enabled = true, }, }, }, }, }) -- efm require("lspconfig")["efm"].setup({ on_attach = on_attach, filetypes = { 'sh' }, capabilities = capabilities }) -- ltex require("lspconfig")["ltex"].setup({ capabilities = capabilities, on_attach = function(client, bufnr) on_attach(client, bufnr) require("ltex_extra").setup { load_langs = { "en-GB" }, init_check = true, log_level = "none", } end, settings = { ltex = { -- my settings here } } }) -- rust-tools local rust_opts = { tools = { runnables = { use_telescope = true, }, inlay_hints = { auto = true, show_parameter_hints = true, parameter_hints_prefix = "↸ ", other_hints_prefix = "❱ ", }, }, -- all the opts to send to nvim-lspconfig -- these override the defaults set by rust-tools.nvim -- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer server = { on_attach = on_attach, settings = { -- to enable rust-analyzer settings visit: -- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc ["rust-analyzer"] = { -- enable clippy on save checkOnSave = { command = "clippy", }, }, }, }, } require('rust-tools').setup(rust_opts) end, }, { "barreiroleo/ltex-extra.nvim", event = "LspAttach", }, { "j-hui/fidget.nvim", event = "VeryLazy", opts = { text = { spinner = "triangle", commenced = "started", -- message shown when task starts completed = "done", -- message shown when task completes }, }, }, { "simrat39/rust-tools.nvim", event = "LspAttach", }, }