-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapt to vscode-neovim #34
Comments
For example, here is my init.vim " Vscode Commands
if exists('g:vscode')
function! s:VisualCommand(commandString)
normal! gv
call VSCodeNotify(a:commandString)
endfunction
xnoremap <silent> gh :<C-u>call <SID>hover()<CR>
nnoremap <silent> <Leader><space> :<C-u>call VSCodeNotify('workbench.action.showCommands')<CR>
nnoremap <silent> <Leader>pf :<C-u>call VSCodeNotify('workbench.action.quickOpen')<CR>
nnoremap <silent> <Leader>/ :<C-u>call VSCodeNotify('actions.find')<CR>
nnoremap <silent> <Leader>= :<C-u>call VSCodeNotify('editor.action.formatDocument')<CR>
nnoremap <silent> <Leader>bd :<C-u>call VSCodeNotify('workbench.action.closeActiveEditor')<CR>
nnoremap <silent> <Leader>bo :<C-u>call VSCodeNotify('workbench.action.closeOtherEditors')<CR>
nnoremap <silent> <Leader>br :<C-u>call VSCodeNotify('workbench.action.files.revert')<CR>
nnoremap <silent> <Leader>bs :<C-u>call VSCodeNotify('workbench.action.files.newUntitledFile')<CR>
nnoremap <silent> <Leader>el :<C-u>call VSCodeNotify('workbench.actions.view.problems')<CR>
nnoremap <silent> <Leader>ep :<C-u>call VSCodeNotify('editor.action.marker.previous')<CR>
nnoremap <silent> <Leader>en :<C-u>call VSCodeNotify('editor.action.marker.next')<CR>
nnoremap <silent> <Leader>f/ :<C-u>call VSCodeNotify('actions.find')<CR>
nnoremap <silent> <Leader>f2 :<C-u>call VSCodeNotify('fileutils.duplicateFile')<CR>
nnoremap <silent> <Leader>fd :<C-u>call VSCodeNotify('fileutils.removeFile')<CR>
nnoremap <silent> <Leader>fe :<C-u>call VSCodeNotify('workbench.action.openGlobalSettings')<CR>
nnoremap <silent> <Leader>fE :<C-u>call VSCodeNotify('workbench.action.openSettingsJson')<CR>
nnoremap <silent> <Leader>fh :<C-u>call VSCodeNotify('gitlens.showQuickFileHistory')<CR>
nnoremap <silent> <Leader>fm :<C-u>call VSCodeNotify('fileutils.moveFile')<CR>
nnoremap <silent> <Leader>fn :<C-u>call VSCodeNotify('fileutils.newFileAtRoot')<CR>
nnoremap <silent> <Leader>fo :<C-u>call VSCodeNotify('workbench.action.files.openFile')<CR>
nnoremap <silent> <Leader>fO :<C-u>call VSCodeNotify('workbench.action.files.openFile')<CR>
nnoremap <silent> <Leader>fr :<C-u>call VSCodeNotify('fileutils.renameFile')<CR>
nnoremap <silent> <Leader>fs :<C-u>call VSCodeNotify('workbench.action.gotoSymbol')<CR>
nnoremap <silent> <Leader>fw :<C-u>call VSCodeNotify('workbench.action.files.save')<CR>
nnoremap <silent> <Leader>fy :<C-u>call VSCodeNotify('workbench.action.files.copyPathOfActiveFile')<CR>
nnoremap <silent> <Leader>gb :<C-u>call VSCodeNotify('gitlens.toggleFileBlame')<CR>
nnoremap <silent> <Leader>gh :<C-u>call VSCodeNotify('gitlens.showQuickRepoHistory')<CR>
nnoremap <silent> <Leader>gs :<C-u>call VSCodeNotify('workbench.view.scm')<CR>
nnoremap <silent> <Leader>hd :<C-u>call VSCodeNotify('workbench.action.openGlobalKeybindings')<CR>
nnoremap <silent> <Leader>hD :<C-u>call VSCodeNotify('workbench.action.openGlobalKeybindingsFile')<CR>
nnoremap <silent> <Leader>pf :<C-u>call VSCodeNotify('workbench.action.quickOpen')<CR>
nnoremap <silent> <Leader>pl :<C-u>call VSCodeNotify('workbench.action.files.openFolder')<CR>
nnoremap <silent> <Leader>pp :<C-u>call VSCodeNotify('workbench.action.openRecent')<CR>
nnoremap <silent> <Leader>ps :<C-u>call VSCodeNotify('workbench.action.showAllSymbols')<CR>
nnoremap <silent> <Leader>qq :<C-u>call VSCodeNotify('workbench.action.closeWindow')<CR>
nnoremap <silent> <Leader>qr :<C-u>call VSCodeNotify('workbench.action.reloadWindow')<CR>
nnoremap <silent> <Leader>rn :<C-u>call VSCodeNotify('search.action.focusNextSearchResult')<CR>
nnoremap <silent> <Leader>rp :<C-u>call VSCodeNotify('search.action.focusPreviousSearchResult')<CR>
nnoremap <silent> <Leader>rs :<C-u>call VSCodeNotify('workbench.action.findInFiles')<CR>
nnoremap <silent> <Leader>rn :<C-u>call VSCodeNotify('editor.action.rename')<CR>
nnoremap <silent> <Leader>ta :<C-u>call VSCodeNotify('workbench.action.toggleActivityBarVisibility')<CR>
nnoremap <silent> <Leader>tb :<C-u>call VSCodeNotify('workbench.action.toggleSidebarVisibility')<CR>
nnoremap <silent> <Leader>tc :<C-u>call VSCodeNotify('workbench.action.toggleCenteredLayout')<CR>
nnoremap <silent> <Leader>td :<C-u>call VSCodeNotify('workbench.view.debug')<CR>
nnoremap <silent> <Leader>te :<C-u>call VSCodeNotify('workbench.view.explorer')<CR>
nnoremap <silent> <Leader>tf :<C-u>call VSCodeNotify('workbench.action.toggleFullScreen')<CR>
nnoremap <silent> <Leader>tg :<C-u>call VSCodeNotify('workbench.view.scm')<CR>
nnoremap <silent> <Leader>t/ :<C-u>call VSCodeNotify('workbench.action.findInFiles')<CR>
nnoremap <silent> <Leader>tl :<C-u>call VSCodeNotify('workbench.view.extension.gitlens')<CR>
nnoremap <silent> <Leader>tm :<C-u>call VSCodeNotify('workbench.action.toggleMenuBar')<CR>
nnoremap <silent> <Leader>tM :<C-u>call VSCodeNotify('editor.action.toggleMinimap')<CR>
nnoremap <silent> <Leader>tp :<C-u>call VSCodeNotify('workbench.action.togglePanel')<CR>
nnoremap <silent> <Leader>' :<C-u>call VSCodeNotify('workbench.action.terminal.toggleTerminal')<CR>
nnoremap <silent> <Leader>ts :<C-u>call VSCodeNotify('workbench.action.selectTheme')<CR>
nnoremap <silent> <Leader>tx :<C-u>call VSCodeNotify('workbench.view.extensions')<CR>
nnoremap <silent> <Leader>tz :<C-u>call VSCodeNotify('workbench.action.toggleZenMode')<CR>
nnoremap <silent> <Leader>v :<C-u>call VSCodeNotify('editor.action.smartSelect.grow')<CR>
nnoremap <silent> <Leader>V :<C-u>call VSCodeNotify('editor.action.smartSelect.shrink')<CR>
nnoremap <silent> <Leader>w- :<C-u>call VSCodeNotify('workbench.action.splitEditorDown')<CR>
nnoremap <silent> <Leader>w/ :<C-u>call VSCodeNotify('workbench.action.splitEditorRight')<CR>
nnoremap <silent> <Leader>wd :<C-u>call VSCodeNotify('workbench.action.closeEditorsInGroup')<CR>
nnoremap <silent> <Leader>wh :<C-u>call VSCodeNotify('workbench.action.focusLeftGroup')<CR>
nnoremap <silent> <Leader>wH :<C-u>call VSCodeNotify('workbench.action.moveActiveEditorGroupLeft')<CR>
nnoremap <silent> <Leader>wj :<C-u>call VSCodeNotify('workbench.action.focusBelowGroup')<CR>
nnoremap <silent> <Leader>wJ :<C-u>call VSCodeNotify('workbench.action.moveActiveEditorGroupDown')<CR>
nnoremap <silent> <Leader>wk :<C-u>call VSCodeNotify('workbench.action.focusAboveGroup')<CR>
nnoremap <silent> <Leader>wK :<C-u>call VSCodeNotify('workbench.action.moveActiveEditorGroupUp')<CR>
nnoremap <silent> <Leader>wl :<C-u>call VSCodeNotify('workbench.action.focusRightGroup')<CR>
nnoremap <silent> <Leader>wL :<C-u>call VSCodeNotify('workbench.action.moveActiveEditorGroupRight')<CR>
nnoremap <silent> <Leader>wm :<C-u>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>
nnoremap <silent> <Leader>wo :<C-u>call VSCodeNotify('workbench.action.closeEditorsInOtherGroups')<CR>
nnoremap <silent> <Leader>ws :<C-u>call VSCodeNotify('workbench.action.splitEditorDown')<CR>
nnoremap <silent> <Leader>wv :<C-u>call VSCodeNotify('workbench.action.splitEditorRight')<CR>
nnoremap <silent> <Leader>ww :<C-u>call VSCodeNotify('workbench.action.focusNextGroup')<CR>
nnoremap <silent> <Leader>wW :<C-u>call VSCodeNotify('workbench.action.focusPreviousGroup')<CR>
nnoremap <silent> <Leader>xw :<C-u>call VSCodeNotify('editor.action.trimTrailingWhitespace')<CR>
nnoremap <silent> go :<C-u>call VSCodeNotify('editor.action.showContextMenu')<CR>
xnoremap <silent> <Leader><space> :<C-u>call <SID>VisualCommand('workbench.action.showCommands')<CR>
xnoremap <silent> > :<C-u>call <SID>VisualCommand("editor.action.indentLines")<CR>
xnoremap <silent> < :<C-u>call <SID>VisualCommand("editor.action.outdentLines")<CR>
xnoremap <silent> go :<C-u>call <SID>VisualCommand("editor.action.showContextMenu")<CR>
nnoremap <silent> <Leader>/ :<C-u>call <SID>VisualCommand('actions.find')<CR>
xmap gc <Plug>VSCodeCommentary
nmap gc <Plug>VSCodeCommentary
omap gc <Plug>VSCodeCommentary
nmap gcc <Plug>VSCodeCommentaryLine
endif
|
Hi :) I am not using neovim so I am not going to implement, support or test this. If someone is willing to do a PR and support the feature this would be welcome 😊 In the meantime I'm closing the issue because there is not much to do. |
Is VSpaceCode tightly coupled to the Vim plugin? Clearly we need a Vim layer to emulate Spacemacs, but do we need that specific vim layer? Perhaps vscode-neovim could provide the vim mappings in place of the vim plugin. |
@iansinnott I happen to be subscribed to this issue for some reason, but I think a lot has changed since this issue was opened. VSpaceCode (and thus, vscode-which-key) doesn't need any Vim emulation in order to function anymore, as far as I can tell -- it's just an extension that you can invoke. While it's surely a better experience that way, all you need to do is remap the extension's invocation to With the above in mind, I recommend checking out the README for this project again. One note to call out from "Project History":
Hope that helps. |
Thank you @macintacos. For anyone else coming across this issue I'd point out that using vscode-neovim the " Integrate with whichkey for spacemacs-style space key
nnoremap <space> :call VSCodeNotify('whichkey.show')<CR> |
You can also override space binding to work {
"key": "space",
"command": "vspacecode.space",
"when": "editorTextFocus && neovim.mode == normal"
}, |
for visual mode, can use this to remap in your lua config file. local function getVisualSelection()
local start = vim.fn.getpos("v")
local finish = vim.fn.getcurpos()
return start, finish
end
local function exit_visual_mode()
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
end
vim.keymap.set("n", "<space>", ":call VSCodeNotify('vspacecode.space')<CR>")
vim.keymap.set("x", "<space>", function()
local start, finish = getVisualSelection()
if vim.fn.visualmode() == "V" then
vim.fn.VSCodeNotifyRange("vspacecode.space", start[2], finish[2], 1)
else
vim.fn.VSCodeNotifyRangePos("vspacecode.space", start[2], finish[2], start[3], finish[3], 1)
end
exit_visual_mode()
end)
|
Could you check if this still works? I tried to toggle comment a visual selection but only the last line of the selection gets commented. That is, I selected a region by "v" using vscode-neovim, pressed "space + ;" to toggle comment of region. Only the last line gets toggled. For comparison, I successfully toggled the comment of a region by directly invoking the "Toggle Line Comment" command in vscode for the region selected using vscode-neovim visual selection "v". |
@aveaves The VSCodeNotifyRange API has changed, try this local function getVisualSelection()
local start = vim.fn.getpos("v")
local finish = vim.fn.getcurpos()
return start, finish
end
vim.keymap.set("n", "<space>", ":call VSCodeNotify('vspacecode.space')<CR>")
vim.keymap.set("x", "<space>", function()
local start, finish = getVisualSelection()
if vim.fn.mode() == "V" then
require("vscode-neovim").notify_range("vspacecode.space", start[2], finish[2], 1)
else
require("vscode-neovim").notify_range_pos("vspacecode.space", start[2], finish[2], start[3], finish[3], 1)
end
end) |
@a690700752 Thank you this also works. I solved it a while ago using your first code by removing the exit_visual_mode() function. |
Vscode neovim allow to use vim inside a vscode window. Mapping of vscode action is supported directly in the init.vim file. A port of this configuration should be easy.
https://github.com/asvetliakov/vscode-neovim
The text was updated successfully, but these errors were encountered: