local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities() local default_setup = function(server) require("lspconfig")[server].setup({ capabilities = lsp_capabilities, }) end -- enable mason and configure icons require("mason").setup({ ui = { icons = { package_installed = "✓", package_pending = "➜", package_uninstalled = "✗", }, }, }) require("mason-lspconfig").setup({ ensure_installed = { -- "tsserver", "cssls", "html", "bashls", "eslint", "ltex", --"marksman", --"lua_ls" has to be installed via package manager on ARM systems }, handlers = { default_setup, }, }) local on_attach = function() vim.api.nvim_create_autocmd("LspAttach", { desc = "LSP actions", callback = function() local bufmap = function(mode, lhs, rhs) local opts = { buffer = true } vim.keymap.set(mode, lhs, rhs, opts) end -- Displays hover information about the symbol under the cursor bufmap("n", "K", "lua vim.lsp.buf.hover()") -- Jump to the definition bufmap("n", "gd", "lua vim.lsp.buf.definition()") -- Jump to declaration bufmap("n", "gD", "lua vim.lsp.buf.declaration()") -- Lists all the implementations for the symbol under the cursor bufmap("n", "gi", "lua vim.lsp.buf.implementation()") -- Jumps to the definition of the type symbol bufmap("n", "go", "lua vim.lsp.buf.type_definition()") -- Lists all the references bufmap("n", "gr", "lua vim.lsp.buf.references()") -- Displays a function's signature information bufmap("n", "gs", "lua vim.lsp.buf.signature_help()") -- Renames all references to the symbol under the cursor bufmap("n", "", "lua vim.lsp.buf.rename()") -- Selects a code action available at the current cursor position bufmap("n", "", "lua vim.lsp.buf.code_action()") -- Show diagnostics in a floating window bufmap("n", "gl", "lua vim.diagnostic.open_float()") -- Move to the previous diagnostic bufmap("n", "nd", "lua vim.diagnostic.goto_prev()") -- Move to the next diagnostic bufmap("n", "nd", "lua vim.diagnostic.goto_next()") end, }) end local lspconfig = require("lspconfig") require("mason-lspconfig").setup_handlers({ -- The first entry (without a key) will be the default handler -- and will be called for each installed server that doesn't have -- a dedicated handler. function(server_name) require("lspconfig")[server_name].setup({ on_attach = on_attach, capabilities = lsp_capabilities, }) end, -- ["eslint"] = function() -- lspconfig.eslint.setup({ -- capabilities = lsp_capabilities, -- on_attach = require("config.lsp.servers.eslint").on_attach, -- settings = require("config.lsp.servers.eslint").settings, -- }) -- end, ["lua_ls"] = function() lspconfig.lua_ls.setup({ capabilities = lsp_capabilities, on_attach = on_attach, settings = require("config.lsp.servers.lua").settings, }) end, ["ltex"] = function() lspconfig.ltex.setup({ capabilities = lsp_capabilities, on_attach = on_attach, settings = require("config.lsp.servers.latex").settings, }) end, })