call plug#begin('~/.vim/plugged') " Collection of common configurations for the Nvim LSP client Plug 'neovim/nvim-lspconfig' " Extensions to built-in LSP, for example, providing type inlay hints Plug 'tjdevries/lsp_extensions.nvim' " Autocompletion framework for built-in LSP Plug 'nvim-lua/completion-nvim' " Diagnostic navigation and settings for built-in LSP Plug 'nvim-lua/diagnostic-nvim' Plug 'dense-analysis/ale' Plug 'preservim/nerdtree' Plug 'rust-lang/rust.vim' Plug 'mattn/webapi-vim' Plug 'vim-scripts/indentpython.vim' Plug 'nvie/vim-flake8' Plug 'tpope/vim-fugitive' Plug 'vim-airline/vim-airline' Plug 'itspriddle/vim-shellcheck' Plug 'vim-airline/vim-airline-themes' call plug#end() syntax enable filetype plugin indent on " 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 set background=dark encoding=utf-8 number nomodeline hidden wrap linebreak :colorscheme desert let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#formatter = 'unique_tail' let g:airline_theme='jellybeans' " let g:syntastic_python_checkers = ['flake8'] " Configuration for splits and split navigation set splitbelow set splitright " Uppercase the current word in insert mode and move to the " word end inoremap viwUei " Uppercase the current word in normal mode and move to the " word end nnoremap viwUe " General indent rules for files augroup indentrules autocmd BufNewFile,BufRead *.js,*.html,*.md,*.css,*.yaml,*.uml setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab fileformat=unix autocmd Filetype text setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab autocmd Filetype sql setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab autocmd Filetype c setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab autocmd Filetype cpp setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab augroup END " Group for nerdtree augroup nerdtree autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif augroup END " Configure LSP " https://github.com/neovim/nvim-lspconfig#rust_analyzer lua < inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ completion#trigger_completion() function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~ '\s' endfunction " Code navigation shortcuts nnoremap 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.declaration() " Visualize diagnostics let g:diagnostic_enable_virtual_text = 1 let g:diagnostic_trimmed_virtual_text = '40' " Don't show diagnostics while in insert mode let g:diagnostic_insert_delay = 1 " Set updatetime for CursorHold " 300ms of no cursor movement to trigger CursorHold set updatetime=300 " Show diagnostic popup on cursor hold autocmd CursorHold * lua vim.lsp.util.show_line_diagnostics() " Goto previous/next diagnostic warning/error nnoremap g[ PrevDiagnosticCycle nnoremap g] NextDiagnosticCycle " have a fixed column for the diagnostics to appear in " this removes the jitter when warnings/errors flow in set signcolumn=yes " Enable type inlay hints autocmd CursorMoved,InsertLeave,BufEnter,BufWinEnter,TabEnter,BufWritePost * \ lua require'lsp_extensions'.inlay_hints{ prefix = '', highlight = "Comment" } " This all came from https://sharksforarms.dev/posts/neovim-rust/