pynvim icon indicating copy to clipboard operation
pynvim copied to clipboard

Not registering plugin command

Open huberb opened this issue 1 year ago • 1 comments

I'm trying to add a new command to neovim using this project. This is my code:

import pynvim
import inspect
import logging

logging.basicConfig(filename='/path/to/logs.txt', level=logging.DEBUG)
logging.debug("file loaded")

@pynvim.plugin
class TestPlugin:
    def __init__(self, nvim):
        self.nvim = nvim
        logging.debug("TestPlugin loaded")

    @pynvim.command('TestCommand', nargs='*', range='', sync=True)
    def test_command(self, args, range):
        logging.debug("TestCommand triggered")
        self.nvim.out_write("TestCommand executed\n")

my log file shows "file loaded", but nothing else. It seems like the class is never instanciated. Logging output from inside the class is never written

I'm loading this using the following lines in my init.lua:

vim.api.nvim_command("python3 import my_plugin")

Which seems to be correct. The file is loaded when starting neovim

I'm using neovim 0.10.1 and python 3.11.5

Is there anything wrong with my approach? I assumed the class will be instanciated and registered automatically

huberb avatar Sep 22 '24 13:09 huberb

The remote plugin concept will be removed, because it's not needed if pynvim just provides a set_handler function. See https://github.com/neovim/pynvim/issues/567

@b0o any chance you can implement set_handler in pynvim?

justinmk avatar Sep 22 '24 14:09 justinmk