Live data from Hacker News

VSCode-Neovim: Use embedded Neovim in VSCode without emulation

github.com

51–60 of 112 posts

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#51

Personally, my problem with trying to use Vim keybindings in VS Code is not about the motions of moving around/editing the code itself, but everything else. You end up in plenty of situations where you have to resolve using the mouse because you ended up on some sub-page or whatever, where you either need to resolve using the mouse or keep pressing Tab until you get to where you want to go. Installing plugins is one…

perhaps onivim would be a good VSCode alternative for you, I think they have a mode like the browser vim extensions that labels everything on screen with a key you can press instead of clicking. https://onivim.io/

SpaceVim is also a fine contender with its LSP support: https://spacevim.org/

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#52

Personally, my problem with trying to use Vim keybindings in VS Code is not about the motions of moving around/editing the code itself, but everything else. You end up in plenty of situations where you have to resolve using the mouse because you ended up on some sub-page or whatever, where you either need to resolve using the mouse or keep pressing Tab until you get to where you want to go. Installing plugins is one…

I do now have memorized some mix of vim and vscode keybindings, but to me it's worth it. I'm not at 100% keyboard navigation because in some cases I've burned 5-10 minutes looking up a shortcut, repeatedly 1/mo for 3 months. After so many (overly) spaced repetitions, I recognize the shortcut isn't worth memorizing.

> Installing plugins is one good example of this, where even if you use a Vim plugin (or this, it seems), you still need to resolve to using the mouse/Tabbing to actually install the plugin itself.

I agree with you here, but I rarely need to install new plugins. It's certainly not a task I repeat for a given plugin. Plugins are actually the reason I do primary development in VSCode instead of Neovim natively. I can set up linters, language highlighters, etc in VSCode much faster than I can in Neovim. The ecosystem in VSCode also seems to be bigger for what I've done in the last few years.

---

Anyways, here are some VS Code keybindings I've found essential to go hand-in-hand with vscode-neovim. These few probably get me to 90% keyboard navigation for day-to-day editing.

cmd-shift-m: toggle the bottom tray problems (works as a universal way to show/hide the bottom)

cmd-b: toggle the left sidebar (in whatever context it was last in)

cmd-shift-e: show the current file in the left sidebar

cmd-0: move context/focus to the left sidebar cmd-1: move context/focus to the editor cmd-2: move context/focus to the right editor (or open an editor split, if not yet split)

ctrl-1,...9: highlight Nth tab from the left ctrl-0: highlight rightmost tab

cmd-p: fuzzy find file cmd-shift-p: fuzzy find any installed action by description

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#53
post #30

Earlier quoted context omitted.

> Installing plugins is one good example of this, where even if you use a Vim plugin (or this, it seems), you still need to resolve to using the mouse/Tabbing to actually install the plugin itself. Sounds like a minor annoyance at best... Where vim-mode is important to me is editing and navigating code, not when installing plugins...

As I said, it's one example. Anything outside the code window suffers from the same problem, not just installing plugins...

I didn’t expect to disagree with you at first because I also struggle with vim -Code plug-ins, but it really never occurred to me that it would cover the entire functionality of Vim outside the editor and file navigation.

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#54
post #12

Personally, my problem with trying to use Vim keybindings in VS Code is not about the motions of moving around/editing the code itself, but everything else. You end up in plenty of situations where you have to resolve using the mouse because you ended up on some sub-page or whatever, where you either need to resolve using the mouse or keep pressing Tab until you get to where you want to go. Installing plugins is one…

I guess I am the target market. I don't mind using the mouse when I'm not in the "flow" of editing. Even browsing code, scroll wheels are pretty expressive, and clicking to jump to definition is fine. Ok not typing, so I don't need to keep my hand on the home row. But the actual editing doesn't use the mouse.

If you have the proper jump to definition set up, vscode-neovim actually has a keybinding (that matches vim/neovim)

gd (go to definition)

You'll also like

gh (peek definition)

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#55
post #26

I tried this plugin a few years ago. It was neat but ultimately buggy and not ironed out enough to use daily. To people who currently use it, has it improved noticeably?

Yes, it has. I've used it for years as well, and I think I know the bugginess you're referring to. Some time back, it required Neovim 0.5.0 or 0.5.1, and that wasn't yet in the official Neovim homebrew package. This was actually documented on the vscode-neovim homepage, but it was easy to miss.

Back then, I used a custom homebrew tap to get the proper Neovim version installed, and the plugin mostly worked. Occasionally the editing context would get messed up, and still does. I've found that changing tabs inside VSCode resets the neovim context, and that's a nearly-instant fix for most issues I see now.

It also works with the default version of Neovim from homebrew. No more custom tap needed.

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#56

I use the regular vim extension in VSCode. How does this compare to that?

Day and night. I haven't touched the regular vim extension in years, but its vim compatibility and feature set depends on the extension author. This plugin starts up neovim as a backend server and sends the file and keystrokes to that. It's not emulation, it's actually Neovim.

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#57
post #3

Would love to see if people have a good experience with this. The only thing keeping me on neovim is the ergonomics of my config. If I can have that, PLUS the discoverability of all the LSP features, hovering, consolidated error messages, etc. without it breaking all the time, I would switch in a heartbeat.

For unrelated reasons I've gone back to neovim. But I used this in vscode for about a year. It works well. I found it got stuck once a day or so and I had to restart vscode. That might have improved by now. Having your keybinding-related config spread out across so many different places (nvim's config, vscode's preferences and keybinding files) is a bit annoying, and I found after initial setup I kept forgetting what…

I know those times you're talking about when it gets stuck. Switching to another file and back seems to solve that issue for me, and is much faster than a restart.

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#58
post #5
post #3

Would love to see if people have a good experience with this. The only thing keeping me on neovim is the ergonomics of my config. If I can have that, PLUS the discoverability of all the LSP features, hovering, consolidated error messages, etc. without it breaking all the time, I would switch in a heartbeat.

Been using it for a couple of years. No problems. You don't get the "absolute fullest" (neo)vim experience because you don't get the buffers/panes like you do in nvim though.

I actually do use pane commands from time to time.

ctrl-w s : will split horizontally ctrl-w v : will split vertically

Commands work, and I just tested buffers specifically. I can type :buffers and I see a list. I was able to get vscode to switch tabs with :b 209 (I don't normally inspect buffers this way, but it's integrated and it works).

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#59
post #18

I love neovim but I don’t have a good replacement for the git plugin of vscode. I haven’t found my way to replicating that experience in neovim. I tried lazygit but I find the diff viewer hard to understand and navigate. Diff view ( https://github.com/sindrets/diffview.nvim ) might be it, but I haven’t made the time to install a newer version of git from source (Debian…)

Gitsigns was good enough for my workflows: https://github.com/lewis6991/gitsigns.nvim

Besides showing the git signs in the gutter, it can do staging, diffing, navigation between hunks, line blame, can show deleted lines etc. If you have more advanced workflows, it might not be enough though. I use lazygit quite often as well.

Re: VSCode-Neovim: Use embedded Neovim in VSCode without emulation

#60
I don't use this extension, but I have used the 'vscodevim' extension for many years now.

I forget all of the settings I changed to make it work for me, but it's mostly usable as a vim replacement now.

I needed to set 'use control keys' or something like that, so I can use Ctrl-[ instead of ESC to enter command mode, something I've done since Vim 2.0 days (and before that in Elvis).

I also override vim bindings for Ctrl-X, Ctrl-C, Ctrl-V, (cut/copy/paste), Ctrl-Z, Ctrl-Y (undo/redo) so I can use vscode for that behavior instead. I'll also use the normal vim commands for those also (like yy, p, etc). Best of both worlds I suppose.

My only gripe with this approach is undo/redo stacks can sometimes get lost between vim and vscode handling it. There is a similar extension for Visual Studio which has never lost the undo/redo stack like the vscode extension does.

Is any of this any better with the newest vscode-neovim? I tried vscode-neovim a while back and had go back to vscodevim after having problems.

Post reply on HN