" This is an example on how rust-analyzer can be configure using rust-tools " Prerequisites: " - neovim >= 0.5 " - rust-analyzer: https://rust-analyzer.github.io/manual.html#rust-analyzer-language-server-binary " Steps: " - :PlugInstall " - Restart call plug#begin('~/.vim/plugged') " Collection of common configurations for the Nvim LSP client Plug 'neovim/nvim-lspconfig' Plug 'tami5/lspsaga.nvim' Plug 'williamboman/nvim-lsp-installer' " Autocompletion framework Plug 'hrsh7th/nvim-cmp' " cmp LSP completion Plug 'hrsh7th/cmp-nvim-lsp' " cmp Snippet completion Plug 'hrsh7th/cmp-vsnip' " cmp Path completion Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-buffer' " See hrsh7th other plugins for more great completion sources! " Adds extra functionality over rust analyzer Plug 'simrat39/rust-tools.nvim' Plug 'simrat39/symbols-outline.nvim' " Snippet engine Plug 'hrsh7th/vim-vsnip' " Optional Plug 'nvim-lua/popup.nvim' Plug 'nvim-lua/plenary.nvim' Plug 'nvim-telescope/telescope.nvim' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'nvim-lua/lsp-status.nvim' Plug 'ojroques/nvim-hardline' Plug 'j-hui/fidget.nvim' Plug 'lewis6991/gitsigns.nvim' Plug 'tpope/vim-surround' Plug 'folke/trouble.nvim' " If you want to display icons, then use one of these plugins: Plug 'kyazdani42/nvim-web-devicons' " lua " Some color scheme other then default Plug 'iCyMind/NeoSolarized' call plug#end() set termguicolors set background=light colorscheme NeoSolarized " Set completeopt to have a better completion experience " :help completeopt " menuone: popup even when there's only one match " noinsert: Do not insert text until a selection is made " noselect: Do not select, force user to select one from the menu set completeopt=menuone,noinsert,noselect " Avoid showing extra messages when using completion set shortmess+=c " Configure LSP through rust-tools.nvim plugin. " rust-tools will configure and enable certain LSP features for us. " See https://github.com/simrat39/rust-tools.nvim#configuration lua < lua vim.lsp.buf.definition() "nnoremap K lua vim.lsp.buf.hover() "nnoremap gD lua vim.lsp.buf.implementation() "nnoremap lua vim.lsp.buf.signature_help() "nnoremap 1gD lua vim.lsp.buf.type_definition() "nnoremap gr lua vim.lsp.buf.references() "nnoremap g0 lua vim.lsp.buf.document_symbol() "nnoremap gW lua vim.lsp.buf.workspace_symbol() nnoremap gd lua vim.lsp.buf.definition() "nnoremap n lua vim.lsp.buf.rename() " Quick-fix nnoremap ga lua vim.lsp.buf.code_action() nnoremap ff lua vim.lsp.buf.formatting() " Setup Completion " See https://github.com/hrsh7th/nvim-cmp#basic-configuration lua <'] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), -- Add tab support [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.close(), [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true, }) }, -- Installed sources sources = { { name = 'nvim_lsp' }, { name = 'vsnip' }, { name = 'path' }, { name = 'buffer' }, }, }) EOF " have a fixed column for the diagnostics to appear in " this removes the jitter when warnings/errors flow in set signcolumn=yes " Set updatetime for CursorHold " 300ms of no cursor movement to trigger CursorHold set updatetime=300 " Show diagnostic popup on cursor hover (Disabled because it's the same as " cd cc from lspsaga, we should choose between the two " autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) " Goto previous/next diagnostic warning/error nnoremap g[ lua vim.diagnostic.goto_prev() nnoremap g] lua vim.diagnostic.goto_next() nnoremap ff lua require('telescope.builtin').find_files() nnoremap fg lua require('telescope.builtin').live_grep() nnoremap fb lua require('telescope.builtin').buffers() nnoremap fh lua require('telescope.builtin').help_tags() lua require('gitsigns').setup() set statusline+=%{get(b:,'gitsigns_status','')} lua require('hardline').setup {} lua <gh lua require'lspsaga.provider'.lsp_finder() nnoremap ca lua require('lspsaga.codeaction').code_action() vnoremap ca :lua require('lspsaga.codeaction').range_code_action() nnoremap K lua require('lspsaga.hover').render_hover_doc() nnoremap gs lua require('lspsaga.signaturehelp').signature_help() nnoremap gr lua require('lspsaga.rename').rename() "nnoremap gd lua require'lspsaga.provider'.preview_definition() nnoremap cd lua require'lspsaga.diagnostic'.show_line_diagnostics() nnoremap cc lua require'lspsaga.diagnostic'.show_cursor_diagnostics() nnoremap [e lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_prev() nnoremap ]e lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_next() lua <", "q"}, goto_location = "", focus_location = "o", hover_symbol = "", toggle_preview = "K", rename_symbol = "r", code_actions = "a", }, lsp_blacklist = {}, symbol_blacklist = {}, symbols = { File = {icon = "", hl = "TSURI"}, Module = {icon = "", hl = "TSNamespace"}, Namespace = {icon = "", hl = "TSNamespace"}, Package = {icon = "", hl = "TSNamespace"}, Class = {icon = "𝓒", hl = "TSType"}, Method = {icon = "ƒ", hl = "TSMethod"}, Property = {icon = "", hl = "TSMethod"}, Field = {icon = "", hl = "TSField"}, Constructor = {icon = "", hl = "TSConstructor"}, Enum = {icon = "ℰ", hl = "TSType"}, Interface = {icon = "ﰮ", hl = "TSType"}, Function = {icon = "", hl = "TSFunction"}, Variable = {icon = "", hl = "TSConstant"}, Constant = {icon = "", hl = "TSConstant"}, String = {icon = "𝓐", hl = "TSString"}, Number = {icon = "#", hl = "TSNumber"}, Boolean = {icon = "⊨", hl = "TSBoolean"}, Array = {icon = "", hl = "TSConstant"}, Object = {icon = "⦿", hl = "TSType"}, Key = {icon = "🔐", hl = "TSType"}, Null = {icon = "NULL", hl = "TSType"}, EnumMember = {icon = "", hl = "TSField"}, Struct = {icon = "𝓢", hl = "TSType"}, Event = {icon = "🗲", hl = "TSType"}, Operator = {icon = "+", hl = "TSOperator"}, TypeParameter = {icon = "𝙏", hl = "TSParameter"} } } EOF lua require"fidget".setup{}