Closed Haagaau22 closed 4 years ago
I don't see why not. Did you check :messages
@justinmk
Hi, I just checked the :messages
and I didn't find any valuable information.
After I use UpdateRemotePlugins
, there are no errors and the plugin is in the list of registered plugins. Then I restart the neovim and check :messages
, it shows:
vimEnter autocmd
init autocmds
And my directory structure is like this:
/home/zz/.config/nvim/rplugin/python3
├── autocmds
│ ├── __init__.py
neovim version: v0.4.3
os: arch linux
I simplified the code and maybe it's easier to reproduce at now.
import pynvim
def echo_py1():
return lambda self: self.nvim.out_write('echo_py1 \n')
@pynvim.plugin
class AutocmdsPlugin(object):
def __init__(self, nvim):
self.nvim = nvim
# self.init_autocmds()
@pynvim.autocmd('VimEnter')
def add_autocmds(self):
self.nvim.out_write('vimEnter autocmd\n')
self.init_autocmds()
def echo_py2(self):
self.nvim.out_write('echo_py2\n')
@pynvim.autocmd('BufEnter', pattern='*.py')
def echo_py3(self):
self.nvim.out_write('echo_py3\n')
def init_autocmds(self):
pynvim.autocmd('BufEnter', pattern='*.py')(AutocmdsPlugin.echo_py2)
pynvim.autocmd('BufEnter', pattern='*.py')(echo_py1())
self.nvim.out_write('init autocmds\n')
the echo_py3
can work well and both echo_py1
and echo_py2
can't work.
Thanks again
Unfortunately, autocmds are registered in rplugin.vim(~/.local/share/nvim/rplugin.vim
).
It is updated by :UpdateRemotePlugins
.
So you cannot register autocmds dynamically.
oh right. thanks @Shougo .
covered by https://github.com/neovim/neovim/issues/5532
Hi! I want to register some
autocmd
s from a config dynamically, and I tried some code, but registration failed and no exceptions. Following is my code:Any suggestions? Thanks!