bindings.vim 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. let mapleader = " "
  2. " move text buffer in visual mode
  3. vnoremap K :m '<-2<CR>gv=gv
  4. vnoremap J :m '>+1<CR>gv=gv
  5. " write and quit easier
  6. nnoremap <Leader>w :w<CR>
  7. nnoremap <Leader>z :wq<CR>
  8. nnoremap <Leader>q :qa<CR>
  9. " windows commands
  10. nnoremap <leader>h :wincmd h<CR>
  11. nnoremap <leader>j wincmd j<CR>
  12. nnoremap <leader>k wincmd k<CR>
  13. nnoremap <leader>l wincmd l<CR>
  14. nnoremap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30<CR>
  15. nnoremap <leader>ps :Rg<CR>
  16. nnoremap <silent> <leader>+ :vertical resize +5<CR>
  17. nnoremap <silent> <leader>- :vertical resize -5<CR>
  18. " general custom commands
  19. command D filetype detect
  20. " commands for opening and compiling various document types
  21. command S silent !vshow '%:p'
  22. command C !compile "%"
  23. " general compile button
  24. map <F3> :w<CR>:!compile "%"; pkill -HUP mupdf<CR>
  25. " bibtex extra compiler
  26. map <F2> :w<CR>:!latexmk -pdf "%"; pkill -HUP mupdf<CR>
  27. map <F4> :noh<CR>
  28. map <F5> :set spell!<CR>
  29. map <F6> :w<CR>:!glosscompile "%"; pkill -HUP mupdf<CR>
  30. " jumper
  31. vnoremap <Space><Space> <Esc>/<++><Enter>"_c4l
  32. map <Space><Space> <Esc>/<++><Enter>"_c4l
  33. "copy from / to clipboard
  34. vnoremap <leader>y "+y
  35. vnoremap <leader>Y "+Y
  36. nmap <leader>p "+p
  37. nmap <leader>P "+P
  38. " Use <c-space> to trigger completion.
  39. inoremap <silent><expr> <c-space> coc#refresh()
  40. " Use `[g` and `]g` to navigate diagnostics
  41. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  42. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  43. " Remap keys for gotos
  44. nmap <silent> gd <Plug>(coc-definition)
  45. nmap <silent> gy <Plug>(coc-type-definition)
  46. nmap <silent> gi <Plug>(coc-implementation)
  47. nmap <silent> gr <Plug>(coc-references)
  48. nmap <leader>rn <Plug>(coc-rename)
  49. vmap <leader>f <Plug>(coc-format-selected)
  50. " switch (back and forth) to (and from) the last opened file
  51. nmap <leader>b <c-^><cr>
  52. nmap <leader>f <Plug>(coc-format-selected)
  53. noremap <silent> <Leader>f :Fern . -drawer -reveal=% -toggle -width=35<CR><C-w>=
  54. function! FernInit() abort
  55. nmap <buffer><expr>
  56. \ <Plug>(fern-my-open-expand-collapse)
  57. \ fern#smart#leaf(
  58. \ "\<Plug>(fern-action-open:select)",
  59. \ "\<Plug>(fern-action-expand:stay)",
  60. \ "\<Plug>(fern-action-collapse)",
  61. \ )
  62. nmap <buffer> <CR> <Plug>(fern-my-open-expand-collapse)
  63. nmap <buffer> <2-LeftMouse> <Plug>(fern-my-open-expand-collapse)
  64. nmap <buffer> n <Plug>(fern-action-new-path)
  65. nmap <buffer> d <Plug>(fern-action-remove)
  66. nmap <buffer> m <Plug>(fern-action-move)
  67. nmap <buffer> M <Plug>(fern-action-rename)
  68. nmap <buffer> c <Plug>(fern-action-hidden:toggle)
  69. nmap <buffer> r <Plug>(fern-action-reload)
  70. nmap <buffer> g <Plug>(fern-action-mark:toggle)
  71. nmap <buffer> o <Plug>(fern-action-open)
  72. nmap <buffer> b <Plug>(fern-action-open:split)
  73. nmap <buffer> v <Plug>(fern-action-open:vsplit)
  74. nmap <buffer> h <Plug>(fern-action-collapse)
  75. nmap <buffer> l <Plug>(fern-action-expand:stay)
  76. nmap <silent> <buffer> p <Plug>(fern-action-preview:toggle)
  77. nmap <silent> <buffer> <C-p> <Plug>(fern-action-preview:auto:toggle)
  78. nmap <silent> <buffer> <C-d> <Plug>(fern-action-preview:scroll:down:half)
  79. nmap <silent> <buffer> <C-u> <Plug>(fern-action-preview:scroll:up:half)
  80. nmap <buffer><nowait> < <Plug>(fern-action-leave)
  81. nmap <buffer><nowait> > <Plug>(fern-action-enter)
  82. endfunction
  83. " use TAB to autocomplete w/ coc
  84. inoremap <silent><expr> <TAB>
  85. \ pumvisible() ? "\<C-n>" :
  86. \ <SID>check_back_space() ? "\<TAB>" :
  87. \ coc#refresh()
  88. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  89. function! s:check_back_space() abort
  90. let col = col('.') - 1
  91. return !col || getline('.')[col - 1] =~# '\s'
  92. endfunction
  93. " Use `:Format` to format current buffer
  94. command! -nargs=0 Format :call CocAction('format')
  95. " Go to tab by number
  96. noremap <leader>1 1gt
  97. noremap <leader>2 2gt
  98. noremap <leader>3 3gt
  99. noremap <leader>4 4gt
  100. noremap <leader>5 5gt
  101. noremap <leader>6 6gt
  102. noremap <leader>7 7gt
  103. noremap <leader>8 8gt
  104. noremap <leader>9 9gt
  105. noremap <leader>0 :tablast<cr>
  106. " Applying codeAction to the selected region.
  107. " Example: `<leader>aap` for current paragraph
  108. xmap <leader>a <Plug>(coc-codeaction-selected)
  109. nmap <leader>a <Plug>(coc-codeaction-selected)
  110. " Remap keys for applying codeAction to the current buffer.
  111. nmap <leader>ac <Plug>(coc-codeaction)
  112. " Apply AutoFix to problem on the current line.
  113. nmap <leader>qf <Plug>(coc-fix-current)
  114. " Run the Code Lens action on the current line.
  115. nmap <leader>cl <Plug>(coc-codelens-action)
  116. " auto center view when walking through searches
  117. nnoremap n nzzzv
  118. nnoremap N Nzzzv
  119. " toggle tag bar
  120. nmap <leader>g :TagbarToggle<CR>
  121. " please write
  122. cmap w!! w !doas tee %
  123. " navigate chunks of current buffer
  124. nmap [h <Plug>(coc-git-prevchunk)
  125. nmap ]h <Plug>(coc-git-nextchunk)
  126. " navigate conflicts of current buffer
  127. nmap [c <Plug>(coc-git-prevconflict)
  128. nmap ]c <Plug>(coc-git-nextconflict)