diff options
| -rw-r--r-- | init.vim | 4 | ||||
| -rw-r--r-- | vscode/settings.vim | 54 | 
2 files changed, 54 insertions, 4 deletions
| @@ -13,13 +13,13 @@ source $HOME/.config/nvim/vim-plug/plugins.vim  source $HOME/.config/nvim/general/settings.vim  source $HOME/.config/nvim/general/functions.vim  source $HOME/.config/nvim/keys/mappings.vim -source $HOME/.config/nvim/plug-config/vim-commentary.vim  source $HOME/.config/nvim/plug-config/quickscope.vim  if exists('g:vscode')    " VS Code extension    source $HOME/.config/nvim/vscode/settings.vim    source $HOME/.config/nvim/plug-config/easymotion.vim +  source $HOME/.config/nvim/plug-config/highlightyank.vim  else    " Themes @@ -29,13 +29,13 @@ else    " Plugin Configuration    source $HOME/.config/nvim/keys/which-key.vim +  source $HOME/.config/nvim/plug-config/vim-commentary.vim    " source $HOME/.config/nvim/plug-config/rainbow.vim    source $HOME/.config/nvim/plug-config/rnvimr.vim    source $HOME/.config/nvim/plug-config/better-whitespace.vim    source $HOME/.config/nvim/plug-config/fzf.vim    source $HOME/.config/nvim/plug-config/sneak.vim    source $HOME/.config/nvim/plug-config/codi.vim -  source $HOME/.config/nvim/plug-config/highlightyank.vim    source $HOME/.config/nvim/plug-config/vim-wiki.vim    source $HOME/.config/nvim/plug-config/coc.vim    source $HOME/.config/nvim/plug-config/goyo.vim diff --git a/vscode/settings.vim b/vscode/settings.vim index 3df722a1..8c988c8e 100644 --- a/vscode/settings.vim +++ b/vscode/settings.vim @@ -27,6 +27,48 @@ function! s:manageEditorSize(...)      endfor  endfunction +function! s:vscodeCommentary(...) abort +    if !a:0 +        let &operatorfunc = matchstr(expand('<sfile>'), '[^. ]*$') +        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:openVSCodeCommandsInVisualMode() +    normal! gv +    let visualmode = visualmode() +    if visualmode == "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) +    endif +endfunction + +function! s:openWhichKeyInVisualMode() +    normal! gv +    let visualmode = visualmode() +    if visualmode == "V" +        let startLine = line("v") +        let endLine = line(".") +        call VSCodeNotifyRange("whichkey.show", startLine, endLine, 1) +    else +        let startPos = getpos("v") +        let endPos = getpos(".") +        call VSCodeNotifyRangePos("whichkey.show", startPos[1], endPos[1], startPos[2], endPos[2], 1) +    endif +endfunction + +  command! -complete=file -nargs=? Split call <SID>split('h', <q-args>)  command! -complete=file -nargs=? Vsplit call <SID>split('v', <q-args>)  command! -complete=file -nargs=? New call <SID>split('h', '__vscode_new__') @@ -66,10 +108,18 @@ nnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>  xnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>  " Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors -xnoremap <silent> <C-/> :call Comment()<CR> -nnoremap <silent> <C-/> :call Comment()<CR> +xnoremap <expr> <C-/> <SID>vscodeCommentary() +nnoremap <expr> <C-/> <SID>vscodeCommentary() . '_'  nnoremap <silent> <C-w>_ :<C-u>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>  nnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR>  xnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR> + +xnoremap <silent> <C-P> :<C-u>call <SID>openVSCodeCommandsInVisualMode()<CR> +xnoremap <silent> <Space> :<C-u>call <SID>openWhichKeyInVisualMode()<CR> + +xmap gc  <Plug>VSCodeCommentary +nmap gc  <Plug>VSCodeCommentary +omap gc  <Plug>VSCodeCommentary +nmap gcc <Plug>VSCodeCommentaryLine | 
