2021年11月6日 星期六

VIM Script 8.0.xx not execute channel command right away

 

I encountered this issue while developing my vim plugins. Although, 

Env/Platform: 

    VIM 8.0.1365

    MAC OS X Mojave

 

Problem: 

    When server send a channel command to VIM client, there is a notable gap between the command receiving time and execution starting time. In my case, the delay is about 4 seconds. With this delay, plugins for realtime application such as autocomplete, linting and highlighting will results  poor user experience. 

    To identify this problem, we can use channel log, for example, in command line type the following command:

    :call ch_logfile(''my_ch.log")

After channel command is done, we can check time-stamps in my_ch.log: 

    x.xxxxx On 0, RECV ["call", "MyFunc"]

    y.yyyyy Call MyFunc 

y.yyyy, x.xxxxx are time-stamps

 

Solution: 

    This issue seems a buffering issue because when VIM send message to server right after receiving  channel command, the channel command will be executed immediately. I guess the VIM is simply waiting  for some events before start to to command. To solve this, update VIM to 8.2.