[Python-modules-commits] [python-neovim] 02/08: Import python-neovim_0.2.0.orig.tar.gz

Víctor Cuadrado Juan viccuad-guest at moszumanska.debian.org
Mon Nov 13 17:55:34 UTC 2017


This is an automated email from the git hooks/post-receive script.

viccuad-guest pushed a commit to branch master
in repository python-neovim.

commit db8f54dcbc09d089677ca435b75b915d8cabc47e
Author: Víctor Cuadrado Juan <me at viccuad.me>
Date:   Mon Nov 13 11:10:00 2017 +0100

    Import python-neovim_0.2.0.orig.tar.gz
---
 PKG-INFO                      |  4 ++--
 README.md                     | 46 +++++++++++++++++++++++++++++++++----------
 neovim.egg-info/PKG-INFO      |  4 ++--
 neovim.egg-info/SOURCES.txt   |  1 +
 neovim/__init__.py            | 14 ++++++-------
 neovim/api/buffer.py          |  8 ++++----
 neovim/api/nvim.py            | 11 +++++------
 neovim/msgpack_rpc/session.py |  1 -
 neovim/plugin/decorators.py   | 27 +++++++++++++++++++------
 neovim/plugin/host.py         |  7 +++----
 neovim/version.py             |  5 +++++
 setup.cfg                     |  3 +--
 setup.py                      |  4 ++--
 test/test_buffer.py           |  7 +++++++
 test/test_vim.py              |  7 +++++--
 15 files changed, 101 insertions(+), 48 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index 15b8bfc..cd8c08a 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,11 +1,11 @@
 Metadata-Version: 1.1
 Name: neovim
-Version: 0.1.13
+Version: 0.2.0
 Summary: Python client to neovim
 Home-page: http://github.com/neovim/python-client
 Author: Thiago de Arruda
 Author-email: tpadilha84 at gmail.com
 License: Apache
-Download-URL: https://github.com/neovim/python-client/archive/0.1.13.tar.gz
+Download-URL: https://github.com/neovim/python-client/archive/0.2.0.tar.gz
 Description: UNKNOWN
 Platform: UNKNOWN
diff --git a/README.md b/README.md
index 555f78c..9a72c44 100644
--- a/README.md
+++ b/README.md
@@ -42,26 +42,44 @@ traditional `:python` interface or the new mechanism is used, as discussed
 below.
 
 * `vim.funcs` exposes vimscript functions (both builtin and global user defined
-  functions) as a python namespace. For instance to set the value of the value
-  of a register
-
-    `vim.funcs.setreg('0', ["some", "text"], 'l')`
+  functions) as a python namespace. For instance to set the value of a register
+  ```
+  vim.funcs.setreg('0', ["some", "text"], 'l')
+  ```
+
+* `vim.api` exposes nvim API methods. For instance to call `nvim_strwidth`,
+  ```
+  result = vim.api.strwidth("some text")
+  ```
+  Note the initial `nvim_` is not included. Also, object methods can be called
+  directly on their object,
+  ```
+  buf = vim.current.buffer
+  len = buf.api.line_count()
+  ```
+  calls `nvim_buf_line_count`. Alternatively msgpack requests can be invoked
+  directly,
+  ```
+  result = vim.request("nvim_strwith", "some text")
+  len = vim.request("nvim_buf_line_count", buf)
+  ```
 
 * The API is not thread-safe in general. However, `vim.async_call` allows a
   spawned thread to schedule code to be executed on the main thread. This method
   could also be called from `:python` or a synchronous request handler, to defer
   some execution that shouldn't block nvim.
+  ```
+  :python vim.async_call(myfunc, args...)
 
-    `:python vim.async_call(myfunc, args...)`
-
+  ```
   Note that this code will still block the plugin host if it does long-running
   computations. Intensive computations should be done in a separate thread (or
   process), and `vim.async_call` can be used to send results back to nvim.
 
-* Some methods accept an extra keyword-only argument `async`: `vim.eval`,
-  `vim.command` as well as the `vim.funcs` wrappers. The python host will not
-  wait for nvim to complete the request, which also means that the return value
-  is unavailable.
+* Some methods accept an `async` keyword argument: `vim.eval`, `vim.command`,
+  `vim.request` as well as the `vim.funcs` and `vim.api` wrappers.  When
+  `async=True` is passed the client will not wait for nvim to complete the
+  request (which also means that the return value is unavailable).
 
 #### Remote (new-style) plugins
 
@@ -96,6 +114,14 @@ If `sync=True` is supplied nvim will wait for the handler to finish (this is
 required for function return values), but by default handlers are executed
 asynchronously.
 
+Normally async handlers (`sync=False`, the default) are blocked while a
+synchronous handler is running. This ensures that async handlers can call
+requests without nvim confusing these requests with requests from a synchronous
+handler. To execute an asynchronous handler even when other handlers are
+running, add `allow_nested=True` to the decorator. The handler must then not
+make synchronous nvim requests, but it can make asynchronous requests, i e
+passing `async=True`.
+
 You need to run `:UpdateRemotePlugins` in nvim for changes in the specifications
 to have effect. For details see `:help remote-plugin` in nvim.
 
diff --git a/neovim.egg-info/PKG-INFO b/neovim.egg-info/PKG-INFO
index 15b8bfc..cd8c08a 100644
--- a/neovim.egg-info/PKG-INFO
+++ b/neovim.egg-info/PKG-INFO
@@ -1,11 +1,11 @@
 Metadata-Version: 1.1
 Name: neovim
-Version: 0.1.13
+Version: 0.2.0
 Summary: Python client to neovim
 Home-page: http://github.com/neovim/python-client
 Author: Thiago de Arruda
 Author-email: tpadilha84 at gmail.com
 License: Apache
-Download-URL: https://github.com/neovim/python-client/archive/0.1.13.tar.gz
+Download-URL: https://github.com/neovim/python-client/archive/0.2.0.tar.gz
 Description: UNKNOWN
 Platform: UNKNOWN
diff --git a/neovim.egg-info/SOURCES.txt b/neovim.egg-info/SOURCES.txt
index f841727..57843b8 100644
--- a/neovim.egg-info/SOURCES.txt
+++ b/neovim.egg-info/SOURCES.txt
@@ -6,6 +6,7 @@ setup.py
 neovim/__init__.py
 neovim/compat.py
 neovim/util.py
+neovim/version.py
 neovim.egg-info/PKG-INFO
 neovim.egg-info/SOURCES.txt
 neovim.egg-info/dependency_links.txt
diff --git a/neovim/__init__.py b/neovim/__init__.py
index 010b5b4..b2bbbf0 100644
--- a/neovim/__init__.py
+++ b/neovim/__init__.py
@@ -21,7 +21,7 @@ __all__ = ('tcp_session', 'socket_session', 'stdio_session', 'child_session',
            'shutdown_hook', 'attach', 'setup_logging', 'ErrorResponse')
 
 
-VERSION = Version(major=0, minor=1, patch=13, prerelease="")
+VERSION = Version(major=0, minor=2, patch=0, prerelease='')
 
 
 def start_host(session=None):
@@ -119,18 +119,18 @@ def setup_logging(name):
         prefix = os.environ['NVIM_PYTHON_LOG_FILE'].strip()
         major_version = sys.version_info[0]
         logfile = '{}_py{}_{}'.format(prefix, major_version, name)
-        handler = logging.FileHandler(logfile, 'w')
+        handler = logging.FileHandler(logfile, 'w', 'utf-8')
         handler.formatter = logging.Formatter(
             '%(asctime)s [%(levelname)s @ '
             '%(filename)s:%(funcName)s:%(lineno)s] %(process)s - %(message)s')
         logging.root.addHandler(handler)
         level = logging.INFO
         if 'NVIM_PYTHON_LOG_LEVEL' in os.environ:
-            l = getattr(logging,
-                        os.environ['NVIM_PYTHON_LOG_LEVEL'].strip(),
-                        level)
-            if isinstance(l, int):
-                level = l
+            lvl = getattr(logging,
+                          os.environ['NVIM_PYTHON_LOG_LEVEL'].strip(),
+                          level)
+            if isinstance(lvl, int):
+                level = lvl
         logger.setLevel(level)
 
 
diff --git a/neovim/api/buffer.py b/neovim/api/buffer.py
index b368b4f..368f9fb 100644
--- a/neovim/api/buffer.py
+++ b/neovim/api/buffer.py
@@ -28,7 +28,7 @@ class Buffer(Remote):
 
     def __len__(self):
         """Return the number of lines contained in a Buffer."""
-        return self.request('buffer_line_count')
+        return self.request('nvim_buf_line_count')
 
     def __getitem__(self, idx):
         """Get a buffer line or slice by integer index.
@@ -62,7 +62,7 @@ class Buffer(Remote):
         lines = item if item is not None else []
         start = adjust_index(idx.start, 0)
         end = adjust_index(idx.stop, -1)
-        return self.request('buffer_set_lines', start, end, False, lines)
+        return self.request('nvim_buf_set_lines', start, end, False, lines)
 
     def __iter__(self):
         """Iterate lines of a buffer.
@@ -160,8 +160,8 @@ class Range(object):
         if start is None:
             start = self.start
         if end is None:
-            end = self.end + 1
-        self._buffer[start:end] = lines
+            end = self.end
+        self._buffer[start:end + 1] = lines
 
     def __iter__(self):
         for i in range(self.start, self.end + 1):
diff --git a/neovim/api/nvim.py b/neovim/api/nvim.py
index ece8ad0..7886a24 100644
--- a/neovim/api/nvim.py
+++ b/neovim/api/nvim.py
@@ -2,7 +2,6 @@
 import functools
 import os
 import sys
-
 from traceback import format_stack
 
 from msgpack import ExtType
@@ -79,7 +78,7 @@ class Nvim(object):
         self.types = types
         self.api = RemoteApi(self, 'nvim_')
         self.vars = RemoteMap(self, 'nvim_get_var', 'nvim_set_var')
-        self.vvars = RemoteMap(self, 'vim_get_vvar', None)
+        self.vvars = RemoteMap(self, 'nvim_get_vvar', None)
         self.options = RemoteMap(self, 'nvim_get_option', 'nvim_set_option')
         self.buffers = Buffers(self)
         self.windows = RemoteSequence(self, 'nvim_list_wins')
@@ -295,12 +294,12 @@ class Nvim(object):
 
         The returned sequences can be used as input to `feedkeys`.
         """
-        return self.request('vim_replace_termcodes', string,
+        return self.request('nvim_replace_termcodes', string,
                             from_part, do_lt, special)
 
-    def out_write(self, msg):
+    def out_write(self, msg, **kwargs):
         """Print `msg` as a normal message."""
-        return self.request('nvim_out_write', msg)
+        return self.request('nvim_out_write', msg, **kwargs)
 
     def err_write(self, msg, **kwargs):
         """Print `msg` as an error message."""
@@ -353,7 +352,7 @@ class Buffers(object):
     """Remote NVim buffers.
 
     Currently the interface for interacting with remote NVim buffers is the
-    `vim_get_buffers` msgpack-rpc function. Most methods fetch the list of
+    `nvim_list_bufs` msgpack-rpc function. Most methods fetch the list of
     buffers from NVim.
 
     Conforms to *python-buffers*.
diff --git a/neovim/msgpack_rpc/session.py b/neovim/msgpack_rpc/session.py
index de87c97..3e03a24 100644
--- a/neovim/msgpack_rpc/session.py
+++ b/neovim/msgpack_rpc/session.py
@@ -1,7 +1,6 @@
 """Synchronous msgpack-rpc session layer."""
 import logging
 from collections import deque
-
 from traceback import format_exc
 
 import greenlet
diff --git a/neovim/plugin/decorators.py b/neovim/plugin/decorators.py
index defceb3..7015a95 100644
--- a/neovim/plugin/decorators.py
+++ b/neovim/plugin/decorators.py
@@ -43,7 +43,7 @@ def rpc_export(rpc_method_name, sync=False):
 
 
 def command(name, nargs=0, complete=None, range=None, count=None, bang=False,
-            register=False, sync=False, eval=None):
+            register=False, sync=False, allow_nested=False, eval=None):
     """Tag a function or plugin method as a Nvim command handler."""
     def dec(f):
         f._nvim_rpc_method_name = 'command:{}'.format(name)
