From 53123f954c6719599b1e3cbb7fb3bbe07bd12512 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 27 Apr 2020 21:58:30 -0400 Subject: added vscode support --- vscode/windows.vim | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 vscode/windows.vim (limited to 'vscode') diff --git a/vscode/windows.vim b/vscode/windows.vim new file mode 100644 index 00000000..436bf981 --- /dev/null +++ b/vscode/windows.vim @@ -0,0 +1,67 @@ + +"VSCode +function! s:split(...) abort + let direction = a:1 + let file = a:2 + call VSCodeCall(direction == 'h' ? 'workbench.action.splitEditorDown' : 'workbench.action.splitEditorRight') + if file != '' + call VSCodeExtensionNotify('open-file', expand(file), 'all') + endif +endfunction + +function! s:splitNew(...) + let file = a:2 + call s:split(a:1, file == '' ? '__vscode_new__' : file) +endfunction + +function! s:closeOtherEditors() + call VSCodeNotify('workbench.action.closeEditorsInOtherGroups') + call VSCodeNotify('workbench.action.closeOtherEditors') +endfunction + +function! s:manageEditorSize(...) + let count = a:1 + let to = a:2 + for i in range(1, count ? count : 1) + call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize') + endfor +endfunction + +command! -complete=file -nargs=? Split call split('h', ) +command! -complete=file -nargs=? Vsplit call split('v', ) +command! -complete=file -nargs=? New call split('h', '__vscode_new__') +command! -complete=file -nargs=? Vnew call split('v', '__vscode_new__') +command! -bang Only if == '!' | call closeOtherEditors() | else | call VSCodeNotify('workbench.action.joinAllGroups') | endif + +nnoremap s :call split('h') +xnoremap s :call split('h') + +nnoremap v :call split('v') +xnoremap v :call split('v') + +nnoremap n :call splitNew('h', '__vscode_new__') +xnoremap n :call splitNew('h', '__vscode_new__') + +nnoremap :call VSCodeNotify('workbench.action.focusBelowGroup') +xnoremap :call VSCodeNotify('workbench.action.focusBelowGroup') +nnoremap :call VSCodeNotify('workbench.action.focusAboveGroup') +xnoremap :call VSCodeNotify('workbench.action.focusAboveGroup') +nnoremap :call VSCodeNotify('workbench.action.focusLeftGroup') +xnoremap :call VSCodeNotify('workbench.action.focusLeftGroup') +nnoremap :call VSCodeNotify('workbench.action.focusRightGroup') +xnoremap :call VSCodeNotify('workbench.action.focusRightGroup') + +nnoremap = :call VSCodeNotify('workbench.action.evenEditorWidths') +xnoremap = :call VSCodeNotify('workbench.action.evenEditorWidths') + +nnoremap > :call manageEditorSize(v:count, 'increase') +xnoremap > :call manageEditorSize(v:count, 'increase') +nnoremap + :call manageEditorSize(v:count, 'increase') +xnoremap + :call manageEditorSize(v:count, 'increase') +nnoremap < :call manageEditorSize(v:count, 'decrease') +xnoremap < :call manageEditorSize(v:count, 'decrease') +nnoremap - :call manageEditorSize(v:count, 'decrease') +xnoremap - :call manageEditorSize(v:count, 'decrease') + +nnoremap _ :call VSCodeNotify('workbench.action.toggleEditorWidths') + -- cgit v1.2.3