Skip to content

Commit

Permalink
add nvim_get_current_win, nvim_win_get_cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
roxma committed Oct 14, 2017
1 parent 7276c68 commit 14a3535
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pythonx/neovim_rpc_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def nvim_set_option(name, val):
def nvim_command(cmd):
vim.command(cmd)

def nvim_get_current_win():
return vim.current.window

def nvim_win_get_cursor(window):
return window.cursor

# TODO
def nvim_out_write(s):
pass
Expand Down
8 changes: 7 additions & 1 deletion pythonx/neovim_rpc_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

BUFFER_TYPE = type(vim.current.buffer)
BUFFER_TYPE_ID = neovim_rpc_server_api_info.API_INFO['types']['Buffer']['id']
WINDOW_TYPE = type(vim.current.window)
WINDOW_TYPE_ID = neovim_rpc_server_api_info.API_INFO['types']['Window']['id']


def from_client(msg):
Expand All @@ -23,6 +25,8 @@ def handler(obj):
if type(obj) is msgpack.ExtType:
if obj.code == BUFFER_TYPE_ID:
return vim.buffers[msgpack.unpackb(obj.data)]
if obj.code == WINDOW_TYPE_ID:
return vim.windows[msgpack.unpackb(obj.data) - 1]
if sys.version_info.major!=2:
# python3 needs decode
obj = decode_if_bytes(obj)
Expand All @@ -34,6 +38,8 @@ def to_client(msg):
def handler( obj):
if type(obj) == BUFFER_TYPE:
return msgpack.ExtType(BUFFER_TYPE_ID, msgpack.packb(obj.number))
if type(obj) == WINDOW_TYPE:
return msgpack.ExtType(WINDOW_TYPE_ID, msgpack.packb(obj.number))
return obj
return walk(handler,msg)
return walk(handler, msg)

0 comments on commit 14a3535

Please sign in to comment.