Skip to content

Commit

Permalink
session: set client info
Browse files Browse the repository at this point in the history
Set basic client info for all connections, not only host.
  • Loading branch information
justinmk committed May 24, 2019
1 parent 451d259 commit 176305a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pynvim/api/nvim.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def from_session(cls, session):
creating specialized objects from Nvim remote handles.
"""
session.error_wrapper = lambda e: NvimError(e[1])
channel_id, metadata = session.request(b'vim_get_api_info')
channel_id, metadata = session.request(b'nvim_get_api_info')

if IS_PYTHON3:
# decode all metadata strings for python3
Expand Down
2 changes: 1 addition & 1 deletion pynvim/msgpack_rpc/async_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def notify(self, method, args):
def run(self, request_cb, notification_cb):
"""Run the event loop to receive requests and notifications from Nvim.
While the event loop is running, `request_cb` and `_notification_cb`
While the event loop is running, `request_cb` and `notification_cb`
will be called whenever requests or notifications are respectively
available.
"""
Expand Down
10 changes: 10 additions & 0 deletions pynvim/msgpack_rpc/session.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Synchronous msgpack-rpc session layer."""
import sys
import logging
import threading
from collections import deque
Expand All @@ -7,6 +8,7 @@
import greenlet

from ..compat import check_async
from ..util import VERSION

logger = logging.getLogger(__name__)
error, debug, info, warn = (logger.error, logger.debug, logger.info,
Expand Down Expand Up @@ -151,6 +153,14 @@ def close(self):
"""Close the event loop."""
self._async_session.close()

def set_client_info(self, kind, type_, method_spec):
name = "python{}-{}-host".format(sys.version_info[0], kind)
attributes = {"license": "Apache v2",
"website": "github.com/neovim/pynvim"}
self.request(b'nvim_set_client_info',
name, VERSION.__dict__, type_, method_spec,
attributes, async_=True)

def _yielding_request(self, method, args):
gr = greenlet.getcurrent()
parent = gr.parent
Expand Down
10 changes: 2 additions & 8 deletions pynvim/plugin/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ..api import decode_if_bytes, walk
from ..compat import IS_PYTHON3, find_module
from ..msgpack_rpc import ErrorResponse
from ..util import VERSION, format_exc_skip
from ..util import format_exc_skip

__all__ = ('Host')

Expand Down Expand Up @@ -160,13 +160,7 @@ def _load(self, plugins):
kind = "script"
else:
kind = "rplugin"
name = "python{}-{}-host".format(sys.version_info[0], kind)
attributes = {"license": "Apache v2",
"website": "github.com/neovim/pynvim"}
self.name = name
self.nvim.api.set_client_info(
name, VERSION.__dict__, "host", host_method_spec,
attributes, async_=True)
self._session.set_client_info(kind, "remote", host_method_spec)

def _unload(self):
for path, plugin in self._loaded.items():
Expand Down

0 comments on commit 176305a

Please sign in to comment.