skywind3000/asyncrun.vim

E518: Unknown option: \ %{exists('w:quickfix_title')?

Closed this issue · 2 comments

问题描述

我定义了如下命令:

function! PinYin#PyNormal()
    let l:conda_python = $USERPROFILE . '\miniconda3\envs\pinyin\python.exe'
    let l:current_word = expand('<cword>')
    let l:cmd = '"' . l:conda_python . '" -m pypinyin -s TONE3 ' . l:current_word
    execute '!' . l:cmd
    " execute 'AsyncRun! -strip ' . l:cmd
endfunction
command! PinYinWords call PinYin#PyNormal()
nnoremap <leader>yq :call PinYin#PyNormal()<CR>

当直接使用外部命令 execute '!' . l:cmd,一切正常。

当改用 AsyncRun 命令 execute 'AsyncRun! -strip ' . l:cmd,就会出现如下错误:

Error detected while processing function AsyncRun_Job_OnTimer[12]..<SNR>59_AsyncRun_Job_Update[40]..<SNR>59_AppendText[33]..BufWinEnter 自动命令 "quickfix":
E518: Unknown option: \ %{exists('w:quickfix_title')? 

我当前的使用环境

  • windows 10 pro 22H2
  • gvim_9.1.0309_x64_signed.exe

发现:不使用 -strip 就不会出现错误,但这样就会有多余的烦人信息。

Update:进一步发现,即使不使用 -strip,多次运行后,还是会出现同样的错误。

原来是这个配置的格式写错了,正确的如下:

    augroup QuickfixStatus
        au! BufWinEnter quickfix setlocal
                    \ statusline=%t\ [%{g:asyncrun_status}]\ %{exists('w:quickfix_title')?\ '\ '.w:quickfix_title\ :\ ''}\ %=%-15(%l,%c%V%)\ %P
    augroup END