@@ -73,17 +73,22 @@ def command(name, nargs=0, complete=None, range=None, count=None, bang=False,
         if eval:
             opts['eval'] = eval
 
+        if not sync and allow_nested:
+            rpc_sync = "urgent"
+        else:
+            rpc_sync = sync
+
         f._nvim_rpc_spec = {
             'type': 'command',
             'name': name,
-            'sync': sync,
+            'sync': rpc_sync,
             'opts': opts
         }
         return f
     return dec
 
 
-def autocmd(name, pattern='*', sync=False, eval=None):
+def autocmd(name, pattern='*', sync=False, allow_nested=False, eval=None):
     """Tag a function or plugin method as a Nvim autocommand handler."""
     def dec(f):
         f._nvim_rpc_method_name = 'autocmd:{}:{}'.format(name, pattern)
@@ -98,17 +103,22 @@ def autocmd(name, pattern='*', sync=False, eval=None):
         if eval:
             opts['eval'] = eval
 
+        if not sync and allow_nested:
+            rpc_sync = "urgent"
+        else:
+            rpc_sync = sync
+
         f._nvim_rpc_spec = {
             'type': 'autocmd',
             'name': name,
-            'sync': sync,
+            'sync': rpc_sync,
             'opts': opts
         }
         return f
     return dec
 
 
-def function(name, range=False, sync=False, eval=None):
+def function(name, range=False, sync=False, allow_nested=False, eval=None):
     """Tag a function or plugin method as a Nvim function handler."""
     def dec(f):
         f._nvim_rpc_method_name = 'function:{}'.format(name)
@@ -124,10 +134,15 @@ def function(name, range=False, sync=False, eval=None):
         if eval:
             opts['eval'] = eval
 
+        if not sync and allow_nested:
+            rpc_sync = "urgent"
+        else:
+            rpc_sync = sync
+
         f._nvim_rpc_spec = {
             'type': 'function',
             'name': name,
-            'sync': sync,
+            'sync': rpc_sync,
             'opts': opts
         }
         return f
diff --git a/neovim/plugin/host.py b/neovim/plugin/host.py
index d1b7ab5..6db26e5 100644
--- a/neovim/plugin/host.py
+++ b/neovim/plugin/host.py
@@ -1,12 +1,11 @@
 """Implements a Nvim host for python plugins."""
-import functools
 import imp
 import inspect
 import logging
 import os
 import os.path
 import re
-
+from functools import partial
 from traceback import format_exc
 
 from . import script_host
@@ -181,8 +180,8 @@ class Host(object):
             if fn._nvim_prefix_plugin_path:
                 method = '{}:{}'.format(plugin_path, method)
 
-            fn_wrapped = functools.partial(self._wrap_function, fn,
-                                           sync, decode, nvim_bind, method)
+            fn_wrapped = partial(self._wrap_function, fn,
+                                 sync, decode, nvim_bind, method)
             self._copy_attributes(fn, fn_wrapped)
             # register in the rpc handler dict
             if sync:
diff --git a/neovim/version.py b/neovim/version.py
new file mode 100644
index 0000000..46d4d13
--- /dev/null
+++ b/neovim/version.py
@@ -0,0 +1,5 @@
+from .util import Version
+
+VERSION = Version(major=0, minor=1, patch=14, prerelease="dev")
+
+__all__ = ('VERSION',)
diff --git a/setup.cfg b/setup.cfg
index 527141c..50edf4c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,8 +1,7 @@
 [flake8]
-ignore = D211,E731,F821
+ignore = D211,E731,F821,D401
 
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index caa6a77..f81a764 100644
--- a/setup.py
+++ b/setup.py
@@ -22,10 +22,10 @@ if platform.python_implementation() != 'PyPy':
     install_requires.append('greenlet')
 
 setup(name='neovim',
-      version='0.1.13',
+      version='0.2.0',
       description='Python client to neovim',
       url='http://github.com/neovim/python-client',
-      download_url='https://github.com/neovim/python-client/archive/0.1.13.tar.gz',
+      download_url='https://github.com/neovim/python-client/archive/0.2.0.tar.gz',
       author='Thiago de Arruda',
       author_email='tpadilha84 at gmail.com',
       license='Apache',
diff --git a/test/test_buffer.py b/test/test_buffer.py
index 9bb91b5..1671048 100644
--- a/test/test_buffer.py
+++ b/test/test_buffer.py
@@ -172,3 +172,10 @@ def test_get_exceptions():
 @with_setup(setup=cleanup)
 def test_contains():
     ok(vim.current.buffer in vim.buffers)
+
+ at with_setup(setup=cleanup)
+def test_set_items_for_range():
+    vim.current.buffer[:] = ['a', 'b', 'c', 'd', 'e']
+    r = vim.current.buffer.range(1, 3)
+    r[1:3] = ['foo']*3
+    eq(vim.current.buffer[:], ['a', 'foo', 'foo', 'foo', 'd', 'e'])
diff --git a/test/test_vim.py b/test/test_vim.py
index 7618f7b..7b5a1ae 100644
--- a/test/test_vim.py
+++ b/test/test_vim.py
@@ -21,7 +21,8 @@ def test_command():
     vim.command('normal itesting\npython\napi')
     vim.command('w')
     ok(os.path.isfile(fname))
-    eq(open(fname).read(), 'testing\npython\napi\n')
+    with open(fname) as f:
+      eq(f.read(), 'testing\npython\napi\n')
     os.unlink(fname)
 
 
@@ -63,8 +64,10 @@ def test_strwidth():
 @with_setup(setup=cleanup)
 def test_chdir():
     pwd = vim.eval('getcwd()')
+    root = os.path.abspath(os.sep)
+    # We can chdir to '/' on Windows, but then the pwd will be the root drive
     vim.chdir('/')
-    eq(vim.eval('getcwd()'), '/')
+    eq(vim.eval('getcwd()'), root)
     vim.chdir(pwd)
     eq(vim.eval('getcwd()'), pwd)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-neovim.git



More information about the Python-modules-commits mailing list