VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.96k stars 1.32k forks source link

Neovim Integration Feedback #1735

Closed Chillee closed 5 years ago

Chillee commented 7 years ago

We have now added Neovim integration for Ex-commands. Enable it with vim.enableNeovim. Note that you must have neovim installed for this to work.

What are opinions on neovim being an optional dependency / maybe becoming a mandatory dependency down the line? We might be able to bundle it together with the extension down the line.

People clearly want neovim support. What are the main reasons for that? In other words, what features from neovim integration would you guys like to see implemented first?

Also, please come to http://vscodevim.slack.com! We'd love to hear discussion in there (discussion/feedback tends to be a bit quicker in there).

Chillee commented 7 years ago

@FelikZ With the fully neovim backed version, yes!

The only motions that won't really be supported (I think) are the overwin motions, I believe.

davidovich commented 6 years ago

With the fully neovim backed version, yes!

New to this, can you point to where the fully neovim backed version lives ?

ghost commented 6 years ago

@davidovich Nowhere yet. It's still in development.

You can track the repo here https://github.com/Chillee/VSCodeNeovim

davidovich commented 6 years ago

@paxy97 Thanks, this is what I meant by where. I understand that it is still in development, but having a where can help trying things out :-)

DrakeXiang commented 6 years ago

I'm experimenting the g command and m command, but doesn't work at all, I can get what I want in vim, so I think I typed command right, anyone idea?

p.s. I installed the latest neovim and did both the configuration, and didn't have warning pop up, so I think neovim is recognized by vscode

xerron commented 6 years ago

I also tried cgn and not work!. why?

mattaschmann commented 6 years ago

This used to work, but I haven't been able to get any commands to work recently, on Windows or OSX. When I try anything more complicated than a 'move' command, I get E492: Not an editor command. <attempted command>. Interestingly, this is the same error message I get when trying a bad command inside of neovim, but these are for perfectly acceptable commands. Was nvim integrations inadvertently disabled recently?

Chillee commented 6 years ago

@mattaschmann Sorry, there was a refactoring that introduced this bug. It was fixed in https://github.com/VSCodeVim/Vim/pull/2347.

I'll push out a release tonight.

mscharley commented 6 years ago

I'm all for integration between VSCodeVim and an actual vim. the number of times I'm switched between vim, atom's vim integration and VSCodeVim and had things work subtly (or even completely) differently is insane. Things like block selections especially seem to work completely differently in all three and I'm left wondering what I'm doing wrong every time.

Orionsg commented 6 years ago

I have been trying to setup Neovim for Visual Studio Code:

"vim.enableNeovim": true,
"vim.neovimPath": "C:\Program Files\Neovim\bin\nvim.exe"

I have copied the neovimPath from the explorer to make sure it is correct and checked that Neovim can start. However, the path is underlined in the Workspace Settings to indicate an error and there is a message when I restart VSCode,: "Unable to etup neovim instance. Check your path".

OS: Windows 7 32 bit VSCode version: 1.22.2 Neovim version: 0.2.2

Any ideas about what could be wrong?

ZuBB commented 6 years ago

hi all!

have same issue as @Orionsg! I have tried to integrate neovim into vscode (under macos) couple of times and failed to do that. would be nice to have/come up with latest howto on that.

ready to put some efforts into that

DrakeXiang commented 6 years ago

@ZuBB @Orionsg I believe you should escape the \ in path like this: D:\\Program Files\\Neovim\\bin\\nvim.exe.

ZuBB commented 6 years ago

hey @DrakeXiang, thanks for reply.

I am on mac os x 10.13. unix uses next kind of slash/. I thought I do not need to escape it. also a hint (provided by vscode) says same /usr/....

Orionsg commented 6 years ago

@DrakeXiang, thanks using extra backslashes escaping the backslash got rid of the error!

pokuwagata commented 6 years ago

Replace command (current line and next lines) dosen't work?

ex) :.,+1s/foo/bar

VSCodeVim : 0.13.1 VSCode : 1.24.1 NeoVim : v0.30

Orionsg commented 6 years ago

Vertical blocks have many issues. When marking a vertical block with ctrl-v:

  1. Yanking the block and pasting it (p) somewhere else inserts the block of text as if it is a normal block with new line characters rather than pasting the block at the column position where the cursor is (for each line in the vertical block).

  2. Deleting the vertical block (d) does not copy the contents to the buffer so it can afterwards be pasted (p).

  3. One cannot move the marked vertical block to the left or right with "<" or ">", respectively.

VSCode: 1.24.1 VSCodeVim: 0.14.1 NeoVim: 0.2.2

dgaleazzo commented 6 years ago

Using ":norm @@" command, the NeoVim macros are used, instead VSCode macros.

VSCode: 1.25 VSCodeVim: 0.14.2 NeoVim: 0.2.2

felixge commented 6 years ago

@dgaleazzo yeah, I have the same problem. Being able to record a macro and apply it to multiple lines is a killer-feature of vim's :normal command, but with the current neovim integration it doesn't work.

fredemmott commented 6 years ago

This generally seems excellent - the main thing I've noticed is that :help replaces file contents :(

JohnLRBrock commented 6 years ago

I just started getting a weird bug where I can't escape from insert or visual mode. Esc doesn't do anything and Ctrl + [ just unindents the line. Turning neovim off fixes the problem.

jplew commented 6 years ago

Using Neovim crashes my VS Code. If I use any Ex-commands it freezes my editor window. I documented this a while ago: https://github.com/VSCodeVim/Vim/issues/3013

VSCode: 1.25 VSCodeVim: 0.16.9 NeoVim: 0.3.1

fredemmott commented 6 years ago

It’s reliable for me on Mac, but have similar freezing issues on Windows

justinmk commented 6 years ago

Most likely Nvim is waiting for input. Does vscodevim check nvim_get_mode to see if it's in this state ("blocking" flag)? (This is a question for @Chillee or anyone who can inspect VSCode source code.)

jplew commented 6 years ago

Most likely Nvim is waiting for input. Does vscodevim check nvim_get_mode to see if it's in this state ("blocking" flag)?

How do I check this? Here is my log output under Output > Log (Extension Host): https://gist.github.com/jplew/35155adb2e1ff993f2fde9dca7efdbb8

No mention of nvim there.


UPDATE: I fixed it, i had a corrupted main.shada file: https://github.com/VSCodeVim/Vim/issues/3013

odorable-code commented 5 years ago

Word boundary pattern \< in visual range selection is not working.

command: :'<,'>s/\<bar\>/baz/g What I received: E486: Pattern not found: \/baz

VSCode: 1.29.1 VSCodeVim: 0.16.12 NeoVim: 0.3.1

andersennl commented 5 years ago

I have the same problem as @jplew described here. Removing the main.shada file and ~/.vimrc didn't solve the issue, though. NeoVim doesn't show any error on startup. I've looked through the logs in VSCode but didn't see anything suspicious. Any idea what it could be?

VSCode: 1.30.1 vscodevim: v1.0.0 (2019-01-05) NVIM: v0.3.3 MacOS: 10.14.1

jpoon commented 5 years ago

@andersennl sounds similar to https://github.com/VSCodeVim/Vim/issues/3323. Fixed was merged by @xconverge with a new release including said fix coming soon in v1.0.1

andersennl commented 5 years ago

@jpoon v.1.0.1 fixed the issue. Thanks!

jonatananauati-natgeo commented 5 years ago

hi!!, i've been testing the integration and I have couple of questions: 1) where I can find the output when running commands? example :!ls -ltr. When executing things, the prompt just returns to "normal mode" and i'm unable to see the output anywhere. 2) in insert mode, although ctrl-x ctrl-l does work for me, ctrl-x ctrl-f for file/directory completion does not, is this feature supported? thank you!

bluekeys commented 5 years ago

I copy my settings.json between machines. Is there a way to define declare neovimPath differently for linux and windows?

futurehome commented 5 years ago

I hope the neovim integration can use the style as what oni do, when input ":" "/". https://www.onivim.io/

eyalk5 commented 5 years ago

What about the echo command? and the source command? I feel like it could exploit at least half of the potential of neovim, but it doesn't currently.

justinmk commented 5 years ago

@eyalk5 Nvim 0.4.0 (unstable/development version) introduced the ext_messages UI API for that purpose. In case any VSCodeVim contributor wants to add support for that.

:help ui-options
eyalk5 commented 5 years ago

OK, I am not sure I fully understand(after installing this version) what does it mean. But I am glad it will be implemented. In any case, the lack of response for some commands that either fail or succeed is a major problem currently. And of course, supporting the defined keyboard mapping inside nvim is essential. This way my beloved customizations (in vimrc) could be applied. I might try to help to implement this.

iiifr commented 5 years ago

I can't set up neovim integration successfully. I received message:

Configuration: Invalid neovimPath. spawn /usr/bin/nvim ENOENT.

I have already added "vim.enableNeovim": true and "vim.neovimPath": "/usr/bin/nvim" to my settings.json, and checked that nvim indeed is located in /usr/bin/

VSCode version: 1.36.1 OS: Linux Mint 19.1 VSCodeVim: 1.9.0 NeoVim: 0.3.8

iiifr commented 5 years ago

I can't set up neovim integration successfully. I received message:

Configuration: Invalid neovimPath. spawn /usr/bin/nvim ENOENT.

I have already added "vim.enableNeovim": true and "vim.neovimPath": "/usr/bin/nvim" to my settings.json, and checked that nvim indeed is located in /usr/bin/

VSCode version: 1.36.1 OS: Linux Mint 19.1 VSCodeVim: 1.9.0 NeoVim: 0.3.8

I figured out this error is caused by flatpak's sandbox feature, tried to give additional options to flatpak to run VSCode but got no luck. I switch to VSCodium, which is a branch of VSCode, and also distributed without flatpak option. And It's all work now.

EDIT: Add Microsoft VSCode ppa from these instructions, then install from package manager, the VSCode is also non-flatpak, dont't know how I get a flatpak version VSCode :P

CavalloneChen commented 5 years ago

I can't set up neovim integration successfully. I received message:

Configuration: Invalid neovimPath. spawn /usr/bin/nvim ENOENT.

I have already added "vim.enableNeovim": true and "vim.neovimPath": "/usr/bin/nvim" to my settings.json, and checked that nvim indeed is located in /usr/bin/

VSCode version: 1.36.1 OS: Linux Mint 19.1 VSCodeVim: 1.9.0 NeoVim: 0.3.8

Same problem with vscode remote ssh. I installed nvim on my remote linux server, but this error keeps me from using neovim intergration.

iiifr commented 5 years ago

@CavalloneChen Is your vscode flatpak version?

CavalloneChen commented 5 years ago

@CavalloneChen Is your vscode flatpak version?

Honestly I don't know. I'm using the build downloaded from Vscode's official website.

iiifr commented 5 years ago

@CavalloneChen Is your vscode flatpak version?

Honestly I don't know. I'm using the build downloaded from Vscode's official website.

Execute flatpak list in terminal, and check if there is a line like this com.visualstudio.code

================================

I guess you download a .deb file from the visual studio code website, that's how I get a flatpak version vscode. I uninstalled the flatpak version vscode first, and manually add package repository then install vscode from package manager. ( referenced from here: https://code.visualstudio.com/docs/setup/linux )

I copied the installation commands for you:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/
sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install code

P.S. Commands uninstall the flatpak version vscode:

flatpak uninstall <the vscode name shown in 'flatpak list', e.g.  com.visualstudio.code.oss>
CavalloneChen commented 5 years ago

@CavalloneChen Is your vscode flatpak version?

Honestly I don't know. I'm using the build downloaded from Vscode's official website.

Execute flatpak list in terminal, and check if there is a line like this com.visualstudio.code

================================

I guess you download a .deb file from the visual studio code website, that's how I get a flatpak version vscode. I uninstalled the flatpak version vscode first, and manually add package repository then install vscode from package manager. ( referenced from here: code.visualstudio.com/docs/setup/linux )

I copied the installation commands for you:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/
sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install code

P.S. Commands uninstall the flatpak version vscode:

flatpak uninstall <the vscode name shown in 'flatpak list', e.g.  com.visualstudio.code.oss>

