local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") if not status_ok then return end local servers = { "bashls", "cssls", "clangd", "emmet_ls", "html", "jsonls", "pyright", "rust_analyzer", "sumneko_lua", "taplo", "texlab", "tsserver", "vimls", "yamlls", } lsp_installer.setup() local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") if not lspconfig_status_ok then return end local opts = {} for _, server in pairs(servers) do opts = { on_attach = require("user.lsp.handlers").on_attach, capabilities = require("user.lsp.handlers").capabilities, } if server == "sumneko_lua" then local sumneko_opts = require("user.lsp.settings.sumneko_lua") opts = vim.tbl_deep_extend("force", sumneko_opts, opts) end if server == "pyright" then local pyright_opts = require("user.lsp.settings.pyright") opts = vim.tbl_deep_extend("force", pyright_opts, opts) end if server == "rust_analyzer" then local keymap = vim.keymap.set local key_opts = { silent = true } keymap("n", "rh", "RustSetInlayHints", key_opts) keymap("n", "rhd", "RustDisableInlayHints", key_opts) keymap("n", "th", "RustToggleInlayHints", key_opts) keymap("n", "rr", "RustRunnables", key_opts) keymap("n", "rem", "RustExpandMacro", key_opts) keymap("n", "roc", "RustOpenCargo", key_opts) keymap("n", "rpm", "RustParentModule", key_opts) keymap("n", "rjl", "RustJoinLines", key_opts) keymap("n", "rha", "RustHoverActions", key_opts) keymap("n", "rhr", "RustHoverRange", key_opts) keymap("n", "rmd", "RustMoveItemDown", key_opts) keymap("n", "rmu", "RustMoveItemUp", key_opts) keymap("n", "rsb", "RustStartStandaloneServerForBuffer", key_opts) keymap("n", "rd", "RustDebuggables", key_opts) keymap("n", "rv", "RustViewCrateGraph", key_opts) keymap("n", "rw", "RustReloadWorkspace", key_opts) keymap("n", "rss", "RustSSR", key_opts) keymap("n", "rxd", "RustOpenExternalDocs", key_opts) require("rust-tools").setup({ tools = { on_initialized = function() vim.cmd([[ autocmd BufEnter,CursorHold,InsertLeave,BufWritePost *.rs silent! lua vim.lsp.codelens.refresh() ]]) end, }, server = { on_attach = require("user.lsp.handlers").on_attach, capabilities = require("user.lsp.handlers").capabilities, settings = { ["rust-analyzer"] = { lens = { enable = true, }, checkOnSave = { command = "clippy", }, }, }, }, }) goto continue end if server == "clangd" then require("clangd_extensions").setup({ server = { -- options to pass to nvim-lspconfig -- i.e. the arguments to require("lspconfig").clangd.setup({}) }, extensions = { -- defaults: -- Automatically set inlay hints (type hints) autoSetHints = true, -- These apply to the default ClangdSetInlayHints command inlay_hints = { -- Only show inlay hints for the current line only_current_line = false, -- Event which triggers a refersh of the inlay hints. -- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but -- not that this may cause higher CPU usage. -- This option is only respected when only_current_line and -- autoSetHints both are true. only_current_line_autocmd = "CursorHold", -- whether to show parameter hints with the inlay hints or not show_parameter_hints = true, -- prefix for parameter hints parameter_hints_prefix = "<- ", -- prefix for all the other hints (type, chaining) other_hints_prefix = "=> ", -- whether to align to the length of the longest line in the file max_len_align = false, -- padding from the left if max_len_align is true max_len_align_padding = 1, -- whether to align to the extreme right or not right_align = false, -- padding from the right if right_align is true right_align_padding = 7, -- The color of the hints highlight = "Comment", -- The highlight group priority for extmark priority = 100, }, ast = { -- These are unicode, should be available in any font role_icons = { type = "🄣", declaration = "🄓", expression = "🄔", statement = ";", specifier = "🄱", ["template argument"] = "🆃", }, kind_icons = { Compound = "đŸ„Č", Recovery = "🅁", TranslationUnit = "🅄", PackExpansion = "🄿", TemplateTypeParm = "🅃", TemplateTemplateParm = "🅃", TemplateParamObject = "🅃", }, -- These require codicons (https://github.com/microsoft/vscode-codicons) role_icons = { type = "î­Ł", declaration = "îȘŒ", expression = "", specifier = "", statement = "îȘ†", ["template argument"] = "îȘ’", }, kind_icons = { Compound = "îȘ‹", Recovery = "îȘ‡", TranslationUnit = "î«©", PackExpansion = "", TemplateTypeParm = "îȘ’", TemplateTemplateParm = "îȘ’", TemplateParamObject = "îȘ’", }, highlights = { detail = "Comment", }, }, memory_usage = { border = "none", }, symbol_info = { border = "none", }, }, }) goto continue end lspconfig[server].setup(opts) ::continue:: end