set background=dark syntax on filetype plugin indent on let mapleader=',' " netrw let g:netrw_banner = 0 let g:netrw_liststyle = 1 let g:netrw_list_hide = '^\.' let g:netrw_winsize=25 map n :Lexplore " fix helptags for opt/ plugins " https://vi.stackexchange.com/questions/17210/generating-help-tags-for-packages-that-are-loaded-by-vim-8s-package-management command! -nargs=0 -bar Helptags \ for p in glob('~/.vim/pack/git-plugins/opt/*', 1, 1) \| exe 'packadd ' . fnamemodify(p, ':t') \| endfor \| helptags ALL set shiftwidth=2 set shiftround set tabstop=2 set expandtab set smarttab set splitbelow set splitright set encoding=utf-8 set hidden set history=1000 set nowrap set smartindent set copyindent set autoindent set hlsearch set showmatch set wildmenu set wildmode=list:full,full set number set relativenumber set ruler set backspace=indent,eol,start set ignorecase set smartcase set incsearch set history=1000 set undolevels=1000 set title set novisualbell set noerrorbells set nobackup set noswapfile set ttymouse=sgr set mouse=a set mousemodel=popup_setpos set lazyredraw set timeoutlen=1000 set ballooneval set balloonevalterm set scrolloff=15 set dictionary=/usr/share/dict/words set shortmess+=I set updatetime=250 set pastetoggle= " See :help thesaurus set thesaurus=$HOME/Documents/thesaurus/thesaurus_pkg/thesaurus.txt set pumheight=200 set completeopt=menu,menuone,popup,noselect set completepopup=width:300,height:50,align:item,border:off " Enable 24-bit colours. " https://github.com/alacritty/alacritty/issues/109#issuecomment-440353106 if exists('+termguicolors') let &t_8f="\[38;2;%lu;%lu;%lum" let &t_8b="\[48;2;%lu;%lu;%lum" set termguicolors endif " Colour scheme: colorscheme nord augroup vimrc autocmd! " Automatically load/save views on files. " https://vi.stackexchange.com/posts/13874/revisions autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview! autocmd BufWinEnter ?* silent! loadview " set cursor line highlight in insert mode. autocmd InsertEnter * set cul autocmd InsertLeavePre * set nocul " use tabs in .gitconfig autocmd BufEnter .gitconfig setlocal shiftwidth=2 tabstop=2 noexpandtab " Quickfix window is always full-width. " https://github.com/fatih/vim-go/issues/1757#issuecomment-565130503 autocmd FileType qf if (getwininfo(win_getid())[0].loclist != 1) | wincmd J | endif augroup end " But, don't remember the current directory for a given file: set viewoptions-=curdir " Key mappings: nmap ,/ :nohlsearch nnoremap j gj nnoremap k gk map map map map imap imap imap imap nmap ]q :cn nmap [q :cp nnoremap ,/ :nohlsearch map :tabnew " Select just-pasted text: nnoremap 0 `[v`] nnoremap 1 :set relativenumber! nnoremap 2 :call SwitchBackground() map m :marks map R :ALERename map v :vsplit map s :split map ! :only " ctrl-c to unload a buffer nnoremap :bp\|bd # function! ToggleQuickFix() if empty(filter(getwininfo(), 'v:val.quickfix')) copen else cclose endif endfunction nmap q :call ToggleQuickFix() nmap l :lclose " deoplete configuration packadd! deoplete.nvim " Disable completion messages: set shortmess+=c let g:deoplete#enable_at_startup = 1 call deoplete#custom#option('num_processes', 6) call deoplete#custom#option('max_list', 250) call deoplete#custom#option('auto_complete_delay', 0) call deoplete#custom#option('auto_refresh_delay', 250) call deoplete#custom#option('refresh_always', v:false) call deoplete#custom#option('omni_patterns', { \ 'go': '[^. *\t]\.\w*', \}) " : completion. inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " vim-markdown configuration: let g:vim_markdown_conceal = 1 " fzf configuration: let g:fzf_action = { \ 'ctrl-t': 'tab split', \ 'ctrl-s': 'split', \ 'ctrl-v': 'vsplit' } nmap t :Files nmap T :GFiles nmap b :Buffers nmap gg :Rg " Lightline configuration: packadd! lightline.vim set laststatus=2 function! LightlineLSPErrorText() let l:info = lsp#get_buffer_diagnostics_counts() if info.error == 0 return '' endif let sign = get(g:lsp_diagnostics_signs_error, 'text', 'E') return info.error . sign endfunction function! LightlineLSPWarningText() let l:info = lsp#get_buffer_diagnostics_counts() if info.warning == 0 return '' endif let sign = get(g:lsp_diagnostics_signs_warning, 'text', 'W') return info.warning . sign endfunction let g:lightline = { \ 'colorscheme': 'seoul256', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], \ [ 'readonly', 'filename', 'modified' ], \ [ 'gitbranch' ], ['lsperror', 'lspwarn'] ], \ 'right': [ ['lineinfo'], ['percent'], ['filetype'], ['gobuild'] ], \ }, \ 'component_function': { \ 'gobuild': 'go#statusline#Show', \ 'gitbranch': 'FugitiveStatusline', \ }, \ 'component_expand': { \ 'lsperror': 'LightlineLSPErrorText', \ 'lspwarn': 'LightlineLSPWarningText', \ }, \ 'component_type': { \ 'lsperror': 'error', \ 'lspwarn': 'warning', \ }, \ 'mode_map': { \ 'n' : 'N', \ 'i' : 'I', \ 'R' : 'R', \ 'v' : 'V', \ 'V' : 'V-LINE', \ "\": 'V-BLOCK', \ 'c' : 'C', \ 's' : 'S', \ 'S' : 'S-LINE', \ "\": 'S-BLOCK', \ 't': 'TERM', \ }, \ } " vim-gitgutter configuration packadd! vim-gitgutter set signcolumn=yes nnoremap hg :GitGutterLineHighlightsToggle nmap ]h (GitGutterNextHunk) nmap [h (GitGutterPrevHunk) omap ih (GitGutterTextObjectInnerPending) omap ah (GitGutterTextObjectOuterPending) xmap ih (GitGutterTextObjectInnerVisual) xmap ah (GitGutterTextObjectOuterVisual) " Vim-Rust configuration: let g:rustfmt_autosave = 1 " echodoc configuration: set cmdheight=1 set noshowmode let g:echodoc#type='echo' let g:echodoc#enable_at_startup = 1 packadd! echodoc.vim " vim-fugitive " load before LSP to ensure it doesn't clobber signcolumn packadd! vim-fugitive " vim-go " load before LSP to ensure it doesn't clobber mappings packadd! vim-go " LSP configuration: packadd! vim-lsp packadd! vim-lsp-settings packadd! deoplete-vim-lsp let g:lsp_settings = { \ 'gopls': { \ 'initialization_options': { \ 'ui.diagnostic.analyses': { \ 'composites': v:false, \ 'unusedparams': v:true, \ 'unusedresult': v:true, \ 'shadow': v:true, \ }, \ 'staticcheck': v:true, \ }}} let g:lsp_diagnostics_float_cursor = 1 let g:lsp_diagnostics_float_delay = 200 let g:lsp_diagnostics_highlight_delay = 200 let g:lsp_diagnostics_signs_delay = 200 let g:lsp_diagnostics_code_action_signs_delay = 200 let g:lsp_document_highlight_delay = 500 function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete setlocal signcolumn=yes " number may be clobbered by vim-fugitive? setlocal number " Jump to definitions nmap gd (lsp-definition) nmap gvd :vertical :LspDefinition nmap gsd :belowright :LspDefinition nmap gD (lsp-type-definition) nmap gvD :vertical :LspTypeDefinition nmap gsD :belowright :LspTypeDefinition " Map to leader keys too, easy typo: nmap gd (lsp-definition) nmap gD (lsp-type-definition) " Peek definitions, only on leader keys nmap pd (lsp-peek-definition) nmap pD (lsp-peek-type-definition) " Navigation nmap ]e (lsp-next-error) nmap [e (lsp-previous-error) nmap ]d (lsp-next-diagnostic) nmap [d (lsp-previous-diagnostic) nmap ]r (lsp-next-reference) nmap [r (lsp-previous-reference) " Misc actions nmap ci (lsp-call-hierarchy-incoming) nmap co (lsp-call-hierarchy-outgoing) nmap a (lsp-code-action) nmap i (lsp-implementation) nmap r (lsp-references) nmap d (lsp-hover) nmap e (lsp-rename) endfunction augroup lsp_install au! autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() autocmd User lsp_diagnostics_updated call lightline#update() " autocmd BufWritePre silent LspDocumentFormatSync " autocmd CursorHold silent LspHover augroup END " load internal plugins: runtime macros/matchit.vim " load other plugins: packadd! tmux-complete.vim packadd! vim-commentary " Requires both fzf.vim plugin to be manually installed: " https://github.com/junegunn/fzf/blob/master/plugin/fzf.vim " and also this separate plugin, which is loaded here: packadd! fzf.vim packadd! vim-surround packadd! vim-yaml-folds