How to use the pynvim.function function in pynvim

To help you get started, we’ve selected a few pynvim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github svermeulen / nvim-marksman / rplugin / python3 / marksman / Marksman.py View on Github external
    @pynvim.function('MarksmanUpdateSearch', sync=True)
    def updateSearch(self, args):
        self._lazyInit()

        assert len(args) == 5, 'Wrong number of arguments to MarksmanUpdateSearch'

        rootPath = self._getCanonicalPath(args[0])

        assert os.path.isdir(rootPath), f"Could not find directory '{rootPath}'"

        requestId = args[1]
        offset = args[2]
        maxAmount = args[3]
        # We could use ignorePath here to hide the current project, but I find that
        # in practice this is more annoying than it is useful
        # ignorePath = self._getCanonicalPath(args[4])
        ignorePath = None
github svermeulen / nvim-marksman / rplugin / python3 / marksman / Marksman.py View on Github external
    @pynvim.function('MarksmanForceRefresh')
    def forceRefresh(self, args):
        self._lazyInit()

        assert len(args) == 1, 'Wrong number of arguments to MarksmanForceRefresh'

        rootPath = self._getCanonicalPath(args[0])

        info = self._getProjectInfo(rootPath)

        if info.isUpdating.getValue():
            return

        info.isUpdating.setValue(True)
        self._refreshQueue.put(rootPath)
github sakhnik / nvim-gdb / rplugin / python3 / gdb / __init__.py View on Github external
    @pynvim.function('GdbInit', sync=True)
    def gdb_init(self, args):
        """Handle the command GdbInit."""
        # Prepare configuration: keymaps, hooks, parameters etc.
        common = BaseCommon(self.vim, Config(self))
        app = App(common, *args)
        self.apps[self.vim.current.tabpage.handle] = app
        app.start()
        if len(self.apps) == 1:
            # Initialize the UI commands, autocommands etc
            self.vim.call("nvimgdb#GlobalInit")
github numirias / semshi / rplugin / python3 / semshi / plugin.py View on Github external
    @neovim.function('SemshiTextChanged', sync=False)
    def event_text_changed(self, _):
        # Note: TextChanged event doesn't trigger if text was changed in
        # unfocused buffer via e.g. nvim_buf_set_lines().
        self._cur_handler.update()
github sakhnik / nvim-gdb / rplugin / python3 / gdb / __init__.py View on Github external
    @pynvim.function('GdbCreateWatch', sync=True)
    def gdb_create_watch(self, args):
        """Handle command GdbCreateWatch."""
        return self.gdb_call(["create_watch"] + args)
github numirias / semshi / rplugin / python3 / semshi / plugin.py View on Github external
    @neovim.function('SemshiBufWipeout', sync=True)
    def event_buf_wipeout(self, args):
        self._remove_handler(args[0])
github sakhnik / nvim-gdb / rplugin / python3 / gdb / __init__.py View on Github external
    @pynvim.function('GdbCustomCommand', sync=True)
    def gdb_custom_command(self, args):
        """Handle command GdbCustomCommand."""
        return self.gdb_call(["custom_command"] + args)
github sakhnik / nvim-gdb / rplugin / python3 / gdb / __init__.py View on Github external
    @pynvim.function('GdbTestPeekConfig', sync=True)
    def gdb_test_peek_config(self, _):
        """Handle command GdbTestPeekConfig."""
        try:
            app = self._get_app()
            if app:
                config = dict(app.config.config)
                for key, val in config.items():
                    if callable(val):
                        config[key] = str(val)
                return config
        except Exception:
            self.logger.exception('GdbTestPeekConfig Exception')
        return None
github sakhnik / nvim-gdb / rplugin / python3 / gdb / __init__.py View on Github external
    @pynvim.function('GdbHandleEvent', sync=True)
    def gdb_handle_event(self, args):
        """Handle the command GdbHandleEvent."""
        self.logger.info("GdbHandleEvent %s", ' '.join(args))
        try:
            app = self._get_app()
            if app:
                handler = getattr(app, args[0])
                handler()
        except Exception:
            self.logger.exception("GdbHandleEvent Exception")
github numirias / semshi / rplugin / python3 / semshi / plugin.py View on Github external
    @neovim.function('SemshiVimResized', sync=False)
    def event_vim_resized(self, args):
        self._update_viewport(*args)
        self._mark_selected()