简体   繁体   English

Vim Syntastic:如何找出当前使用的语法检查程序?

[英]Vim Syntastic: How to find out which syntax checker is currently in use?

I would like to change a setting or edit a line of code in the Python syntax checker, but Syntastic comes with five of them. 我想在Python语法检查器中更改设置或编辑一行代码,但Syntastic附带了五行代码。 How can I find out which one is in use? 我怎样才能知道哪一个正在使用?

Syntastic has a built-in function for this. Syntastic具有内置功能。 I believe which syntax checkers are available depend on your system. 我相信哪些语法检查器可用取决于您的系统。

:SyntasticInfo

Syntastic info for filetype: python
Available checkers: python
Currently active checker(s): python
Press ENTER or type command to continue

Frustratingly there doesn't seem to be a direct way to return the available checkers as a vim script string or list. 令人沮丧的是,似乎没有直接的方法将可用的检查器作为vim脚本字符串或列表返回。 Wrote this function that uses :redir to do so: 写了这个函数,使用:redir这样做:

function! s:syntastic_checkers(...)
  redir => output
  silent SyntasticInfo
  redir END
  let result=split(output, "\n")
  let checkers=split(split(result[-2], ':')[-1], '\s\+')
  if checkers[0]=='-'
    let checkers=[]
  else
    call extend(checkers, split(split(result[-1], ':')[-1], '\s\+')[:1])
  endif
  if a:0 "just echo the result
    echo 'Checkers: '.join(checkers, ', ')
  else
    return checkers
  endif
endfunction
command! SyntasticCheckers

Call it with any argument to print a list of checkers, and call it without any arguments to return a vim list of checkers, plus the current checker in the final position of the list. 使用任何参数调用它来打印检查器列表,并在没有任何参数的情况下调用它来返回检查器的vim列表,以及列表最终位置的当前检查器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM