let mapleader = " " " move text buffer in visual mode vnoremap K :m '<-2gv=gv vnoremap J :m '>+1gv=gv " write and quit easier nnoremap w :w nnoremap z :wq nnoremap q :qa nnoremap e :q " windows commands nnoremap pv :wincmd v :Ex :vertical resize 30 nnoremap ps :Rg nnoremap + :vertical resize +5 nnoremap - :vertical resize -5 " general custom commands command D filetype detect " commands for opening and compiling various document types command S silent !vshow '%:p' command C !compile "%" " general compile button map :w:!compile "%"; pkill -HUP mupdf " bibtex extra compiler map :w:!latexmk -pdf "%"; pkill -HUP mupdf map :noh map :set spell! map :w:!glosscompile "%"; pkill -HUP mupdf " jumper vnoremap /<++>"_c4l map /<++>"_c4l "copy from / to clipboard vnoremap y "+y vnoremap Y "+Y nmap p "+p nmap P "+P " Use to trigger completion. inoremap coc#refresh() " Use `[g` and `]g` to navigate diagnostics nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " Remap keys for gotos nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) nmap rn (coc-rename) vmap f (coc-format-selected) " switch (back and forth) to (and from) the last opened file nmap b nmap f (coc-format-selected) noremap f :Fern . -drawer -reveal=% -toggle -width=35= function! FernInit() abort nmap \ (fern-my-open-expand-collapse) \ fern#smart#leaf( \ "\(fern-action-open:select)", \ "\(fern-action-expand:stay)", \ "\(fern-action-collapse)", \ ) nmap (fern-my-open-expand-collapse) nmap <2-LeftMouse> (fern-my-open-expand-collapse) nmap n (fern-action-new-path) nmap d (fern-action-remove) nmap m (fern-action-move) nmap M (fern-action-rename) nmap c (fern-action-hidden:toggle) nmap r (fern-action-reload) nmap g (fern-action-mark:toggle) nmap o (fern-action-open) nmap b (fern-action-open:split) nmap v (fern-action-open:vsplit) nmap h (fern-action-collapse) nmap l (fern-action-expand:stay) nmap p (fern-action-preview:toggle) nmap (fern-action-preview:auto:toggle) nmap (fern-action-preview:scroll:down:half) nmap (fern-action-preview:scroll:up:half) nmap < (fern-action-leave) nmap > (fern-action-enter) endfunction " use TAB to autocomplete w/ coc inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use `:Format` to format current buffer command! -nargs=0 Format :call CocAction('format') " Go to tab by number noremap 1 1gt noremap 2 2gt noremap 3 3gt noremap 4 4gt noremap 5 5gt noremap 6 6gt noremap 7 7gt noremap 8 8gt noremap 9 9gt noremap 0 :tablast " Applying codeAction to the selected region. " Example: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap keys for applying codeAction to the current buffer. nmap ac (coc-codeaction) " Apply AutoFix to problem on the current line. nmap qf (coc-fix-current) " Run the Code Lens action on the current line. nmap cl (coc-codelens-action) " auto center view when walking through searches nnoremap n nzzzv nnoremap N Nzzzv " toggle tag bar nmap g :TagbarToggle " please write cmap w!! w !doas tee % " navigate chunks of current buffer nmap [h (coc-git-prevchunk) nmap ]h (coc-git-nextchunk) " navigate conflicts of current buffer nmap [c (coc-git-prevconflict) nmap ]c (coc-git-nextconflict) function! WinMove(key) let t:curwin = winnr() exec "wincmd ".a:key if (t:curwin == winnr()) if (match(a:key,'[jk]')) wincmd v else wincmd s endif exec "wincmd ".a:key endif endfunction " smart global buffor / window switching nnoremap :call WinMove('h') nnoremap :call WinMove('j') nnoremap :call WinMove('k') nnoremap :call WinMove('l') " source vim config nnoremap sv :source $XDG_CONFIG_HOME/nvim/init.vim nnoremap l :Telescope live_grep nnoremap t :Telescope find_files " markdown preview mappings nmap mg MarkdownPreview nmap ms MarkdownPreviewStop nmap mt MarkdownPreviewToggle " correct whitespace nnoremap cw :StripWhitespace " move to next / previous trailing whitespace nnoremap ]w :NextTrailingWhitespace nnoremap [w :PrevTrailingWhitespace " trigger snippet expand imap (coc-snippets-expand) " select text for visual placeholder of snippet vmap (coc-snippets-select) " jump to next placeholder let g:coc_snippet_next = '' " jump to previous placeholder let g:coc_snippet_prev = '' " for both expand and jump (make expand higher priority.) imap (coc-snippets-expand-jump)