2

In a traditional :python3 plugin, I can call print("msg") to echo a message.

In a remote plugin function, I expect that calling vim.async_call(print, "msg") would do the same thing, but it does not. To be more concrete, in the following example, :call EchoTest() echos, and :call PrintTest() does not:

import pynvim
from pynvim.api.nvim import Nvim


@pynvim.plugin
class MyPlugin(object):
    def __init__(self, vim: Nvim) -> None:
        self.vim = vim

    @pynvim.function("EchoTest")
    def echo_test(self, _):
        self.vim.command(f'echo "this will be echoed as expected"')

    @pynvim.function("PrintTest")
    def print_test(self, _):
        self.vim.async_call(print, "this will not be echoed")

I understand that Nvim.out_write is probably the preferred way to do this, but I think I may be misunderstanding what vim.async_call does, and I would appreciate some clarity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.