local lsp_config = require("lspconfig") local saga = require("lspsaga") -- See: https://github.com/glepnir/lspsaga.nvim#configuration saga.init_lsp_saga({ border_style = "rounded", symbol_in_winbar = { enable = false }, code_action_lightbulb = { enable = false }, code_action_keys = { quit = "" }, definition_action_keys = { quit = "" }, rename_action_quit = "", }) -- 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 = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) ------------------------------------------------------------------------------- -- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md -- -- 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, }) -- nix lsp_config.nil_ls.setup({}) -- js,ts lsp_config.tsserver.setup({}) lsp_config.eslint.setup({}) -- rust lsp_config.rust_analyzer.setup({ -- Server-specific settings... settings = { ["rust-analyzer"] = { ["server.path"] = "rust-analyzer", ["updates.prompt"] = false, ["updates.checkOnStartup"] = false, ["checkOnSave.enable"] = true, ["checkOnSave.command"] = "clippy", ["cargo.autoreload"] = true, }, }, })