pynvim icon indicating copy to clipboard operation
pynvim copied to clipboard

plugin.function is not being loaded in neovim

Open punitsoni opened this issue 6 years ago • 2 comments
trafficstars

I am seeing a weird issue, where a function defined using @plugin.function does not get loaded most of the time.

I have a python3 plugin called prj.py. I am defining a very simple function inside the plugin like this.

@pynvim.plugin
class Main(object):
    ....
    @pynvim.function('PJumpDef')
    def PJumpDef(self, args):
        logger.info('jump')
        logger.info(args)

I run the :UpdateRemotePlugins command to generate remote plugin manifest. Now, if I restart nvim and try to execute the function using :call PJumpDef(), it fails to find the function. But, If I keep restarting nvim it works once in a while (but very rarely).

This function is also not available in the output of :func command.

However, By trial and error, I found that creating an autocmd like this in a prj.vim plugin file, I can get the function to load 100% of time.

autocmd VimEnter * call PJumpDef()

I know, this sounds very random and weird behavior, but this is bugging me for a while. Please let me know if there is some known fix for this.

punitsoni avatar Mar 08 '19 01:03 punitsoni

I can call my functions, at the first time there is no tab auto-completion, but after called once, there is auto-completion. Also, function does not accept named params.

thinker3 avatar Sep 12 '21 00:09 thinker3

I am trying to resurect this thread, i am facing the same issue, if i call a python plugin method the first time it fails to return a valid value iget vim.NIL as a value if i call it second time (same args) then it returns a proper value . Note that the function itself seems to execute but the return value is not correct the first time you call it. Calling Update remote plugins does not seem to help

asmodeus812 avatar Mar 30 '22 14:03 asmodeus812

I just experienced the issue described by @asmodeus812 and narrowed it down to an issue which is already fixed in https://github.com/neovim/pynvim/pull/496. In my case the issue still exists because the latest release, which is distributed in Arch, doesn't include it.

notEvil avatar Nov 12 '22 17:11 notEvil

Released 0.5: https://github.com/neovim/pynvim/releases/tag/0.5.0

justinmk avatar Dec 05 '23 00:12 justinmk