return { "neovim/nvim-lspconfig", event = { "BufReadPre", "BufNewFile" }, dependencies = { "hrsh7th/cmp-nvim-lsp", "onsails/lspkind.nvim", { "folke/neodev.nvim", opts = {} }, }, config = function() local lspconfig = require("lspconfig") local mason_lspconfig = require("mason-lspconfig") local cmp_nvim_lsp = require("cmp_nvim_lsp") local wk = require("which-key") local capabilities = cmp_nvim_lsp.default_capabilities() mason_lspconfig.setup({ function(server_name) lspconfig[server_name].setup({ capabilities = capabilities, }) end, }) vim.lsp.config("lua_ls", { capabilities = capabilities, settings = { -- custom settings for lua Lua = { -- make the language server recognize "vim" global diagnostics = { globals = { "vim" }, }, workspace = { -- make language server aware of runtime files library = { [vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.stdpath("config") .. "/lua"] = true, }, }, }, }, }) vim.lsp.config("pyright", { capabilities = capabilities, filetypes = { "python" }, settings = { python = { pythonPath = vim.fn.exepath("python3.12"), }, }, }) vim.lsp.config("ltex", { settings = { ltex = { language = "de-CH", checkFrequency = "save", }, }, }) vim.diagnostic.config({ virtual_text = true, signs = true, }) wk.add({ { "l", group = "lsp", icon = "" }, { "lr", "Telescope lsp_references", desc = "Show references", icon = "" }, { "lD", "lua vim.lsp.buf.defenition()", desc = "Show defenition", icon = "" }, { "lc", "lua vim.lsp.buf.code_action()", desc = "Code actions", icon = "" }, { "lR", "lua vim.lsp.buf.rename()", desc = "Smart rename", icon = "󰑕" }, { "ld", "Telescope diagnostics bufnr=0", desc = "Diagnostics", icon = "󰍉" }, { "ll", "lua vim.lsp.buf.open_float()", desc = "Line Diagnostics", icon = "󰍉" }, { "ln", "lua vim.diagnostics.goto_next()", desc = "Go to next Diagnostic", icon = "" }, { "lp", "lua vim.diagnostics.goto_prev()", desc = "Go to previous Diagnostic", icon = "", }, { "li", "lua vim.lsp.buf.hover()", desc = "Show documentation", icon = "󰈙" }, { "lL", "LspRestart", desc = "Restart LSP", icon = "" }, }) end, }