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: packadd! gruvbox let g:gruvbox_contrast_dark='medium' let g:gruvbox_contrast_light='medium' let g:gruvbox_improved_strings=1 let g:gruvbox_improved_warnings=1 let g:gruvbox_vert_split='bg2' colorscheme gruvbox function! SwitchBackground() if &background == 'dark' set background=light let g:lightline.colorscheme = 'solarized' call lightline#init() call lightline#colorscheme() call lightline#update() else set background=dark let g:lightline.colorscheme = 'seoul256' call lightline#init() call lightline#colorscheme() call lightline#update() endif endfunction 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: nmap t :Files nmap T :GFiles nmap b :Buffers nmap gg :Rg " Lightline configuration: packadd! lightline.vim set laststatus=2 let g:lightline = { \ 'colorscheme': 'seoul256', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], \ [ 'readonly', 'filename', 'modified' ], \ [ 'gitbranch' ] ], \ 'right': [ ['lineinfo'], ['percent'], ['filetype'], ['gobuild'] ], \ }, \ 'component_function': { \ 'gobuild': 'go#statusline#Show', \ 'gitbranch': 'FugitiveHead', \ }, \ '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 " ALE configuration: nmap [L (ale_first) nmap ]L (ale_previous_wrap_error) nmap ]e (ale_next_wrap_error) nmap [w (ale_previous_wrap) nmap ]w (ale_next_wrap) nmap ad :ALEDetail map g :ALEGoToDefinition map f :ALEFindReferences map fv :ALEFindReferences -vsplit map fh :ALEFindReferences -split map ft :ALEFindReferences -tab nnoremap gD :ALEGoToTypeDefinition nnoremap gd :ALEGoToDefinition command GoToDefinition ALEGoToDefinition command GoToTypeDefinition ALEGoToTypeDefinition command FindReferences ALEFindReferences command Rename ALERename let g:ale_sign_column_always = 1 let g:ale_fix_on_save = 1 let g:ale_lint_on_text_changed = 1 let g:ale_lint_on_enter = 1 let g:ale_lint_on_insert_leave = 1 let g:ale_lint_on_save = 1 let g:ale_echo_cursor = 1 let g:ale_lint_delay = 100 let g:ale_lsp_suggestions = 1 let g:ale_set_balloons = 1 " NOTE: Needs https://github.com/dense-analysis/ale/issues/3350 let g:ale_rust_analyzer_config = { \ 'diagnostics': { 'disabled': ['unresolved-import'] }, \ 'cargo': { 'loadOutDirsFromCheck': v:true }, \ 'procMacro': { 'enable': v:true }, \ 'checkOnSave': { 'command': 'clippy', 'enable': v:true }, \ } let g:ale_go_goimports_options = '-local github.com/sensiblecodeio/cantabular' let g:ale_go_gopls_init_options = {'ui.diagnostic.analyses': { \ 'composites': v:false, \ 'unusedparams': v:true, \ 'unusedresult': v:true, \ 'shadow': v:true, \ }} " let g:ale_command_wrapper = 'nice -n5' let g:ale_completion_enabled = 0 let g:ale_close_preview_on_insert = 1 let g:ale_hover_to_preview = 1 let g:ale_history_log_output = 0 let g:ale_linters = { \ 'javascript': ['eslint'], \ 'go': ['gopls'], \ 'rust': ['analyzer'], \ 'css': ['stylelint'], \ 'python': ['pyls'], \ 'ruby': ['rubocop'], \ } let g:ale_fixers = { \ '*': ['remove_trailing_lines', 'trim_whitespace'], \ 'javascript': ['prettier'], \ 'rust': [], \ 'go': [], \ 'css': ['stylelint'], \ 'python': ['autopep8'], \ 'ruby': ['rubocop'], \ } " load internal plugins: runtime macros/matchit.vim " load ALE only after configured: packadd! ale " 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-go packadd! vim-surround packadd! vim-yaml-folds packadd! vim-fugitive