-
Notifications
You must be signed in to change notification settings - Fork 0
/
vscodekeys.vim
64 lines (54 loc) · 2.58 KB
/
vscodekeys.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
" made up from
" https://github.com/ChristianChiarulli/nvim/blob/master/lua/user/keymaps.lua
" https://github.com/LunarVim/LunarVim/blob/rolling/utils/lv-vscode/init.vim
" https://www.youtube.com/watch?v=g4dXZ0RQWdw
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
function! s:ToggleComment()
normal! gv
let selection = [getpos("'<"), getpos("'>")]
let endLine = selection[1][1]
let startLine = selection[0][1]
call VSCodeNotifyRange("editor.action.commentLine", startLine, endLine, 0)
endfunction
nnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.navigateDown')<CR>
xnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.navigateDown')<CR>
nnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.navigateUp')<CR>
xnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.navigateUp')<CR>
nnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.navigateLeft')<CR>
xnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.navigateLeft')<CR>
nnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>
xnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>
nnoremap gr <Cmd>call VSCodeNotify('editor.action.goToReferences')<CR>
nnoremap <silent> ; :call VSCodeNotify('whichkey.show')<CR>
xnoremap <silent> ; :<C-u>call <SID>openWhichKeyInVisualMode()<CR>
xnoremap <silent> <C-P> :<C-u>call <SID>openVSCodeCommandsInVisualMode()<CR>
nnoremap gc :call VSCodeNotify('editor.action.commentLine')<cr>
nnoremap gC :call VSCodeNotify('editor.action.blockComment')<cr>
"vnoremap gc :call VSCodeNotify('editor.action.commentLine')<cr>
vnoremap gc :<C-u>call <SID>ToggleComment()<cr>
vnoremap gC :call VSCodeNotify('editor.action.blockComment')<cr>