function! s:vscodeFormat(...) abort if !a:0 let &operatorfunc = matchstr(expand(''), '[^. ]*$') return 'g@' elseif a:0 > 1 let [line1, line2] = [a:1, a:2] else let [line1, line2] = [line("'["), line("']")] endif call VSCodeCallRange('editor.action.formatSelection', line1, line2, 0) endfunction function! s:vscodeCommentary(...) abort if !a:0 let &operatorfunc = matchstr(expand(''), '[^. ]*$') return 'g@' elseif a:0 > 1 let [line1, line2] = [a:1, a:2] else let [line1, line2] = [line("'["), line("']")] endif call VSCodeCallRange('editor.action.commentLine', line1, line2, 0) endfunction function! s:vscodeGoToDefinition(str) if exists('b:vscode_controlled') && b:vscode_controlled call VSCodeNotify('editor.action.reveal' . a:str) else " Allow to funcionar in help files exe "normal! \" endif endfunction function! s:openVSCodeCommandsInVisualMode() let mode = mode() if mode ==# 'V' let startLine = line('v') let endLine = line('.') call VSCodeNotifyRange('workbench.action.showCommands', startLine, endLine, 1) else let startPos = getpos('v') let endPos = getpos('.') call VSCodeNotifyRangePos('workbench.action.showCommands', startPos[1], endPos[1], startPos[2], endPos[2] + 1, 1) endif endfunction command! -range -bar VSCodeCommentary call s:vscodeCommentary(, ) xnoremap VSCodeCommentary vscodeCommentary() nnoremap VSCodeCommentary vscodeCommentary() nnoremap VSCodeCommentaryLine vscodeCommentary() . '_' " Bind format to vscode format selection xnoremap = vscodeFormat() nnoremap = vscodeFormat() nnoremap == vscodeFormat() . '_' " gf/gF . Map to go to definition for now nnoremap K call VSCodeNotify('editor.action.showHover') nnoremap gh call VSCodeNotify('editor.action.showHover') nnoremap gf call vscodeGoToDefinition("Declaration") nnoremap gd call vscodeGoToDefinition("Definition") nnoremap call vscodeGoToDefinition("Definition") nnoremap gO call VSCodeNotify('workbench.action.gotoSymbol') nnoremap gF call VSCodeNotify('editor.action.peekDeclaration') nnoremap gD call VSCodeNotify('editor.action.peekDefinition') nnoremap gH call VSCodeNotify('editor.action.referenceSearch.trigger') xnoremap K call VSCodeNotify('editor.action.showHover') xnoremap gh call VSCodeNotify('editor.action.showHover') xnoremap gf call vscodeGoToDefinition("Declaration") xnoremap gd call vscodeGoToDefinition("Definition") xnoremap call vscodeGoToDefinition("Definition") xnoremap gO call VSCodeNotify('workbench.action.gotoSymbol') xnoremap gF call VSCodeNotify('editor.action.peekDeclaration') xnoremap gD call VSCodeNotify('editor.action.peekDefinition') xnoremap gH call VSCodeNotify('editor.action.referenceSearch.trigger') " gf opens definition on the side nnoremap gf call VSCodeNotify('editor.action.revealDefinitionAside') nnoremap gd call VSCodeNotify('editor.action.revealDefinitionAside') xnoremap gf call VSCodeNotify('editor.action.revealDefinitionAside') xnoremap gd call VSCodeNotify('editor.action.revealDefinitionAside') " Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors xnoremap vscodeCommentary() nnoremap vscodeCommentary() . '_' " open quickfix menu for spelling corrections and refactoring " only keyboard arrows can be used to navigate, for a solution, see https://github.com/asvetliakov/vscode-neovim#keyboard-quickfix nnoremap z= call VSCodeNotify('editor.action.quickFix') " workaround for calling command picker in visual mode xnoremap call openVSCodeCommandsInVisualMode()