local lsp_config = require("lspconfig") local saga = require("lspsaga") local nlsp_settings = require("nlspsettings") -- See: https://github.com/glepnir/lspsaga.nvim#configuration saga.init_lsp_saga(@lspSagaSettings@) -- always show signcolumns vim.opt.signcolumn = "yes" -- Mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions local opts = { noremap = true, silent = true } vim.keymap.set("n", "e", vim.diagnostic.open_float, opts) vim.keymap.set("n", "[d", "Lspsaga diagnostic_jump_prev", opts) vim.keymap.set("n", "]d", "Lspsaga diagnostic_jump_next", opts) vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) -- Only jump to error vim.keymap.set("n", "[e", function() require("lspsaga.diagnostic").goto_prev({ severity = vim.diagnostic.severity.ERROR }) end, opts) vim.keymap.set("n", "]e", function() require("lspsaga.diagnostic").goto_next({ severity = vim.diagnostic.severity.ERROR }) end, opts) -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) -- Enable completion triggered by -- vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") -- Mappings. -- See `:help vim.lsp.*` for documentation on any of the below functions local bufopts = { noremap = true, silent = true, buffer = bufnr } vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) vim.keymap.set("n", "gy", vim.lsp.buf.type_definition, bufopts) vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts) vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts) -- vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) -- vim.keymap.set("n", "f", vim.lsp.buf.formatting, bufopts) vim.keymap.set("n", "n", "Lspsaga rename", bufopts) vim.keymap.set({ "n", "v" }, "a", "Lspsaga code_action", bufopts) vim.keymap.set("n", "K", "Lspsaga hover_doc", bufopts) vim.keymap.set("n", "co", "LSoutlineToggle", bufopts) end -- nvim-cmp local capabilities = require("cmp_nvim_lsp").default_capabilities() -- for local configurations nlsp_settings.setup({}) ------------------------------------------------------------------------------- -- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md -- vim.g.markdown_fenced_languages = { "ts=typescript" } -- Override the default configuration to be applied to all servers lsp_config.util.default_config = vim.tbl_extend("force", lsp_config.util.default_config, { on_attach = on_attach, capabilities = capabilities, }) local root_pattern = lsp_config.util.root_pattern for name, settings in pairs(@lspConfigServers@) do lsp_config[name].setup(settings) if name == "eslint" then vim.cmd([[ aug eslint_fix au! au BufWritePre *.tsx,*.ts,*.jsx,*.js silent! EslintFixAll aug END ]]) end end