123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- let mapleader = " "
- " move text buffer in visual mode
- vnoremap K :m '<-2<CR>gv=gv
- vnoremap J :m '>+1<CR>gv=gv
- " write and quit easier
- nnoremap <Leader>w :w<CR>
- nnoremap <Leader>z :wq<CR>
- nnoremap <Leader>q :qa<CR>
- nnoremap <Leader>e :q<CR>
- " windows commands
- nnoremap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30<CR>
- nnoremap <leader>ps :Rg<CR>
- nnoremap <leader>rh :vertical resize +5<CR>
- nnoremap <leader>rl :vertical resize -5<CR>
- " 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 <F3> :w<CR>:!compile "%" && pkill -HUP mupdf<CR>
- " bibtex extra compiler
- map <F2> :w<CR>:!latexmk -pdf "%" && pkill -HUP mupdf<CR>
- map <F4> :noh<CR>
- map <F5> :set spell!<CR>
- map <F6> :w<CR>:!glosscompile "%" && pkill -HUP mupdf<CR>
- " jumper
- vnoremap <Space><Space> <Esc>/<++><Enter>"_c4l
- map <Space><Space> <Esc>/<++><Enter>"_c4l
- "copy from / to clipboard
- vnoremap <leader>y "+y
- vnoremap <leader>Y "+Y
- nmap <leader>p "+p
- nmap <leader>P "+P
- " Use <c-space> to trigger completion.
- inoremap <silent><expr> <c-space> coc#refresh()
- " Use `[g` and `]g` to navigate diagnostics
- nmap <silent> [g <Plug>(coc-diagnostic-prev)
- nmap <silent> ]g <Plug>(coc-diagnostic-next)
- " Remap keys for gotos
- nmap <silent> gd <Plug>(coc-definition)
- nmap <silent> gy <Plug>(coc-type-definition)
- nmap <silent> gi <Plug>(coc-implementation)
- nmap <silent> gr <Plug>(coc-references)
- nmap <leader>rn <Plug>(coc-rename)
- vmap <leader>f <Plug>(coc-format-selected)
- " switch (back and forth) to (and from) the last opened file
- nmap <leader>b <c-^><cr>
- nmap <leader>f <Plug>(coc-format-selected)
- noremap <silent> <Leader>f :Fern . -drawer -reveal=% -toggle -width=35<CR><C-w>=
- function! FernInit() abort
- nmap <buffer><expr>
- \ <Plug>(fern-my-open-expand-collapse)
- \ fern#smart#leaf(
- \ "\<Plug>(fern-action-open:select)",
- \ "\<Plug>(fern-action-expand:stay)",
- \ "\<Plug>(fern-action-collapse)",
- \ )
- nmap <buffer> <CR> <Plug>(fern-my-open-expand-collapse)
- nmap <buffer> <2-LeftMouse> <Plug>(fern-my-open-expand-collapse)
- nmap <buffer> n <Plug>(fern-action-new-path)
- nmap <buffer> d <Plug>(fern-action-remove)
- nmap <buffer> m <Plug>(fern-action-move)
- nmap <buffer> M <Plug>(fern-action-rename)
- nmap <buffer> c <Plug>(fern-action-hidden:toggle)
- nmap <buffer> r <Plug>(fern-action-reload)
- nmap <buffer> g <Plug>(fern-action-mark:toggle)
- nmap <buffer> o <Plug>(fern-action-open)
- nmap <buffer> b <Plug>(fern-action-open:split)
- nmap <buffer> v <Plug>(fern-action-open:vsplit)
- nmap <buffer> h <Plug>(fern-action-collapse)
- nmap <buffer> l <Plug>(fern-action-expand:stay)
- nmap <silent> <buffer> p <Plug>(fern-action-preview:toggle)
- nmap <silent> <buffer> <C-p> <Plug>(fern-action-preview:auto:toggle)
- nmap <silent> <buffer> <C-d> <Plug>(fern-action-preview:scroll:down:half)
- nmap <silent> <buffer> <C-u> <Plug>(fern-action-preview:scroll:up:half)
- nmap <buffer><nowait> < <Plug>(fern-action-leave)
- nmap <buffer><nowait> > <Plug>(fern-action-enter)
- endfunction
- " use (shift-)TAB to autocomplete w/ coc
- inoremap <expr> <Tab> coc#pum#visible() ? coc#pum#next(1) : "\<Tab>"
- inoremap <expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(1) : "\<S-Tab>"
- " use Ctrl + Space to trigger autocomplete box
- inoremap <silent><expr> <c-space> coc#refresh()
- " Use `:Format` to format current buffer
- command! -nargs=0 Format :call CocAction('format')
- " Go to tab by number
- noremap <leader>1 1gt
- noremap <leader>2 2gt
- noremap <leader>3 3gt
- noremap <leader>4 4gt
- noremap <leader>5 5gt
- noremap <leader>6 6gt
- noremap <leader>7 7gt
- noremap <leader>8 8gt
- noremap <leader>9 9gt
- noremap <leader>0 :tablast<cr>
- " Applying codeAction to the selected region.
- " Example: `<leader>aap` for current paragraph
- xmap <leader>a <Plug>(coc-codeaction-selected)
- nmap <leader>a <Plug>(coc-codeaction-selected)
- " Remap keys for applying codeAction to the current buffer.
- nmap <leader>ac <Plug>(coc-codeaction)
- " Apply AutoFix to problem on the current line.
- nmap <leader>qf <Plug>(coc-fix-current)
- " Run the Code Lens action on the current line.
- nmap <leader>cl <Plug>(coc-codelens-action)
- " auto center view when walking through searches
- nnoremap n nzzzv
- nnoremap N Nzzzv
- " toggle tag bar
- nmap <leader>g :TagbarToggle<CR>
- " please write
- cmap w!! w !doas tee %
- " navigate chunks of current buffer
- nmap [h <Plug>(coc-git-prevchunk)
- nmap ]h <Plug>(coc-git-nextchunk)
- " navigate conflicts of current buffer
- nmap [c <Plug>(coc-git-prevconflict)
- nmap ]c <Plug>(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 <silent> <C-h> :call WinMove('h')<CR>
- nnoremap <silent> <C-j> :call WinMove('j')<CR>
- nnoremap <silent> <C-k> :call WinMove('k')<CR>
- nnoremap <silent> <C-l> :call WinMove('l')<CR>
- " source vim config
- nnoremap <Leader>sv :source $XDG_CONFIG_HOME/nvim/init.vim<CR>
- nnoremap <leader>l :Telescope live_grep<CR>
- nnoremap <leader>t :Telescope git_files<CR>
- nnoremap <leader>z :Telescope find_files<CR>
- nnoremap <C-s> :Telescope grep_string<CR>
- " markdown preview mappings
- nmap <leader>mg <Plug>MarkdownPreview
- nmap <leader>ms <Plug>MarkdownPreviewStop
- nmap <leader>mt <Plug>MarkdownPreviewToggle
- " correct whitespace
- nnoremap <leader>cw :StripWhitespace<CR>
- " move to next / previous trailing whitespace
- nnoremap ]w :NextTrailingWhitespace<CR>
- nnoremap [w :PrevTrailingWhitespace<CR>
- " trigger snippet expand
- imap <C-l> <Plug>(coc-snippets-expand)
- " select text for visual placeholder of snippet
- vmap <C-j> <Plug>(coc-snippets-select)
- " jump to next placeholder
- let g:coc_snippet_next = '<c-n>'
- " jump to previous placeholder
- let g:coc_snippet_prev = '<c-b>'
- " for both expand and jump (make expand higher priority.)
- imap <C-j> <Plug>(coc-snippets-expand-jump)
- nnoremap <leader>da :call vimspector#Launch()<CR>
- nnoremap <leader>dc :call GotoWindow(g:vimspector_session_windows.code)<CR>
- nnoremap <leader>dv :call GotoWindow(g:vimspector_session_windows.variables)<CR>
- nnoremap <leader>dw :call GotoWindow(g:vimspector_session_windows.watches)<CR>
- nnoremap <leader>ds :call GotoWindow(g:vimspector_session_windows.stack_trace)<CR>
- nnoremap <leader>do :call GotoWindow(g:vimspector_session_windows.output)<CR>
- nnoremap <leader>di :call AddToWatch()<CR>
- nnoremap <leader>dx :call vimspector#Reset()<CR>
- nnoremap <leader>dX :call vimspector#ClearBreakpoints()<CR>
- nnoremap <S-k> :call vimspector#StepOut()<CR>
- nnoremap <S-l> :call vimspector#StepInto()<CR>
- nnoremap <S-j> :call vimspector#StepOver()<CR>
- nnoremap <leader>d_ :call vimspector#Restart()<CR>
- nnoremap <leader>dn :call vimspector#Continue()<CR>
- nnoremap <leader>drc :call vimspector#RunToCursor()<CR>
- nnoremap <leader>dh :call vimspector#ToggleBreakpoint()<CR>
- nnoremap <leader>de :call vimspector#ToggleConditionalBreakpoint()<CR>
|