Skip to content
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

neovim integration? #18

Closed
prabirshrestha opened this issue Nov 19, 2015 · 62 comments
Closed

neovim integration? #18

prabirshrestha opened this issue Nov 19, 2015 · 62 comments

Comments

@prabirshrestha
Copy link

Are there any plans for neovim integration?

@jpoon
Copy link
Member

jpoon commented Nov 19, 2015

As I understand, the neovim project is refactoring vim core itself. What would be involved with integrating VSCode with neovim?

@snowiow
Copy link
Contributor

snowiow commented Nov 19, 2015

As far as I know, neovim offers the RPC protocol for communication. So a gui can communicate with the neovim core for example. Here are some example projects. Here is also a small overview on how this communication could look like. But I don't have a clue about anything beneath this theory.

@jpoon
Copy link
Member

jpoon commented Nov 19, 2015

Whoa, that is actually really amazing! I'm curious as to its current state; of the example projects, none of them looked very complete. Nonetheless, looks super promising.

@jordwalke
Copy link

I would seriously consider taking a look at this existing electron-integrated neovim implementation: https://github.com/coolwanglu/neovim-e

It works really well. The challenge with integrating into VSCode is that neovim currently only exposes raw character/line draw command (this will be improved over time). VSCode's API likely will want something more rich than this. This is why that neovim-electron project uses canvas to paint everything.
However, I would still recommend starting with an interpretation of NeoVim's raw/unstructured commands - counting on NeoVim to deliver more structured information in the future (I believe it's on the roadmap) (or counting on the fact that you can extract whatever meaning you need from the unstructured commands with enough reliability).
Comparing the time it would take to interpret the unstructured message (or wait for NeoVim to deliver more structure) against the time/effort it takes to replicate all of Vim's nuances correctly - I would say that integrating with NeoVim might get you to the end goal more quickly.

(For context, I'm a Vim emulator connoisseur, and file countless issues on various editor plugins that try to get the Vim feel right - in my experience, it takes a very very long time - and not a single one has achieved Vim's core editing experience. With much due respect to Vintageous (which does a very good job in general), even it doesn't replicate the undo/redo cursor position correctly (which is a critical part of the Vim editing experience) (but in that case because it's fundamentally limited by Sublime's API).

@guillermooo
Copy link
Member

How stable is Neovim on all three platforms?

I'm against adopting Neovim wholesale at this point. My suggestion is that we continue with a port of Vim in TS without taking it too far. At the same time, we can explore certain functionality using Neovim (vimrc support, for example, if it provides that), and then converge on the choice that makes more sense: pure TS port or Neovim back-end.

Also, we'll need some TS infrastructure anyway, primarily for keyboard handling, so we can implement a handful of commands in TS, see where we get and then adjust our approach wrt Neovim.

@jordwalke
Copy link

How stable is Neovim on all three platforms?

I'm not sure, I've only tried it on Mac OS, but it's forked from Vim.

Also, we'll need some TS infrastructure anyway, primarily for keyboard handling, so we can implement a handful of commands in TS, see where we get and then adjust our approach wrt Neovim.

Yeah, don't someone like me stop you - seems like good stuff will come out of this! I'm just giving my perspective as a consumer of Vim emulators. A Vim emulator that only gets 98% right is almost worthless - no one ends up using them. It's the small subtleties that are the worst. Please consider it a great compliment to your fantastic work on Vintageous that I consider it "faithful enough to use". I just thought that there might be a faster path to getting there for VSCodeVim (I'm recalling the massive amount of work that I've seen you do over the last several years - my how time flies :) )

@tmandry
Copy link

tmandry commented Nov 21, 2015

FWIW, all reports I've heard say neovim is very stable, thanks in part to its dramatically expanded body of tests. A few reports are here.

I do agree completely with @jordwalke's point of view here. I personally think it's only a matter of time before integrations like this replace emulations, in editors where it's practical to integrate. That said, I don't know of any great examples of integrations with existing editors yet. There might be some hidden challenges to doing this.

@tmandry
Copy link

tmandry commented Nov 21, 2015

Starting points for anyone who is interested in looking into this:

Also you might want to read tarruda's blog post about his planned Smart UI protocol to get a sense of what's coming in the future. Some of the limitations he mentions in that post may already be removed (check the API), but I'm not certain.

@jordwalke
Copy link

That "Smart UI Protocol" is exactly what I had in mind.

In the mean time, I would even be happy with a canvas rendering of Vim inside of VSCode (which is almost trivial to accomplish thanks to neovim-e (electron example)).

@drewcassidy
Copy link

In the mean time, I would even be happy with a canvas rendering of Vim inside of VSCode (which is almost trivial to accomplish thanks to neovim-e (electron example)).

💯 This would be awesome, especially if i can still use all of VSCode's debugging features. This might even be the right thing to do given the current limited extension API.

@aakashsigdel
Copy link

From my experience I can tell that neovim is very stable in mac OSX and in linux. And I would love to see it being integrated with vscode.

@songgao
Copy link

songgao commented Mar 31, 2016

Another happy neovim user here. I have alias vim=nvim and never had any serious (if any at all) problems. The team is very active and responsive to issue reports. Not sure about API stability though.

@owais
Copy link

owais commented Jun 28, 2016

FWIW, I've been using neovim-dot-app (https://github.com/rogual/neovim-dot-app) on OS X on production for a couple of months at least and it works really really well. Only minor issue I've seen so far is that the re-draws are a bit slow when scrolling too fast.

@johnfn
Copy link
Member

johnfn commented Jul 6, 2016

This is still viable as an extension, but probably isn't going to be ours, given the amount of stuff we've already done... 😛

@johnfn johnfn closed this as completed Jul 6, 2016
@johnfn
Copy link
Member

johnfn commented Jan 15, 2017

Wow, this got a lot of thumbs up.

To the people that are thumbsing this up (and thumbsing down my previous comment): What particular, specific features of Neovim are you missing from VSCodeVim? (e.g. "plugins" is not very helpful, but "surround.vim" is.)

@justinmk
Copy link

@johnfn I didn't vote, but some Vim features are missing from all vim emulations: ex commands (there are hundreds of them), vim regex, jumplist, quickfix list, macros, marks (the non-obvious ones), vim's undo behavior, spellcheck (it's powerful and unique), vim completion (it's powerful and unique), viminfo (called "shared data" in Neovim). And lots of subtle details.

@johnfn
Copy link
Member

johnfn commented Jan 15, 2017

@justinmk I know that there are lots of things missing from VSCodeVim, but I'm looking for the specific features that are missing that inspired you guys to upvote this thread, so we can target our efforts there.

(There's no real point to work on, say, the quickfix list, if no one derives benefit from having it...)

@jordwalke
Copy link

My support of true NeoVim integration has nothing to do with a particular feature but more so a general philosophy I've gained after trying and watching dozens of vim key bindings implementations miss very basic features. There are many nuanced pieces to vim's interaction language that it is inevitable that you will miss many of them and not even realize it. The amount of time required to integrate vim directly is a fraction of the time required to reimplement even the most basic vim interactions with high accuracy. I have only seen one plugin ever get the basics right and I've tried about twenty different attempted reimplementations thoroughly. It typically only takes two minutes of usage to spot a major defiiciency/bug even for projects that have been invested in for years.

@jordwalke
Copy link

Unless you are going to invest massively in a VSCode vim emulator from scratch, or start with vim-mode-Plus and adapt it to VSCode, I do not have high hopes that the resulting experience will win over any true vim fans. I want to believe. I really do. I've just been burned too many times. I highly recommend embedding NeoVim or vim directly.

@johnfn
Copy link
Member

johnfn commented Jan 16, 2017

@jordwalke Have you used VSCodeVIm? Could you please point out the areas in which it is deficient that bother you while using it?

I mean, if you guys were like "I really desperately need 100% compatible viml evaluation because I use that every day" then that is complex enough that I would consider a NeoVim integration. But if you were just like "it's frustrating that the cursor ends up in the wrong place when I do [random command]," I mean, that's something we can work with.

@justinmk
Copy link

justinmk commented Jan 16, 2017

@johnfn For me personally, it's easier to say what I want from an IDE or higher-level editor, rather than enumerate the things I want from vim.

To be clear, I want:

  • vim (neovim) running in a single tab in VSCode
    • File navigation is done by vim. I don't need VSCode tabs, splits etc.
  • The ability to map vim keybindings to VSCode API functions. Examples:
    • Bind a key from an embedded Nvim instance to invoke some refactoring capability of VSCode (assuming that's exposed as an API)
    • Bind a key from an embedded Nvim instance that invokes VSCode's "go to type" navigator. When I make a choice, it opens the file in the embedded neovim instance. (Neovim API makes this trivial)
  • (optional) some way to invoke the IDE (VSCode) context menu at the cursor position, or do other actions associated with the cursor position

I don't care about VSCode's search/replace, find-in-files, code completion, text effects, or anything involving text-editing.

@johnfn
Copy link
Member

johnfn commented Jan 16, 2017

@jordwalke I know that it seems like NeoVim is probably not as hard as implementing the remainder of those features. My current perspective a NeoVim port is the following:

  1. Actually correctly implementing a NeoVim integration would be a magnitude of work probably equal to or exceeding the amount of work we have already done. Consider:
  • How multiple cursor support should be done with a NeoVim integration
  • Synchronizing registers with VSCode's clipboard
  • Synchronizing buffers with VSCode's files
  • Integrating VSCode snippets with NeoVim
  • Making NeoVim play well with other VSCode plugins (How would NeoVim understand if a different plugin inserted text somewhere, bypassing our keybindings? How would NeoVim understand when to allow VSCode to process keystrokes, vs when it should process keystrokes?)
  • Mapping the contents of NeoVim's various input boxes to somewhere in VSCodeVim
  • Mapping NeoVim's folds to VSCode's folds.

To be clear, I'm not saying it's a bad idea, or that I won't do it. Just that it may be more work than it appears.

  1. I believe that VSCodeVim currently captures the 90%+ use case for most users, and that most of the crucial things it lacks are relatively simple to add. The reason I believe this is because when I look over the most popular issues on our issues page, they generally fall into one of a few categories:
  • Things that VSCode currently doesn't allow us to do
  • Minor bugs
  • Really simple features

Like, if I went to that page and I saw that "Undo Tree History" was our most popular issue with 500 thumbs up, I would probably start considering a NeoVim port. 😉 But that hasn't proven to be the case.

The scariest thing on that page by far is surround.vim, but even if that was a feature of Vim proper, I doubt it would take more than 2-3 days to implement. This is an extreme outlier. The rest of the missing features/bugs are almost certainly 30 minute to an hour jobs at worst.

(Of course, I primarily designed VSCodeVim selfishly for my own use case, and it has 100% of the features that I care about. But that doesn't really help anyone but me, hehe...)

As usual, I am open to changing my mind. I'd need to be convinced that a NeoVim port would be easier (1) than just implementing the missing features to round out the 90% case for the users of VSCodeVim (2).

@jordwalke
Copy link

I love your optimism!

I just tried the cursor position on undo/redo again, and it looks better than most other attempts, but still not "correct". See this example:

Enter:

aaaa
bbbb
cccc
dddd

Visually select from the first b to the last c. Hit c to change the text, and replace the two lines with:

qqqq
qqqq

So that the final text is:

aaaa
qqqq
qqq
dddd

The hit escape, and undo/redo that change repeatedly. The cursor should remain on the first q location as you undo and redo that change. It remains at the end.

I only played with this for a couple minutes, so I could probably find a few more issues if you like.

@jordwalke
Copy link

jordwalke commented Jan 16, 2017

The other thing about all the challenges of integrating vim/neovim you mentioned - is that even if those things take time and don't start off perfect, it's okay. Vim users can switch if only a fraction of the VSCode vim integrations are supported because hey, it's exactly what they're used to and they get a handful of VSCode integrations. Some of the ones you mentioned aren't that hard, others are certainly more difficult, and others might not be that important afterall, when you can create a bridge between the VSCode config/feature and an existing Vim plugin. For example, imagine creating a conversion tool from VSCode snippets to Ultisnips (which is the standard in Vim snippets plugins) and doing that automatically.

If I had such a configuration of Vim, I would even create a custom build of VSCode that strips out the standard editor so that my startup time could be super fast.

@jordwalke
Copy link

To be clear, I do believe you could simply fix all of these issues (and make it more polished (the cursor selection appears visually to be a little flaky (but that's just styling))), but I only wanted to point out that I've seen this become an all-consuming task for developers. Some (like vmp) have been able to pull it off.

@johnfn
Copy link
Member

johnfn commented Jan 23, 2017

I totally understand where you guys are coming from, and you've convinced me that, given unlimited time, I would definitely try my hand at a NeoVim port. Unfortunately, I barely have any time at all right now, so it seems like a more effective use of my resources to spend a few hours getting VSCodeVim from 94% to 97% than the same number of hours getting VSCodeNeoVim from 0% to ???%.

I mean hey, if you guys wanna throw money at me to pursue NeoVim, I won't say no :P As it is though, I'm just trying to pursue the thing that benefits the most people with the limited amount of time that I can spend on this plugin.

@justinmk
Copy link

No problem. My only goal was to answer your question.

@jordwalke
Copy link

Totally understandable and thanks for your work so far. You might also consider taking a look at vmp from Atom. Perhaps you could join forces if you want to go this direction and somehow help make vmp generalizable to more editors.

@octref
Copy link
Contributor

octref commented Feb 21, 2017

First of all, I use VSCodeVim every day and have great respect for @johnfn's work.

I also agree with @jordwalke

There are many nuanced pieces to vim's interaction language that it is inevitable that you will miss many of them and not even realize it.

I've reported 30 issues like that. Some command I'm using 100 times a day like ci} was broken, and get fixed. Now it's broken again. After ci} there should be 2 leading spaces. Now it's like:

function foo() {
|
}

it used to be broken this way:

function foo() {|
}

Others like cit I greatly miss when editing html, but I also understand it will take a lot of time to implement such features in VSCodeVim.

A tremendous amount of man-hour has been put to developing Vim so the interaction between text and actions feels natural and consistent. Despite VSCodeVim's maintainers' great work, it'll still take a lot more effort to get everything right.

Smart Protocol & msgpack API

I briefly looked into making a Vim plugin for VSCode using msgpack API last summer. The old version is like "OK, send NeoVim a width and height, say 80x200, then send NeoVim a command string, NeoVim will send back a 80x200 2D array telling you what's on each position. Now redraw the screen yourself.

That's impractical for integrating to VSCode, for obvious perf reason, but also because VSCode's language features will become much harder to implement on top of that.

What I hoped, however, is NeoVim just be content as being a tool for text navigation & manipulation and leave everything else to VSCode. If instead of sending whole screen, NeoVim can send structured data like:

  • Text diff. Say I press di}, just tell me "line 20-40 is affected, apply this diff to line 20-40 in VSCode, then you get what you get in NeoVim". This is most crucial, as either redrawing whole screen or computing the diff in VSCode side is impratical for perf.
  • Cursor position
  • Current mode
  • View window position, selected region in Visual mode, etc

Then it would be much easier to implement a Vim extension in VSCode, or let VSCodeVim substitute its Vim State Machine with NeoVim.

I remember seeing some progress in NeoVim 0.2 release blog draft by @justinmk but I lost it. Also remember some work was being done in NyaoVim. I was thinking about giving it another try once 0.2 is released.

@justinmk
Copy link

then send NeoVim a command string, NeoVim will send back a 80x200 2D array telling you what's on each position.

Some widgets are being externalized. Currently in Nvim 0.1.7 the popupmenu is externalized, so UIs can render it however they like. We're close to externalizing other widgets like wildmenu, statusline, tabline, and cursorline.

That's impractical for integrating to VSCode, for obvious perf reason,

What perf reason? UIs should (and do) batch the redraws.

Text diff. Say I press di}, just tell me "line 20-40 is affected, apply this diff to line 20-40 in VSCode, then you get what you get in NeoVim".

neovim/neovim#5269

I remember seeing some progress in NeoVim 0.2 release blog draft

https://neovim.io/news/2016/11/

Also remember some work was being done in NyaoVim

Also check out: https://github.com/extr0py/oni

@octref
Copy link
Contributor

octref commented Feb 22, 2017

Thanks. I'm subscribing to #5269, and I'll try again once it's in NeoVim.

Oni looks cool, but I'm worried how far it can go.

@v3ss0n
Copy link

v3ss0n commented Mar 8, 2017

Oni is still quite unstable , can't use for daily work.
Oni should just do a plugin for VSCode , isntead of developing whole ide themselves.

@johnfn
Copy link
Member

johnfn commented Mar 12, 2017

I've been monitoring other attempts at integrating NeoVim, but they appear to be blocked on very simple issues. e.g. dw does not currently work, apparently: neovim/neovim#6166

I will continue to monitor these plugins to see when NeoVim gets into a usable state!

@jordwalke
Copy link

jordwalke commented Mar 12, 2017

That's really strange - I've had no problem with dw in NeoVim. Is it just a particular use of that protocol they're using that causes this?

I think NeoVim will always have bugs. But Vim will also always have bugs, and so will any Vim emulator. I think it's just about how many bugs there are compared to the value the tools add.
So far, the number of bugs in NeoVim compared to the amount of bugs in Vim puts them at about equal, and they both provide somewhere around the same value - except NeoVim has this huge edge (over Vim) that it can connect to amazing IDEs/editors like VSCode.

@johnfn
Copy link
Member

johnfn commented Mar 12, 2017

@jordwalke Yeah, not to say that dw doesn't work in NeoVim - that would be insane - just in extensions that use its remote functionality. I believe it has something to do with the remote msgpack API.

Like I said before, if someone wants to fund me, I'll totally get started on a NeoVim plugin for VSCode today. 😁 Otherwise, I'll have to find some time elsewhere...

@jordwalke
Copy link

jordwalke commented Mar 12, 2017

I'm absolutely certain you would raise a great chunk of change on KickStarter.
Have you heard of other software projects using a similar model?

NeoVim + VSCode might be a nice project for that model because there's clearly a few simple steps along the way.

  • Turn each editor tab into a simple canvas that just uses NeoVim's "dumb" protocol, and integrate it with the standard VSCode hooks for opening files etc.
  • Begin adding "smart" UI protocol features from neovim.
  • Extra polish.
  • Do work to unify Vim plugins with VSCode plugins by refining the MS Language Service Vim Shim and making it robust (which also gives back to all other Vim clients besides VSCode on NeoVim)

@justinmk
Copy link

justinmk commented Mar 12, 2017

The "dw" RPC bug is a high priority.

actualvim recently switched to Neovim, and the result is impressive (if you have Sublime Text 3, try it). It's very similar to the model I tried to describe above.

It's about 1000 lines of code, and it blows away any other "vim mode". Sublime plugins and Vim plugins work.

@johnfn
Copy link
Member

johnfn commented Mar 12, 2017

Ah @justinmk I didn't realize you were one of the main contributors to NeoVim! That explains some things... 😉

@octref
Copy link
Contributor

octref commented Mar 12, 2017

Turn each editor tab into a simple canvas that just uses NeoVim's "dumb" protocol

That alone is impossible as VSCode doesn't allow extensions to touch its DOM.

@3cooper
Copy link

3cooper commented Mar 12, 2017

I've been keeping track of this thread for sometime. I'd support a kickstarter to use neovim as the backend for the plugin.

@tmandry
Copy link

tmandry commented Mar 12, 2017 via email

@clee
Copy link

clee commented May 5, 2017

@johnfn One missing feature that I have started to heavily use in "real" vim (and neovim) is register support, which does not appear to work at all in VSCodeVim.

For anybody who doesn't use it, you can type " to enter register-selection mode, then any of the [0-9a-z] characters (and possibly more, but I've only tested with those) to select a register to store/pull buffers. So, an example would be, "kdd to delete the current line and store it in the k register, and then later you can use "kp to paste whatever you stored there. When you're working with multiple chunks of code, it's really useful.

@johnfn
Copy link
Member

johnfn commented May 5, 2017

@clee Register support 100% works in VSCodeVim, aside from a few edge cases. Please open up an issue describing your problems!

@clee
Copy link

clee commented May 5, 2017

@johnfn When I tried it, it seemed like any non-register yy or dd command killed my register buffers. But I can definitely give it a shot again!

@Chillee
Copy link
Member

Chillee commented May 19, 2017

I've gotten a proof of concept working here! #1725

It should support all text-editing Ex commands.

@Chillee
Copy link
Member

Chillee commented May 22, 2017

As we've started adding neovim integration, please leave all feedback in this issue: #1735

@yetone
Copy link

yetone commented Jun 5, 2017

@hyiltiz
Copy link

hyiltiz commented Feb 11, 2020

Maybe integration with an even smaller and modern codebase like vis would be ideal; nvim supports vim's plugins and vimscripts, which doesn't quite make sense for VSCode.

@justinmk
Copy link

nvim supports vim's plugins and vimscripts, which doesn't quite make sense for VSCode.

Depends on the plugins. Many of them make sense.

In any case, this is a solved problem: https://github.com/asvetliakov/vscode-neovim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests