settings.vim 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. " TODO there is a more contemporary version of this file
  2. "VSCode
  3. function! s:split(...) abort
  4. let direction = a:1
  5. let file = a:2
  6. call VSCodeCall(direction == 'h' ? 'workbench.action.splitEditorDown' : 'workbench.action.splitEditorRight')
  7. if file != ''
  8. call VSCodeExtensionNotify('open-file', expand(file), 'all')
  9. endif
  10. endfunction
  11. function! s:splitNew(...)
  12. let file = a:2
  13. call s:split(a:1, file == '' ? '__vscode_new__' : file)
  14. endfunction
  15. function! s:closeOtherEditors()
  16. call VSCodeNotify('workbench.action.closeEditorsInOtherGroups')
  17. call VSCodeNotify('workbench.action.closeOtherEditors')
  18. endfunction
  19. function! s:manageEditorSize(...)
  20. let count = a:1
  21. let to = a:2
  22. for i in range(1, count ? count : 1)
  23. call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize')
  24. endfor
  25. endfunction
  26. command! -complete=file -nargs=? Split call <SID>split('h', <q-args>)
  27. command! -complete=file -nargs=? Vsplit call <SID>split('v', <q-args>)
  28. command! -complete=file -nargs=? New call <SID>split('h', '__vscode_new__')
  29. command! -complete=file -nargs=? Vnew call <SID>split('v', '__vscode_new__')
  30. command! -bang Only if <q-bang> == '!' | call <SID>closeOtherEditors() | else | call VSCodeNotify('workbench.action.joinAllGroups') | endif
  31. nnoremap <silent> <C-w>s :call <SID>split('h')<CR>
  32. xnoremap <silent> <C-w>s :call <SID>split('h')<CR>
  33. nnoremap <silent> <C-w>v :call <SID>split('v')<CR>
  34. xnoremap <silent> <C-w>v :call <SID>split('v')<CR>
  35. nnoremap <silent> <C-w>n :call <SID>splitNew('h', '__vscode_new__')<CR>
  36. xnoremap <silent> <C-w>n :call <SID>splitNew('h', '__vscode_new__')<CR>
  37. nnoremap <silent> <C-w>= :<C-u>call VSCodeNotify('workbench.action.evenEditorWidths')<CR>
  38. xnoremap <silent> <C-w>= :<C-u>call VSCodeNotify('workbench.action.evenEditorWidths')<CR>
  39. nnoremap <silent> <C-w>> :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  40. xnoremap <silent> <C-w>> :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  41. nnoremap <silent> <C-w>+ :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  42. xnoremap <silent> <C-w>+ :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  43. nnoremap <silent> <C-w>< :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  44. xnoremap <silent> <C-w>< :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  45. nnoremap <silent> <C-w>- :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  46. xnoremap <silent> <C-w>- :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  47. " Better Navigation
  48. nnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.navigateDown')<CR>
  49. xnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.navigateDown')<CR>
  50. nnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.navigateUp')<CR>
  51. xnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.navigateUp')<CR>
  52. nnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.navigateLeft')<CR>
  53. xnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.navigateLeft')<CR>
  54. nnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>
  55. xnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>
  56. " Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors
  57. xnoremap <silent> <C-/> :call Comment()<CR>
  58. nnoremap <silent> <C-/> :call Comment()<CR>
  59. nnoremap <silent> <C-w>_ :<C-u>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>
  60. nnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR>
  61. xnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR>