Git Product home page Git Product logo

pynvim's Introduction

Coverity Scan analysis Packages Debian CI Downloads

Neovim is a project that seeks to aggressively refactor Vim in order to:

See the Introduction wiki page and Roadmap for more information.

Features

See :help nvim-features for the full list, and :help news for noteworthy changes in the latest version!

Install from package

Pre-built packages for Windows, macOS, and Linux are found on the Releases page.

Managed packages are in Homebrew, Debian, Ubuntu, Fedora, Arch Linux, Void Linux, Gentoo, and more!

Install from source

See BUILD.md and supported platforms for details.

The build is CMake-based, but a Makefile is provided as a convenience. After installing the dependencies, run the following command.

make CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make install

To install to a non-default location:

make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_INSTALL_PREFIX=/full/path/
make install

CMake hints for inspecting the build:

  • cmake --build build --target help lists all build targets.
  • build/CMakeCache.txt (or cmake -LAH build/) contains the resolved values of all CMake variables.
  • build/compile_commands.json shows the full compiler invocations for each translation unit.

Transitioning from Vim

See :help nvim-from-vim for instructions.

Project layout

├─ cmake/           CMake utils
├─ cmake.config/    CMake defines
├─ cmake.deps/      subproject to fetch and build dependencies (optional)
├─ runtime/         plugins and docs
├─ src/nvim/        application source code (see src/nvim/README.md)
│  ├─ api/          API subsystem
│  ├─ eval/         Vimscript subsystem
│  ├─ event/        event-loop subsystem
│  ├─ generators/   code generation (pre-compilation)
│  ├─ lib/          generic data structures
│  ├─ lua/          Lua subsystem
│  ├─ msgpack_rpc/  RPC subsystem
│  ├─ os/           low-level platform code
│  └─ tui/          built-in UI
└─ test/            tests (see test/README.md)

License

Neovim contributions since b17d96 are licensed under the Apache 2.0 license, except for contributions copied from Vim (identified by the vim-patch token). See LICENSE for details.

Vim is Charityware.  You can use and copy it as much as you like, but you are
encouraged to make a donation for needy children in Uganda.  Please see the
kcc section of the vim docs or visit the ICCF web site, available at these URLs:

        https://iccf-holland.org/
        https://www.vim.org/iccf/
        https://www.iccf.nl/

You can also sponsor the development of Vim.  Vim sponsors can vote for
features.  The money goes to Uganda anyway.

pynvim's People

Contributors

benekastah avatar bfredl avatar blueyed avatar brcolow avatar btipling avatar cherti avatar diefans avatar elmart avatar equalsraf avatar farisachugthai avatar fgtatsuro avatar frewsxcv avatar fwalch avatar heliomeiralins avatar jamessan avatar justinmk avatar lambdalisue avatar malramsay64 avatar meitham avatar mhinz avatar michel-slm avatar noelevans avatar rgrinberg avatar s0undt3ch avatar samuelqp avatar shougo avatar tarruda avatar timeyyy avatar viccuad avatar wookayin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pynvim's Issues

unhelpful error message on `UpdateRemotePlugins`

Steps to reproduce:
1. Add some error to an existing (remote) python plugin that would stop it from load (syntax error, importing misspelled module etc)
2. run :UpdateRemotePlugins
neovim
This message make it sound like the python host is broken, which is very confusing. It would be better perhaps if the python exception could be printed, then it would be much quicker to find and fix the actual problem. (Those Missing :endif are also wierd, since endif is definitely not missing, but I suppose it is some internal vimscript exception handling glitch)

Current(self) does not work

Don't you wish, python had a compiler :P

client = neovim.connect('/tmp/neovim')
In [57]: client.current.vim
TypeError                                 Traceback (most recent call last)
<ipython-input-57-3b8a3bab0c75> in <module>()
----> 1 client.current.vim

/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/neovim/vim.pyc in current(self)
     62     def current(self):
     63         if not hasattr(self, '_current'):
---> 64             self._current = Current(self)
     65         return self._current
     66

TypeError: object.__new__() takes no parameters

vim.current.range is not supported

I tried to run clang-format.py with python client, but noticed that vim.current.range is not supported yet. Is there any plan on supporting it or any other workarounds?

File "/usr/lib/clang-format/clang-format.py", line 48, in main
lines = '%s:%s' % (vim.current.range.start + 1, vim.current.range.end + 1)
AttributeError: 'Current' object has no attribute 'range'

Buffer Append Graphical Oddity

Hello, I was investigating porting the vim-plug python installer to neovim for a fallback. I've made it work on neovim & vim but there is an odd buffer difference. I've made a gif to demonstrate, you can see that the entries jump up & down a level at a time randomly. This doesn't happen with vim. You can see expected behaviour gif at https://github.com/junegunn/vim-plug .

To reproduce:

  1. Clone my fork of vim-plug git clone -b nvim_py https://github.com/starcraftman/vim-plug .Note: I've hard disabled neovim & ruby on this branch to ensure python executed.
  2. Replace normal plug.vim with my fork.
  3. Use any config of vim-plug with nvim, for example: https://raw.githubusercontent.com/starcraftman/.my_scripts/master/dot_files/.vimrc

Not a high priority, but definitely jarring.

Edit: So you don't have to search the big file, the code manipulating the buffer: https://github.com/starcraftman/vim-plug/blob/nvim_py/plug.vim#L1065-L1128

Error detected while processing "nvim/runtime/autoload/provider/python.vim"

Everytime I try to launch neovim with python support I receive this error:

Error detected while processing /usr/local/Cellar/neovim/HEAD/share/nvim/runtime/autoload/provider/python.vim:
line   14:
E117: Unknown function: remote#host#RegisterClone
line   15:
E117: Unknown function: remote#host#RegisterPlugin

I read this post about how it was having issues with virtualenv.
post >> #16

So, I uninstalled virtualenv. But I still have same issue.
Vim does launch; only without python support.

nvim --version
NVIM 0.0.0-alpha+201412041032 (compiled Dec  4 2014 21:18:39)
Commit: 45ae6eadfd3184b860ac19bd2661e1338c4efc89
Build type: RelWithDebInfo
Compilation: /usr/local/Library/ENV/4.3/clang -Wconversion -O2 -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/tmp/neovim-JJDRaW/build/config -I/tmp/neovim-JJDRaW/src -I/tmp/neovim-JJDRaW/.deps/usr/include -I/tmp/neovim-JJDRaW/.deps/usr/include -I/tmp/neovim-JJDRaW/.deps/usr/include/luajit-2.0 -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-JJDRaW/build/src/nvim/auto -I/tmp/neovim-JJDRaW/build/include
Compiled by [email protected]  Features included (+) or not (-):
+acl             +farsi           -mouse_gpm       -tag_any_white
+arabic          +file_in_path    +mouse_netterm   +terminfo
+autocmd         +find_in_path    +mouse_sgr       +termresponse
-browse          +float           -mouse_sysmouse  +textobjects
+byte_offset     +folding         +mouse_urxvt     +title
+cindent         -footer          +mouse_xterm     -toolbar
-clipboard       +fork()          +multi_byte      +user_commands
+cmdline_compl   +gettext         +multi_lang      +vertsplit
+cmdline_hist    +iconv           +path_extra      +virtualedit
+cmdline_info    +insert_expand   +persistent_undo +visual
+comments        +jumplist        +postscript      +visualextra
+conceal         +keymap          +printer         +viminfo
+cscope          +langmap         +profile         +vreplace
+cursorbind      +libcall         +quickfix        +wildignore
+cursorshape     +linebreak       +reltime         +wildmenu
+dialog_con      +lispindent      +rightleft       +windows
+diff            +listcmds        +scrollbind      +writebackup
+digraphs        +localmap        +signs           -X11
-dnd             +menu            +smartindent     -xfontset
-ebcdic          +mksession       +startuptime     -xsmp
-emacs_tags      +modify_fname    +statusline      -xterm_clipboard
+eval            +mouse           +syntax
+ex_extra        -mouseshape      +tag_binary
+extra_search    +mouse_dec       +tag_old_static
   system vimrc file: "$VIM/nvimrc"
     user vimrc file: "$HOME/.nvimrc"
 2nd user vimrc file: "~/.nvim/nvimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD/share/nvim"

autocmd decorator pattern defaults to `None`

It probably should default to * instead of None because if you don't supply a pattern nvim starts erring out. None is just a not a valid pattern and in fact the pattern registered with the host is * but the lookup name has None in it, for example on cursor move this is how nvim looks for a handler:

"/Users/bjorn/.nvim/rplugin/python/floobits.py:autocmd:CursorMoved:*" 

This is how the handler is registered in f._nvim_rpc_method_name:

"/Users/bjorn/.nvim/rplugin/python/floobits.py:autocmd:CursorMoved:None"

Which is not a valid handler lookup.

Window objects cannot be compared to each other

In Vim I would expect the following print True:

python import vim; print vim.windows[int(vim.eval('winnr()')) - 1] is vim.current.window

. But in NeoVim I can neither use the above code nor compare window.number attribute. This attribute is present at least since vim-7.0.112. Tabpage objects are missing this attribute as well.

Traceback is not displayed

If you run into error in Vim when using :python/pyeval you will see full Python traceback. In NeoVim you just see the error class and error message.

Change cursor shape in insert mode

I haven't built this client in a while, but I assume it always uses a block-style cursor as in terminals. It would be nice to use a line-style cursor when in insert mode, similar to MacVim and gVim. This client uses a GtkDrawingArea, and my own Neovim GUI uses a VteTerminal. Would this be achievable if we had Neovim control a GtkTextView instead, or is there another way to do it?

Incorrect rendering in pynvim with Terminus 12 font

I changed font from Monospace 13 to Terminus 12, and after that, pynvim rendering started to produce some artefacts. Here is how it looks:

shot-002

I guess this is related to different font character square shape.

I know, that there are plans to rewrite GTK UI rendering to C, but still, maybe this will be useful to know about this bug.

Implement stream without pyuv

If the stream interface required by the Client class is implemented without pyuv(which depends on the CPython API), this library can be used by other python implementations(ironpython, jython, pypy...) without any changes.

pydo/python_do_range incompatibilities

Testing Neovim python support I came across a couple of Vim incompatibilities. Bottom line seems to be that Neovim converts every :pydo result to string while Vim does not. For example this

:pydo ()

returns None, and in Vim causes no changes to the buffer. But in Neovim it changes all lines to None.

For other datatype e.g. integers Vim raises an error, for

:pydo return 42
TypeError: bad argument type for built-in operation

The culprit seems to be the str conversion in python_do_range().

                result = str(function(line, linenr))
                if result:
                    lines[i] = result

A somewhat related question is should lines[i] be given an str object(result) or result.encode('utf8')

Vimdoc suggests that only strings (unicode also works) are accepted as results to pydo

:[range]pydo {body} Execute Python function "def _vim_pydo(line, linenr):
            {body}" for each line in the [range], with the
            function arguments being set to the text of each line
            in turn, without a trailing <EOL>, and the current
            line number. The function should return a string or
            None. If a string is returned, it becomes the text of
            the line in the current turn. The default for [range]
            is the whole file: "1,$".

My proposed fix for this would be to check the return type for basestr and only change those lines, I might give it a shot later if I get the time.

python-client imports from current working directory

Say I have a plugin at ~/.nvim/pythonx/neovim_thing.py and it imports ~/.nvim/pythonx/foo.py. Assuming my current working directory is ~/dev/foo/, if I start nvim and there happens to be a ~/dev/foo/foo.py there this file is imported by my plugin instead of ~/.nvim/pythonx/foo.py which breaks the plugin.

pyuv 1.0.2 changed API for Process.spawn

pyuv==1.0.2 changed its API a bit...

Traceback (most recent call last):
  File "/usr/local/bin/pynvim", line 9, in <module>
    load_entry_point('neovim==0.0.27', 'console_scripts', 'pynvim')()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/neovim/ui/cli.py", line 60, in main
    nvim = attach('child', argv=nvim_argv)
  File "/usr/local/lib/python2.7/dist-packages/neovim/__init__.py", line 88, in attach
    child_session(argv) if session_type == 'child' else
  File "/usr/local/lib/python2.7/dist-packages/neovim/msgpack_rpc/__init__.py", line 41, in child_session
    return session('child', argv)
  File "/usr/local/lib/python2.7/dist-packages/neovim/msgpack_rpc/__init__.py", line 17, in session
    loop = EventLoop(transport_type, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/neovim/msgpack_rpc/event_loop/base.py", line 88, in __init__
    getattr(self, '_connect_{0}'.format(transport_type))(*args)
  File "/usr/local/lib/python2.7/dist-packages/neovim/msgpack_rpc/event_loop/uv.py", line 81, in _connect_child
    stdio=(stdin, stdout, stderr,))
TypeError: Required argument 'loop' (pos 1) not found

Ovewriting a buffer is not working properly

In an empty document.

client = neovim.connect('/tmp/neovim')
client.buffers[0][:] = ["Blub", "Blah", "Fasel"]

Gives only "blub\nblah". When the last line is run again the "Fasel" appears too.

os.fchdir not available in Windows

os.fchdir imported in neovim/api/nvim.py is not available in Windows. import neovim fails in Windows

  File "c:\Python27\lib\site-packages\neovim\api\nvim.py", line 18, in <module>
    os_fchdir = os.fchdir
AttributeError: 'module' object has no attribute 'fchdir'

I couldn't find any reference to the method in other parts of the code, is it really necessary?

Buffer gets/sets invalid indexes should raise IndexError

From #48. The following examples raise IndexError in Vim but not in Neovim

vim.current.buffer[:] = ['line1']
vim.current.buffer[42] # returns 'line1'
vim.current.buffer[33] # Invalid line index

I'm not sure what is the correct behaviour for all cases. Vim seems permissive about this when using slices but not indexes. From python it would be desirable to have IndexError but it seems the Neovim API functions dont raise an error for these cases.

Can't kill next_message() with SIGINT or Ctrl-C

While neovim.client.Vim.next_message() is working, I'm unable to kill it using Ctrl-C or kill -INT. If I hit Ctrl-C in the same terminal, I just see "^C" appear on the terminal and nothing else happens.

This makes it hard to troubleshoot problems that cause the python client to get stuck because you can't get a traceback and have no idea which code it's stuck on and under what circumstances.

Buffer modification events

Hi all,

Is there a way for clients to detect/subscribe to when the current buffer has been modified ?

There is nvim.subscribe method but I can't find a list of events to subscribe to ?

Cheers

Doesn't work on Arch Linux

Sorry for the blurry titel, but I don't know how to describe it better. I have a running Arch Linux version and installed the packages neovim-git and python2-neovim as mentioned in the install wiki page. Neovim version is NVIM 0.0.0-alpha+201504081227.

I already described my problem at the python2-neovim AUR package and here is a summary:
I have both python and python2 installed on my system. So I set let g:python_host_prog='/usr/bin/python2' in my .nvimrc to force it to python2. When I spawn a python REPL and load the neovim packages this works fine and I can control a nvim instance from python, see neovim/neovim#2258 [or in the README of this github project]. But when installing YouCompleteMe, it prints still "YouCompleteMe unavailable: requires Vim compiled with Python 2.x support". When I try to do :python print "hello" in a nvim instance, I get E117: Unknown function: provider#python#Call. I also tried to upgrade the neovim python package with pip2 which gives me version 0.0.32, but with the same outcome.

I symlinked ~/bin/python to /usr/bin/python2 so other commands use this as the python executable. I tried to remove it, in case it brakes something, but got the same problems without it.

Provider for method "python_execute" is not available

I wanted to try if neovim is now able to work for me fulltime, but apparently something is still problematic. I compiled and installed from master and run sudo pip install git+https://github.com/neovim/python-client.git#egg=neovim. When loading UltiSnips though I see the error in the title.

Also, was has happened to has('neovim')? I have this in my vimrc:

 if !has('neovim')
   set cryptmethod=blowfish
endif

which stopped working but has worked before.

test_name in test_buffer.py fails on OS X

On OS X /var is a symlink to /private/var so the check:

new_name = vim.eval('tempname()')
vim.current.buffer.name = new_name
eq(vim.current.buffer.name, new_name)

fails with:

AssertionError: '/private/var/folders/07/jtkf72yn4_587wv8zc7ntg6h0000gn/T/nvim8XLj27/0' != '/var/folders/07/jtkf72yn4_587wv8zc7ntg6h0000gn/T/nvim8XLj27/0'

Although the file was name was changed the test fails because the symlink path is being used in one case and the full path in the other case.

Multiple plugins cannot register the same notification handler.

The current python-client architecture in neovim/plugin/host.py has a single map for self._notification_handlers and self._request_handlers. If a previous plugin for example has registered an event for keypress a subsequent plugin cannot also register a handler for the same event. Either the _request_handlers needs to be an array and the checks to see if these events already exist go away or the maps must be per plugin.

python-client requires an empty py file in case of a plugin package

If I have a directory that exports the @neovim.plugin class in an __init__.py python-client doesn't doesn't see the plugin unless there's also an empty python file with the same name. This is because we only check for if ext == '.py': and not directories in neovim/__init__.py

The plugin will actually though load the plugin from the package directory instead of the empty python file because of how find_module and imp.load_module work in neovim/plugin/host.py.

Our floobits plugin is too complicated and shares code with other plugins and so cannot be contained in a single python file.

In addition when there is a problem with a plugin package the error reported (only with code in #62 because error logging has problems that pr fixes) reports the empty python file as the cause of the problem which is incorrect. This is because neovim/plugin/host.py reports the path for the empty python file and not the path returned by find_module.

I plan on issuing patches for these problems, but I'm blocked by #62 which is still outstanding. I may just go ahead and start adding pull requests blocked by other pull requests.

Trouble with subprocess stdio

The following crashes the python host: (which is an improvment, som time ago this crashed nvim :p )

python from subprocess import call
python call(["echo","S"])

This because subprocesses inherit stdout and will inject output directly into the binary msgpack stream. stdout was written to by a helper process inside a library, so at first I couldn't understand why on earth nvim complained about a malformatted message that the client obviously never sent. One could argue that a correcty behaving plugin/library should redirect stdio itself (subprocess makes this easy), but the host should error out a better way than just crashing.

Cannot run python remote plugin example 'limit.py'

nvim :version

NVIM 0.0.0-alpha+201504030905 (compiled Apr  4 2015 01:43:05)
Commit: 94153ab975401572ea6942b4fba8dcfba53ceecc
Build type: Release
Compilation: /usr/bin/cc -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -DINCLUDE_GENERATED_DECLARAT
IONS -DHAVE_CONFIG_H -I/home/syswow/Omega/Repos/BuildApps/neovim/build/config -I/home/syswow/Omega/Repos/BuildApps/neovim/src -I/home/syswow/Omega/Repos/BuildApps/neovim/.deps/usr/include -I/hom
e/syswow/Omega/Repos/BuildApps/neovim/.deps/usr/include -I/home/syswow/Omega/Repos/BuildApps/neovim/.deps/usr/include/luajit-2.0 -I/home/syswow/Omega/Repos/BuildApps/neovim/.deps/usr/include -I/
home/syswow/Omega/Repos/BuildApps/neovim/.deps/usr/include -I/home/syswow/Omega/Repos/BuildApps/neovim/.deps/usr/include -I/usr/include -I/home/syswow/Omega/Repos/BuildApps/neovim/build/src/nvim
/auto -I/home/syswow/Omega/Repos/BuildApps/neovim/build/include
Compiled by syswow@omega

Optional features included (+) or not (-): +acl  +iconv
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/nvimrc"
     user vimrc file: "~/.nvimrc"
 2nd user vimrc file: "~/.nvim/nvimrc"
      user exrc file: "~/.exrc"
  fall-back for $VIM: "/home/syswow/Omega/Apps/neovim/share/nvim"

python-client

syswow@omega:~$ pip show neovim

---
Name: neovim
Version: 0.0.32
Location: /usr/local/lib/python2.7/dist-packages
Requires: click, msgpack-python, trollius, greenlet

Error:

Error detected while processing function <SNR>4_UpdateRemotePlugins..<SNR>4_RegistrationCommands..remote#host#Require..<SNR>4_RequirePythonHost:
line   66:
E605: Exception not caught: Failed to load python host. Try upgrading the Neovim python module with 'pip install --upgrade neovim' or see ':help nvim-python'.
Error detected while processing function <SNR>4_UpdateRemotePlugins..<SNR>4_RegistrationCommands..remote#host#Require:
line    6:
E171: Missing :endif
Error detected while processing function <SNR>4_UpdateRemotePlugins:
line    5:
E171: Missing :endif

limit.py

import neovim

@neovim.plugin
class Limit(object):
    def __init__(self, vim):
        self.vim = vim
        self.calls = 0

    @neovim.command('Cmd', range='', nargs='*', sync=True)
    def command_handler(self, args, range):
        self._increment_calls()
        self.vim.current.line = (
            'Command: Called %d times, args: %s, range: %s' % (self.calls,
                                                               args,
                                                               range))

    @neovim.autocmd('BufEnter', pattern='*.py', eval='expand("<afile>")',
                    sync=True)
    def autocmd_handler(self, filename):
        self._increment_calls()
        self.vim.current.line = (
            'Autocmd: Called %s times, file: %s' % (self.calls, filename))

    @neovim.function('Func')
    def function_handler(self, args):
        self._increment_calls()
        self.vim.current.line = (
            'Function: Called %d times, args: %s' % (self.calls, args))

    def _increment_calls(self):
        if self.calls == 5:
            raise Exception('Too many calls!')
        self.calls += 1

Client module not found

When trying to import neovim, it throws the following error message:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'client'

Running python 3 packages from Arch Linux official repo.

Code is run not in __main__ module

Consider the following script:

python import sys; print sys.modules['__main__'].__dict__ is globals()

. In Vim this code prints True, in NeoVim it prints False. Using import __main__ can be (and is actually used in powerline) to put some variable into global environment without requiring to specify globals() dictionary, so that code that user needs to run to use powerline is simply

python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup

which is simple and easy.

replace_termcodes with DecodeHook fails on non-ASCII input

vim.replace_termcodes seems to be broken when used on a vim client with a neovim.DecodeHook installed. It seems like it might be trying to double-decode input or something.

An example from maktaba:

>>> vim.replace_termcodes(u":let g:weirdpath = maktaba#path#Join([g:repo, 'weird¬p…l✓u↓g⏎i‽n'])<CR>")
b":let g:weirdpath = maktaba#path#Join([g:repo, 'weird\xc2\xacp\xe2\x80\xfeX\xa6l\xe2\x9c\x93u\xe2\x86\x93g\xe2\x8f\x8ei\xe2\x80\xfeX\xbdn'])\r"
>>> vim.with_hook(neovim.DecodeHook()).replace_termcodes(u":let g:weirdpath = maktaba#path#Join([g:repo, 'weird¬p…l✓u↓g⏎i‽n'])<CR>")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dbarnett/.local/lib/python3.4/site-packages/neovim/api/nvim.py", line 168, in replace_termcodes
    from_part, do_lt, special)
  File "/home/dbarnett/.local/lib/python3.4/site-packages/neovim/api/common.py", line 213, in request
    'out-request')
  File "/home/dbarnett/.local/lib/python3.4/site-packages/neovim/api/common.py", line 240, in walk
    return fn(obj, *args)
  File "/home/dbarnett/.local/lib/python3.4/site-packages/neovim/api/common.py", line 148, in <lambda>
    return lambda o, s, m, k: f1(f2(o, s, m, k), s, m, k)
  File "/home/dbarnett/.local/lib/python3.4/site-packages/neovim/api/common.py", line 170, in _decode_if_bytes
    return obj.decode(self.encoding, errors=self.encoding_errors)
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 55-56: invalid continuation byte

I tried some other variations of passing pre-encoded bytes and such, and couldn't find anything that wouldn't blow up.

It would also be good to get unicode strings out at least when passing unicode strings in.

Cannot start gtk GUI

When started as python -m neovim.ui.cli -gn, I got lots of Attribute errror, complaining self._screen is None. It seems that no resize event is not received at the beginning, (which also happened in my Atom Shell UI).

If started as python -m neovim.ui.cli -gn -c <path>, I got an error TypeError: Couldn't find foreign struct converter for 'cairo.Context'

pynvim broken with Python 3?

While running pynvim from Python 2 seems to work fine, the one from Python 3 only shows a blank screen. All dependencies should be installed (click, cairo, gobject).

next_message(timeout) gives NameError

I'm trying to integrate the nvim-client event handling with the event loop of IPython (for interactive testing/introspection of plugins). The simplest way would be to call next_message with a very low time-out, but when I do

vim.next_message(timeout=0) # or any int value

it gets the error

NameError: global name 'TimeoutError' is not defined

TimeoutError seems unfortunably not be defined in python2.x. Perhaps define neovim.TimeoutError when running in python2?

Also, the vim object could perhaps expose the fd of the underlying connection, that way the client could easily be efficiently integrated into any existing eventloop (by registering vim.next_message as callback for incoming data on the fd). (At least for my case that would be simpler than running the neovim eventloop in a separate thread)

Segmentation fault with vim-fugitive/github-issues.vim

When using vim-fugitive with :Gcommit or github-issues.vim with :Gissues it produces the output pasted below, leading into a segfault.

The problem also appears with github-issues.vim disabled, and the plugins work fine in Vim 7.4.

Neovim version compiled today (see paste below), python-client 0.0.26:

>pip freeze | grep neovim
neovim==0.0.26

Neovim error output, every second 'Press Enter[...]' line removed:

Exception in thread Thread-5:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 813, in __bootstrap_inner
    self.run()
  File "<string>", line 317, in run
  File "<string>", line 112, in getUpstreamRepoURI
  File "<string>", line 32, in getRepoURI
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/api/nvim.py", line 239, in buffer
    return self._session.request('vim_get_current_buffer')
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/api/common.py", line 220, in request
    return walk(self._in, self._session.request(name, *args), self, name,
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/msgpack_rpc/session.py", line 72, in request
    err, rv = self._yielding_request(method, args)
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/msgpack_rpc/session.py", line 133, in _yielding_request
    return parent.switch()
AttributeError: 'NoneType' object has no attribute 'switch'
Press ENTER or type command to continue
Press ENTER or type command to continue[1]    17965 segmentation fault (core dumped)  NVIM_PYTHON_LOG_LEVEL='INFO' NVIM_PYTHON_LOG_FILE='neovim.log' nvim

Neovim logfile set to info:

2015-02-03 13:38:54,030 [WARNING @ async_session.py:_on_message:69] 15024 - Traceback (most recent call last):
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/msgpack_rpc/async_session.py", line 66, in _on_message
    self._handlers.get(msg[0], self._on_invalid_message)(msg)
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/msgpack_rpc/async_session.py", line 87, in _on_response
    self._pending_requests.pop(msg[1])(msg[2], msg[3])
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/msgpack_rpc/session.py", line 129, in response_cb
    gr.switch(err, rv)
error: cannot switch to a different thread

Neovim version:

>nvim --version
NVIM 0.0.0-alpha+201502021723 (compiled Feb  3 2015 12:51:44)
Commit: 7751cd21f5ae8952f578a0ccd892e32c95a4ae8a
Build type: Debug
Compilation: /bin/cc -Wconversion -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/home/ntnn/prog/neovim/build/config -I/home/ntnn/prog/neovim/src -I/home/ntnn/prog/neovim/.deps/usr/include -I/home/ntnn/prog/neovim/.deps/usr/include -I/home/ntnn/prog/neovim/.deps/usr/include/luajit-2.0 -I/usr/include -I/home/ntnn/prog/neovim/build/src/nvim/auto -I/home/ntnn/prog/neovim/build/include
Compiled by root@Persephone  Features included (+) or not (-):
+acl             +extra_search    +mouse_dec       +tag_binary
+arabic          +farsi           -mouse_gpm       +tag_old_static
+autocmd         +file_in_path    +mouse_netterm   -tag_any_white
-browse          +find_in_path    +mouse_sgr       +terminfo
+byte_offset     +folding         -mouse_sysmouse  +termresponse
+cindent         -footer          +mouse_urxvt     +textobjects
-clipboard       +fork()          +mouse_xterm     +title
+cmdline_compl   +gettext         +multi_byte      -toolbar
+cmdline_hist    +iconv           +multi_lang      +user_commands
+cmdline_info    +insert_expand   +path_extra      +vertsplit
+comments        +jumplist        +persistent_undo +virtualedit
+conceal         +keymap          +postscript      +visual
+cscope          +langmap         +printer         +visualextra
+cursorbind      +libcall         +profile         +viminfo
+cursorshape     +linebreak       +quickfix        +vreplace
+dialog_con      +lispindent      +reltime         +wildignore
+diff            +listcmds        +rightleft       +wildmenu
+digraphs        +localmap        +scrollbind      +windows
-dnd             +menu            +signs           +writebackup
-ebcdic          +mksession       +smartindent     -X11
-emacs_tags      +modify_fname    +startuptime     -xfontset
+eval            +mouse           +statusline      -xsmp
+ex_extra        -mouseshape      +syntax          -xterm_clipboard
   system vimrc file: "$VIM/nvimrc"
     user vimrc file: "$HOME/.nvimrc"
 2nd user vimrc file: "~/.nvim/nvimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/nvim"

Maybe this helps too:

Output of attached python-repl:

>>> nvim.command(':Gcommit')
INFO:neovim.msgpack_rpc.session:'Received error: [0, 'Vim(return):Invalid channel "1"']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/api/nvim.py", line 121, in command
    return self._session.request('vim_command', string)
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/api/common.py", line 220, in request
    return walk(self._in, self._session.request(name, *args), self, name,
  File "/home/ntnn/.local/lib/python2.7/site-packages/neovim/msgpack_rpc/session.py", line 77, in request
    raise self.error_wrapper(err)
neovim.api.nvim.NvimError: Vim(return):Invalid channel "1"

eval returns byte strings in python 3

python-client generally works in python 3, but returns byte strings from eval(). For instance,

conn.eval("['x', '¬']")

returns

[b'x', b'\xc2\xac']

Vim itself understands non-ASCII strings, so python-client should, too. This is not something that's trivial to work around in the calling code because recursive data structures can have strings deeply embedded. You'd have to recursively traverse the returned data structures and return an equivalent structure with all strings decoded.

neovim python-client when using in a virtualenv

This is not a bug, but a documentation suggestion.

I tried out neovim with YouCompleteMe and all my python plugins (python-mode, virtualenv) enabled. Everything works fine and all vim plugins are loaded.

But when someone works within a virtualenv the thing is breaking. My solution to this is to install the python client into a virtualenv itself and setting PYTHONPATH=~/.virtualenvs/neovim/lib/python2.7/site-packages

First command to neovim doesn't work

The example taken from here that is: http://neovim.org/doc/user/msgpack_rpc.html#msgpack-rpc

Steps to reproduce:

  1. Turn on neovim

  2. Connect with python

Here's what I'm running ipython:

In [1]: from neovim import attach
In [2]: nvim = attach('socket', path='/var/folders/1y/41fddxzj4sbdkwxlq_y92zsw0000gn/T/nvimEE9Hyn/0')
In [3]: nvim.command('echo "testing"')
  1. Now the last command blocks indefinitely.

  2. Go to neovim

  3. Press key and the python command will unblock

  4. Subsequent commands sent with python work and execute immediately.

python-client could do with a "ready" event of some kind.

I have been burned a bit by trying to do too much in the @neovim.plugin class's __init__ function. If I start a thread loop it locks up during a :UpdateRemotePlugins call. If I lock up the vim ui with a prompt during __init__ and events come in there are python errors because handlers haven't finished registering. It would be nice if there were some kind of ready event specific to the python-client to let me know when I could start things off. Right now I have changed our plugin to not attempt to do anything until the user runs one of our functions, but if I wanted to automatically start some kind of async process it's not clear to me when I should do that.

I would also recommend if such a thing as a ready event is created, that this event doesn't fire in the case of the :UpdateRemotePlugins function which I think seems to create instances of the plugins. I'm not sure it does actually, I see RegistrationCommands creates a host clone, and that might be creating instances of the plugin in cases I didn't expect it to.

Using vim.eval to eval a variable value will fail the first time.

Steps to reproduce:

Create a plugin like so and name it foo.py or whatever you want to call it:

import neovim

@neovim.plugin
class Foo(object):
    def __init__(self, vim):
        self.vim = vim

    @neovim.command('TestFoo', sync=True, nargs=1)
    def foo_test(self, args):
        foovar = self.vim.eval(args[0])
        self.vim.command("echom 'result %s'" % foovar)

Update plugins:

nvim -c 'UpdateRemotePlugins' -c 'q'

Start neovim.

$  nvim

Set a variable on the input prompt:

:let foo = 'bar'

Verify it is set:

:echom foo

That should echo "bar" to :messages

Now try the plugin:

:TestFoo foo

This will show an error like so:

Error detected while processing function remote#define#CommandBootstrap:
line    5:
NvimError('Vim:E121: Undefined variable: foo',)

Try it again.

:TestFoo foo

See that it works:

result bar

I have followed vim_eval.c all the way down to eval7 and find_var with lldb and it's definitely trying to find the variable, but it just doesn't find it, it's not where it's looking. It creates a hash from the variable name, which looks like it's just an integer and sees if it's in a hash table and it isn't there. nvim can find it from the input prompt, but the plugin can't until after the first failure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.