Powerline: Add support for NeoVim

Created on 27 Jan 2015  ·  23Comments  ·  Source: powerline/powerline

I understand that this may not be immediately feasible due to the still-unstable nature of NeoVim, but I'd like to make the request anyway.

First, powerline fails when it tries to access the bindeval method which NeoVim does not support. I attempted to do some initial debugging, and discovered that Powerline relies on Vim's 7.4 Python API when it detects a version greater than 703. NeoVim reports as version 704 right now, but has not added support for Vim's 7.4 Python API (see discussion on neovim/neovim#1898), which apparently includes the bindeval method. After attempting to work around this by modifying powerline's version checking, I'm still seeing the following issue:

Error detected while processing function PowerlinePyeval..provider#python#Call:
line    1:
NameError("name 'powerline' is not defined",)

I'm not sure what's going on here that it cannot find "powerline". Executing :py import sys; print sys.path seems to indicate that the right paths can be found, and I can execute :py import powerline without complaint.

For the record, I'm running the latest NeoVim (NVIM 0.0.0-alpha+201501262108) on Mac OS 10.10, with Python 2.7 installed through homebrew, and powerline 2.0 installed through pip.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

cvim enhancement

Most helpful comment

Could you just stop spamming this bug report with useless "+1". Just use the "reaction" github feature on the first post.

All 23 comments

@abstiles powerline that is not found has nothing to do with powerline module. It is an instance of powerline.vim.VimPowerline class that is expected to live in __main__ module. If

python foo = 1

will add variable foo to something _other_ then __main__ module bindings will not work. But in any case you should not try to use bindings for old Vim because the very reason pyeval was added in first place is that other ways around are fucking slow (well, they are not that slow for powerline because I wrote them for transmitting files a few KiBs to a few MiBs in one turn and powerline was never close to that data rate, but there is still much overhead for dumping strings). NeoVim is using msgpack over sockets and this is going to be way slower. I was not going to add NeoVim support any time soon because this needs a major rewrite of Vim bindings since

&statusline
   \/
pyeval
   \/
…
   \/
segment function
   \/
vim.eval
   \/
result
   \/
displayed statusline

is fine, but

&statusline
  \/
:python          --------msgpack-rpc------>  … > segment function
                                                \/
vim_eval         <-------msgpack-rpc-------  vim.eval
  \/
eval result (C)  --------msgpack-rpc------>  result (Python)
                                                \/
displayed stl    <-------msgpack-rpc-------  segment function result

(in all cases: repeated for each segment function which bothers to use some interface with Vim) is not and I do not need tests to say that this would not work.

The only alternative approach I can see is

startup notification  -------msgpack-rpc------->  powerline
                                                     \/
                                                     …
                                                     \/
                                                  segment.startup
                                                     \/
&statusline function  <------msgpack-rpc--------  list of things needed from NeoVim
  \/
computed list of things ----------msgpack-rpc-----------------------------+
                                                                          |
&statusline                                                               |
  \/                                                                      |
:python (+computed list of things)  -------msgpack-rpc------->  renderer  |    ----->  … > segment function
                                                                   \/     \/                    \/
displayed statusline                <------msgpack-rpc--------  cached result                result
                                                                                                |
&statusline                                                               +---------------------+
  \/                                                                      |
:python (+computed list of things)  -------msgpack-rpc------->  renderer  |    ----->  … > segment function
                                                                   \/     \/                    \/
displayed statusline                <------msgpack-rpc--------  cached result                result
                                                                                                |
…

, but as you see there will be a lag between when things needed from NeoVim are computed and when they are displayed. In this case it may though can appear that I can afford waiting until computed things are processed, so there will be no lag, but I am not sure. Rewrite is needed in any case.

There is also an alternative where statusline function constantly computes things and sends them to powerline and powerline constantly sends back an updates to &statusline when they are ready, but this is no different regarding how segment functions need to be rewritten and this variant is rather not compatible with Vim.

Some things in a list may be replaced with NeoVim events which is a bit faster.

Is there not some way to at least get this working, even if it doesn't perform optimally? I tried bumping the version conditionals from 703 to 704, but all that got me was:

Error detected while processing function provider#python#Call:
line    1:
NameError("name 'powerline' is not defined",)

Instead of:

Error detected while processing function provider#python#Call:
line    1:
AttributeError("'Nvim' object has no attribute 'bindeval'",)
NameError("name 'powerline_setup' is not defined",)
NameError("name 'powerline_setup' is not defined",)

If I add a test for hasattr(vim, 'bindeval') before the calls to bindeval that don't have any, I just get:

Error detected while processing function provider#python#Call:
line    1:
NvimError('Key not found',)

So, I'm wondering exactly what features are broken and/or whether <=703 do currently work, and if so, how to properly force Powerline to use the older bindings with NeoVim.

NeoVim does _not_ support full Python API even from version 7.0. There is a patch for powerline which I used to get it working to have some performance measurements and it is more then just adding a few ifs. I.e. see neovim/python-client#85, neovim/python-client#84, neovim/python-client#87.

Oh right, ugly. Thanks for the links.

I've noticed no new activity on this issue or the related Neovim issues. Are there simply irreconcilable differences between Neovim and Powerline such that there are no plans for Powerline to support Neovim?

I'd like to know if you see any hope of resolving the problems here, or if I should give up my hope of using Powerline in Neovim.

Might I add my vote for this feature as well?

Is there a good alternative to powerline that works with neovim?

Nice! That works! Thanks @aarobc!

Very hard to choose between neovim and powerline...
+∞

@code-hunger vim-airline offers similar functionality to powerline and works fine with neovim.

@kierun thanks, it seems to do quite the same job.

The only downside with airline is you have to configure it apart from powerline and if you already use powerline in bash, weechat/irssi, tmux, etc... it is just a little annoying to do that.

@Goddard Take a look at these:

https://github.com/edkolev/promptline.vim
https://github.com/edkolev/tmuxline.vim

Above projects generate scripts for bash, zsh, fish and tmux and the generated script is native code that doesn't call any external program like python.

I'm making the switch to nvim, and would love to see Powerline support for it.

Could you just stop spamming this bug report with useless "+1". Just use the "reaction" github feature on the first post.

Likewise, you can go back and delete your "+1" comments to make this issue easier to follow.

So it's 2019 (almost 2020) now, and I am still getting this error. Is there a workaround to getting Powerline working in nvim, or is it vim exclusive?

@vegerot I gave up ages ago and started using vim-airline which works out of the box and can be installed with dein or other plugin managers…

5 1/2 years, and still doesn't work at all? Is there an update on the status of this, or the likelihood this will work at some point in the future?

5 1/2 years, and still doesn't work at all? Is there an update on the status of this, or the likelihood this will work at some point in the future?

Sadly, there is no progress towards supporting NeoVim and looking at @ZyX-I original comments on this issue, I'm not very optimistic regarding the future. Perhaps NeoVim changed something regarding its python support in the meantime (which I don't know) so it would make sense to look at this again; if not and if they don't do so, I'm not very optimistic that NeoVim support will be added (at least by me) in the near future, sorry.

Unrelated: I just removed the plethora of “+1” comments to make this issue somewhat more readable.

Is there a way to hide this error at least? In my case i want to have both neovim an vim with powerline.

Is there a way to hide this error at least? In my case i want to have both neovim an vim with powerline.

You can try the following: In your .vimrc, put all powerline-related code in a if !has('nvim') ... endif block.

Was this page helpful?
0 / 5 - 0 ratings