Thanks for your explanations, I really appreciate your effort. I found that I made a fundamental mistake. I pointed the neovim path to the neovim installed on my remote machine, but the local neovim path should be pointed instead. My problem was solved after I changed to the local path.

Mirag-e commented 5 years ago

I am perfectly happy with current vscodevim as far as my current knowledge of vim goes, great job. Yet to be honest I'm a bit surprised you're trying to implement vim and neovim emulation into vscode natively, wouldn't it be easier (but also better for long-term maintenance) to connect to full neovim through server mode and basically have neovim do all the work for you, so that you're not really emulating [neo]vim, you're actually using it, just with vscode as frontend? Or have I misinterpreted what's currently possible through neovim APIs?

By the way, for those that oppose this "because minimalism", I would note that baking neovim's functionalities into vscodevim doesn't make it any lighter than bundling neovim with it (the code's getting in either way), nor any simpler for the user (as long as it's installed automatically with it). It only makes it harder for the devs that maintain the plugin.

J-Fields commented 5 years ago

@Mirag-e There is a project to do just this (https://github.com/Chillee/VSCodeNeovim) but it's been dead for a while. You might find https://github.com/onivim/oni2 interesting also.

Mirag-e commented 5 years ago

thanks for the pointers, oni2 seems super interesting, though i'm a bit sad it's not fully open source. I guess that's the price to pay when you don't have microsoft paying your main developers.

nerdo commented 5 years ago

I wish VSCodeNeovim was active. I'd work on it myself if I have the time, but, alas...

Ex commands may be useful, but I've never actually used them. The VSCodeVim plugin seems to work well a lot of the time, but I find it to be a bit finicky sometimes, which is why I personally would love to see neovim power it.

Oni2 looks super interesting, since they intend to support vscode extensions and configuration... and for $20, I don't mind speculating that the project will work out. Time will tell.

danielb2 commented 5 years ago

Oni2 looks super interesting, since they intend to support vscode extensions and configuration... and for $20, I don't mind speculating that the project will work out. Time will tell.

I'm not trying to discourage you to support this cool project. Just FYI after using Oni (1) I dropped it fairly quickly. (it was finicky about what neovim versions I had installed and it was buggy)

nerdo commented 5 years ago

Oni2 looks super interesting, since they intend to support vscode extensions and configuration... and for $20, I don't mind speculating that the project will work out. Time will tell.

I'm not trying to discourage you to support this cool project. Just FYI after using Oni (1) I dropped it fairly quickly. (it was finicky about what neovim versions I had installed and it was buggy)

Thanks for the heads up. It seems they've taken a different approach with Oni2 though, using libvim instead of neovim. I read somewhere that the choice was because of integration issues with neovim.

You may already know this, but it seems like if you have supported Oni1, you will have access to Oni2 https://onivim.github.io/docs/other/faq#i-already-backed-onivim-1-do-i-need-to-pay-again so hopefully your support for Oni1 will be worth it if Oni2 is successful.

Orionsg commented 5 years ago

I installed Neovim and set it active in order to be able to use regular expressions in the substitute command. However, it does not seem to work for the substitute or global command.

If I use:

":%s/^/<p>/g" (to insert a p tag in the beginning of all lines)
or
":g/^\s*$/d" (to remove all blank lines)

I get the error: "TaskQueue: Error running task. Failed to handle key= . nvim_buf_set_lines: Wrong type for argument 1, expecting Buffer."

Any ideas about how to make this work?

casey-speer commented 5 years ago

I installed Neovim and set it active in order to be able to use regular expressions in the substitute command. However, it does not seem to work for the substitute or global command.

If I use:

":%s/^/<p>/g" (to insert a p tag in the beginning of all lines)
or
":g/^\s*$/d" (to remove all blank lines)

I get the error: "TaskQueue: Error running task. Failed to handle key= . nvim_buf_set_lines: Wrong type for argument 1, expecting Buffer."

Any ideas about how to make this work?

+1 @Orionsg This feature had been working for me for quite some time but it has been broken recently :/ Similar error message about nvim_buf_set_lines tried upgrading neovim to no avail. I'm thinking it's a bug.

DwordPtr commented 5 years ago

One thing I miss is netrw being able to open a url with gx is really nice.