windows.vim 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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-j> :call VSCodeNotify('workbench.action.focusBelowGroup')<CR>
  38. xnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.focusBelowGroup')<CR>
  39. nnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.focusAboveGroup')<CR>
  40. xnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.focusAboveGroup')<CR>
  41. nnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.focusLeftGroup')<CR>
  42. xnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.focusLeftGroup')<CR>
  43. nnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.focusRightGroup')<CR>
  44. xnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.focusRightGroup')<CR>
  45. nnoremap <silent> <C-w>= :<C-u>call VSCodeNotify('workbench.action.evenEditorWidths')<CR>
  46. xnoremap <silent> <C-w>= :<C-u>call VSCodeNotify('workbench.action.evenEditorWidths')<CR>
  47. nnoremap <silent> <C-w>> :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  48. xnoremap <silent> <C-w>> :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  49. nnoremap <silent> <C-w>+ :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  50. xnoremap <silent> <C-w>+ :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  51. nnoremap <silent> <C-w>< :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  52. xnoremap <silent> <C-w>< :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  53. nnoremap <silent> <C-w>- :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  54. xnoremap <silent> <C-w>- :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  55. " Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors
  56. xnoremap <silent> <C-/> :call Comment()<CR>
  57. nnoremap <silent> <C-/> :call Comment()<CR>
  58. nnoremap <silent> <C-w>_ :<C-u>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>
  59. " nnoremap <silent> <Space> :call VSCodeCall('whichkey.show')
  60. " xnoremap <silent> <Space> :call VSCodeCall('whichkey.show')
  61. nnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR>
  62. xnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR>