neovim / pynvim

Python client and plugin host for Nvim
http://pynvim.readthedocs.io/en/latest/
Apache License 2.0
1.53k stars 118 forks source link

no request handler registered for "/home/me/dummy/rplugin/python3/dummy:autocmd:BufEnter:*" #341

Open balta2ar opened 6 years ago

balta2ar commented 6 years ago

Hello. I came from this issue: https://github.com/numirias/semshi/issues/11

Summary: neovim prints this upon startup:

Error detected while processing function remote#define#request:
line    2:
no request handler registered for "/home/bz/rc.arch/bz/.vim/plugged/semshi/rplugin/python3/semshi:autocmd:BufEnter:*.py"

It only surfaced when I started using semshi. However, it does not look like it's a bug in the plugin, but rather in neovim/neovim-client. The author of the plugin could also reproduce the issue with the following configuration (see this comment https://github.com/numirias/semshi/issues/11#issuecomment-397452519):

call plug#begin('~/.vim/plugged')
Plug 'numirias/semshi'
Plug 'autozimu/LanguageClient-neovim'
Plug 'brooth/far.vim'
call plug#end()

The following plugin can also help reproduce the issue:

import neovim

@neovim.plugin
class Plugin:

    def __init__(self, vim):
        self._vim = vim

    @neovim.autocmd('BufEnter', pattern='*', sync=True)
    def foo(self):
        self._vim.out_write('hey\n')

neovim 0.3.0 neovim-client 0.2.6

Shougo commented 6 years ago

UpdateRemotePlugins is already executed?

numirias commented 6 years ago

@Shougo Yep. Installation of Python plugins (and registering their handlers) otherwise works fine.

You should be able to reproduce the bug with a minimal config using only these three plugins:

call plug#begin('~/.vim/plugged')
Plug 'numirias/semshi'
Plug 'autozimu/LanguageClient-neovim'
Plug 'brooth/far.vim'
call plug#end()

Note that they all are Python-powered and if you remove any single one of them the error disappears. But even if you replace one of them with the dummy plugin stub from above, the error will reappear. (While trying, obviously run :UpdateRemotePlugins each time.)

Would love to see someone else repro it.

Shougo commented 6 years ago

I have tested it, but I cannot reproduce the problem.

balta2ar commented 6 years ago

If it's a race condition, could you try with more plugins, e.g.:

call plug#begin('~/.vim/plugged')

Plug 'numirias/semshi'

Plug 'autozimu/LanguageClient-neovim'
Plug 'brooth/far.vim'
Plug 'raghur/vim-ghost', {'do': ':GhostInstall'}
Plug 'arakashic/chromatica.nvim'
Plug 'Shougo/deoplete.nvim'

call plug#end()
lkhphuc commented 5 years ago

Confirm that I can reproduce the problem with the minimal config above. Neovim: 0.3.1, python-neovim: 0.2.6, macOS 10.14.

numirias commented 5 years ago

Many shaky race conditions have been fixed in Neovim since, so chances are this bug might be gone.

@balta2ar @lkhphuc Can you still reproduce? Otherwise, I think this can be closed.

balta2ar commented 5 years ago

@numirias I'm using neovim 0.3.3, pynvim 0.3.2 and I can consistently reproduce very similar error message with the following plugin:

import pynvim

@pynvim.plugin
class Main(object):
    def __init__(self, nvim):
        self.nvim = nvim

    @pynvim.autocmd('BufWritePost', pattern='*', eval='expand("<afile>:p")')
    def update_tags_for_file(self, filename):
        self.update_screen()

    @property
    def extrawidth(self):
        numberwidth = self.nvim.eval(
            '((&number||&relativenumber) ? &numberwidth : 0) + &foldcolumn')
        self.nvim.command(
            'redir =>a |exe "sil sign place buffer=".bufnr(\'\')|redir end')
        signlist = self.nvim.command_output('echo a').split('\n')
        signwidth = 2 if len(signlist) > 2 else 0
        separator = 1

        result = numberwidth + signwidth
        result += separator if numberwidth > 0 else 0
        result += separator if signwidth > 0 else 0
        return result

    def pad_message(self, message, index):
        winwidth = self.nvim.eval('winwidth("%")')
        linewidth = self.nvim.eval(
            'strdisplaywidth(getline(%s))' % (index + 1)) + self.extrawidth
        sumwidth = len(message)
        padwidth = max(0, winwidth - linewidth - sumwidth)
        padding = ' ' * padwidth
        padded_message = padding + message

        return padded_message

    def update_screen(self):
        highlight_group = 'LineNr'

        line_start = self.nvim.eval('line("w0")') - 1
        line_end = self.nvim.eval('line("w$")')
        lines = self.nvim.current.buffer[line_start:line_end]

        api = self.nvim.current.buffer.api
        api.clear_namespace(-1, 0, -1)
        for line, index in zip(lines, range(line_start, line_end)):
            text = 'Mocked'
            message = self.pad_message(text, index)
            api.set_virtual_text(0, index, [[message, highlight_group]], {})

The error I see when I do :w is this:

no notification handler registered for "/home/username/rc.arch/bz/.vim/plugged/timesheet.nvim/rplugin/python3/timesheet.py:autocmd:BufWritePost:*"

If I remove the two lines below, the error disappears:

        numberwidth = self.nvim.eval(
            '((&number||&relativenumber) ? &numberwidth : 0) + &foldcolumn')
        self.nvim.command(
            'redir =>a |exe "sil sign place buffer=".bufnr(\'\')|redir end')

Maybe it's a problem with my code, not neovim or pynvim, could you tell it from the code?

justinmk commented 5 years ago
no notification handler registered for "/home/username/rc.arch/bz/.vim/plugged/timesheet.nvim/rplugin/python3/timesheet.py:autocmd:BufWritePost:*"

That definitely looks wrong. The "method name" "/home/username/.../timesheet.py:autocmd:BufWritePost:* is nonsense. Somewhere that's being passed as a method name. Most likely a bug in runtime/autoload/remote/define.vim .

tjdevries commented 5 years ago

I'm having this exact same thing happen to me while attempting to write a plugin...

weird thing is that after the first attempt failing, the rest succeed.

fkarg commented 5 years ago

I just had the exact same issue happening to me with only

Plug 'autozimu/LanguageClient-neovim'

though. Can't seem to figure it out though, and the magic UpdateRemotePlugins does something for me, but does not solve my problem (even after repeated execution).

DrBluefall commented 4 years ago

I can reproduce this as well, with this fairly minimal plugin:

"""An RPC client for Neovim."""
import pynvim
import pypresence
import asyncio
from datetime import datetime

@pynvim.plugin
class Neocord:
    """The core class for Neocord."""

    def __init__(self, nvim):
        """Initialize the plugin."""
        self.nvim = nvim
        self.client_id = self.nvim.vars.get("neocord_clientid")
        if self.client_id is None:
            self.client_id = 655548219425554464
        self.presence = pypresence.AioClient(
            self.client_id,
            loop=self.nvim.loop
        )
        self.presence.start()
        self.enter_time = datetime.now()
        self.pid = self.nvim.api.get_api_info()[0]

    @pynvim.autocmd('BufEnter', pattern='*')
    async def on_bufenter(self):
        """Run on opening a buffer."""
        current_buf = self.nvim.current.buffer
        await self.presence.set_activity(
                state=f"Editing buffer {current_buf.name}",
                start=self.enter_time.timestamp(),
                pid=self.pid
            )

    @pynvim.autocmd('VimEnter', pattern='*')
    async def on_vimenter(self):
        """Run on opening a vim session."""
        current_buf = self.nvim.current.buffer
        await self.presence.set_activity(
                state=f"Editing buffer {current_buf.name}",
                start=self.enter_time.timestamp(),
                pid=self.pid
            )

as well as this (super) minimal vimrc:

let &runtimepath.=','.escape(expand('<sfile>:p:h'), '\,')
tejasvi commented 3 years ago

I had the issue with incorrect g:python3_host_prog. Try doing :checkhealth once