Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First call to function returns null #434

Closed
lriuui0x0 opened this issue Mar 7, 2020 · 2 comments · Fixed by #496
Closed

First call to function returns null #434

lriuui0x0 opened this issue Mar 7, 2020 · 2 comments · Fixed by #496
Labels

Comments

@lriuui0x0
Copy link

I'm using the standard example plugin:

import pynvim

@pynvim.plugin
class TestPlugin(object):

    def __init__(self, nvim):
        self.nvim = nvim

    @pynvim.function('TestFunction', sync=True)
    def testfunction(self, args):
        return 3

    @pynvim.command('TestCommand', nargs='*', range='')
    def testcommand(self, args, range):
        self.nvim.current.line = ('Command with args: {}, range: {}'
                                  .format(args, range))

    @pynvim.autocmd('BufEnter', pattern='*.py', eval='expand("<afile>")', sync=True)
    def on_bufenter(self, filename):
        self.nvim.out_write('testplugin is in ' + filename + '\n')

The first time I call :echo TestFunction(), it returns v:null. The second time returns the correct number. I also observed that if you open the plugin handler file first, then it will behave correctly and returns the correct number even for the first time.

As a side question, is there a way to reload remote plugins on the fly? I tried :UpdateRemotePlugins but it doesn't work. It's really annoying to restart nvim to see changes.

@dncnmcdougall
Copy link

I have also experienced this problem.

I am on:
NVIM v0.5.0-426-g30a6e374d
Build type: Release

@justinmk
Copy link
Member

is there a way to reload remote plugins on the fly? I tried :UpdateRemotePlugins but it doesn't work. It's really annoying to restart nvim to see changes.

no, unfortunately. tracked in neovim/neovim#5532

justinmk pushed a commit that referenced this issue Aug 26, 2021
This happens only right after instantiation of the plugin class, so
calling any other asynchronous function seemingly fixes the problem.

Fixes #434
@justinmk justinmk added bug and removed question labels Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants