roxma / vim-hug-neovim-rpc

EXPERIMENTAL
MIT License
218 stars 28 forks source link

nvim_get_option not implemented #6

Closed jsfaint closed 7 years ago

jsfaint commented 7 years ago

I use nvim.options['ignorecase'] to check vim option, it works in neovim, but fail to work in vim8.

The log says nvim_get_options was not implemented

2017-06-22 11:54:35,640 [INFO @ session.py:request:97] 19060 - 'Received error: [1, b'nvim_get_option not implemented']

I checked neovim_rpc_server_api_info.py, nvim_get_option was defined, but not implemented. I add the implement in neovim_rpc_methods.py and it works as expected.

def nvim_get_option(name):
    return vim.options[name]

def nvim_set_option(name, val):
    vim.options[name] = val

I'm a little curious about the difference of nvim/vim python client.

import vim
print(vim.options['ignorecase'])

This snippet works on both neovim and vim with :py3file

But when I add import vim to my plugin, it reported No module named 'vim'

  File "C:\Users\jia.sui\AppData\Local\nvim\plugged\gen_tags.vim\pythonx\cm_sources\gtags.py", line 5, in <module>
    import vim
ImportError: No module named 'vim'

Does anyone know the difference? Thanks

roxma commented 7 years ago

I checked neovim_rpc_server_api_info.py, nvim_get_option was defined, but not implemented. I add the implement in neovim_rpc_methods.py and it works as expected.

I have only implemented a minimal set of api for NCM. You could creat PR for this use case.


On neovim, the import vim is basicly an attached neovim client, which is:

import neovim
vim = neovim.attach(...)

It seems possible to make import vim works in your case, with some sort of magic (I've never done that), https://stackoverflow.com/questions/3799545/dynamically-importing-python-module.

But it is not necessary, with NCM source, you should use the self.nvim object. For more vim objects creation for multi-threading, you could use the neovim module to attach a new connection.

jsfaint commented 7 years ago

Thanks @roxma , you are so kind~