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

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

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

    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.