local lsp_installer = require("nvim-lsp-installer") -- Include the servers you want to have installed by default below local install_servers=function() local servers = { 'pyright', 'bashls', 'rust_analyzer', 'sumenko_lua', 'ltex', 'texlab', } local flag=false; for _, name in pairs(servers) do local server_is_found, server = lsp_installer.get_server(name) if server_is_found and not server:is_installed() then print("Installing " .. name) server:install() flag=true; end end if flag then print('All Servers Installed') end end lsp_installer.on_server_ready(function(server) local opts = {} if server.name == "rust_analyzer" then -- Initialize the LSP via rust-tools instead require("rust-tools").setup { -- The "server" property provided in rust-tools setup function are the -- settings rust-tools will provide to lspconfig during init. -- We merge the necessary settings from nvim-lsp-installer (server:get_default_options()) -- with the user's own settings (opts). server = vim.tbl_deep_extend("force", server:get_default_options(), opts), } server:attach_buffers() -- Only if standalone support is needed require("rust-tools").start_standalone_if_required() else server:setup(opts) end end) local on_attach = function() local function set_keymap(...) vim.api.nvim_set_keymap(...) end local function set_option(...) vim.api.nvim_set_option(...) end -- Enable completion triggered by set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. local opts = { noremap=true, silent=true } -- See `:help vim.lsp.*` for documentation on any of the below functions set_keymap('', ';lc', 'lua vim.lsp.buf.declaration()', opts) set_keymap('', ';lf', 'lua vim.lsp.buf.definition()', opts) set_keymap('', ';lh', 'lua vim.lsp.buf.hover()', opts) set_keymap('', ';li', 'lua vim.lsp.buf.implementation()', opts) set_keymap('', ';ls', 'lua vim.lsp.buf.signature_help()', opts) set_keymap('', ';lwa', 'lua vim.lsp.buf.add_workspace_folder()', opts) set_keymap('', ';lwr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) set_keymap('', ';lw', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) set_keymap('', ';lt', 'lua vim.lsp.buf.type_definition()', opts) set_keymap('', ';lr', 'lua vim.lsp.buf.rename()', opts) set_keymap('', ';la', 'lua vim.lsp.buf.code_action()', opts) set_keymap('', ';le', 'lua vim.lsp.buf.references()', opts) set_keymap('', ';lo', 'lua vim.diagnostic.open_float()', opts) set_keymap('', ';ln', 'lua vim.diagnostic.goto_prev()', opts) set_keymap('', ';lp', 'lua vim.diagnostic.goto_next()', opts) set_keymap('', ';lm', 'lua vim.lsp.buf.formatting()', opts) end on_attach() install_servers()