windows.vim 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "VSCode
  2. function! s:split(...) abort
  3. let direction = a:1
  4. let file = a:2
  5. call VSCodeCall(direction == 'h' ? 'workbench.action.splitEditorDown' : 'workbench.action.splitEditorRight')
  6. if file != ''
  7. call VSCodeExtensionNotify('open-file', expand(file), 'all')
  8. endif
  9. endfunction
  10. function! s:splitNew(...)
  11. let file = a:2
  12. call s:split(a:1, file == '' ? '__vscode_new__' : file)
  13. endfunction
  14. function! s:closeOtherEditors()
  15. call VSCodeNotify('workbench.action.closeEditorsInOtherGroups')
  16. call VSCodeNotify('workbench.action.closeOtherEditors')
  17. endfunction
  18. function! s:manageEditorSize(...)
  19. let count = a:1
  20. let to = a:2
  21. for i in range(1, count ? count : 1)
  22. call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize')
  23. endfor
  24. endfunction
  25. command! -complete=file -nargs=? Split call <SID>split('h', <q-args>)
  26. command! -complete=file -nargs=? Vsplit call <SID>split('v', <q-args>)
  27. command! -complete=file -nargs=? New call <SID>split('h', '__vscode_new__')
  28. command! -complete=file -nargs=? Vnew call <SID>split('v', '__vscode_new__')
  29. command! -bang Only if <q-bang> == '!' | call <SID>closeOtherEditors() | else | call VSCodeNotify('workbench.action.joinAllGroups') | endif
  30. nnoremap <silent> <C-w>s :call <SID>split('h')<CR>
  31. xnoremap <silent> <C-w>s :call <SID>split('h')<CR>
  32. nnoremap <silent> <C-w>v :call <SID>split('v')<CR>
  33. xnoremap <silent> <C-w>v :call <SID>split('v')<CR>
  34. nnoremap <silent> <C-w>n :call <SID>splitNew('h', '__vscode_new__')<CR>
  35. xnoremap <silent> <C-w>n :call <SID>splitNew('h', '__vscode_new__')<CR>
  36. nnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.focusBelowGroup')<CR>
  37. xnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.focusBelowGroup')<CR>
  38. nnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.focusAboveGroup')<CR>
  39. xnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.focusAboveGroup')<CR>
  40. nnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.focusLeftGroup')<CR>
  41. xnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.focusLeftGroup')<CR>
  42. nnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.focusRightGroup')<CR>
  43. xnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.focusRightGroup')<CR>
  44. nnoremap <silent> <C-w>= :<C-u>call VSCodeNotify('workbench.action.evenEditorWidths')<CR>
  45. xnoremap <silent> <C-w>= :<C-u>call VSCodeNotify('workbench.action.evenEditorWidths')<CR>
  46. nnoremap <silent> <C-w>> :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  47. xnoremap <silent> <C-w>> :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  48. nnoremap <silent> <C-w>+ :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  49. xnoremap <silent> <C-w>+ :<C-u>call <SID>manageEditorSize(v:count, 'increase')<CR>
  50. nnoremap <silent> <C-w>< :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  51. xnoremap <silent> <C-w>< :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  52. nnoremap <silent> <C-w>- :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  53. xnoremap <silent> <C-w>- :<C-u>call <SID>manageEditorSize(v:count, 'decrease')<CR>
  54. nnoremap <silent> <C-w>_ :<C-u>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>