Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vim错误格式和光谱林特_Vim_Swagger_Openapi_Spectral - Fatal编程技术网

Vim错误格式和光谱林特

Vim错误格式和光谱林特,vim,swagger,openapi,spectral,Vim,Swagger,Openapi,Spectral,我试图为Spectrum OpenAPI linter定义一个错误格式。下面是我的代码,但我看到的是在我运行之后:使用Spectral中的行填充quickfix窗口,但我无法使用它导航到错误点。Vim中没有错误,快速修复窗口只是做不了什么 来自Spectrum的消息如下所示: /path/to/sample.yaml:25:9 error oas3-schema "Property `think` is not expected to be here." function! OpenAPIDe

我试图为Spectrum OpenAPI linter定义一个错误格式。下面是我的代码,但我看到的是在我运行之后:使用Spectral中的行填充quickfix窗口,但我无法使用它导航到错误点。Vim中没有错误,快速修复窗口只是做不了什么

来自Spectrum的消息如下所示:

/path/to/sample.yaml:25:9 error oas3-schema "Property `think` is not expected to be here."
function! OpenAPIDetect()
    if getline(1) =~ 'openapi:'
        let &l:makeprg='spectral lint "' .  expand('%') . '" -f text'
        setlocal errorformat=%f:%l:%c\ (information\\|warning\\|error)\ (\\w\\|-)\+\ %m
        setlocal errorformat+=%-GOpenAPI\ 3.x\ detected
    endif
endfunction

augroup filetypedetect
    au BufRead,BufNewFile *.{yml,yaml} call OpenAPIDetect()
augroup END
我当前的Vimscript如下所示:

/path/to/sample.yaml:25:9 error oas3-schema "Property `think` is not expected to be here."
function! OpenAPIDetect()
    if getline(1) =~ 'openapi:'
        let &l:makeprg='spectral lint "' .  expand('%') . '" -f text'
        setlocal errorformat=%f:%l:%c\ (information\\|warning\\|error)\ (\\w\\|-)\+\ %m
        setlocal errorformat+=%-GOpenAPI\ 3.x\ detected
    endif
endfunction

augroup filetypedetect
    au BufRead,BufNewFile *.{yml,yaml} call OpenAPIDetect()
augroup END

以下几点就足够了:

setlocal errorformat=%f:%l:%c\ %t%.%\\{-}\ %m
%f:%l:%c与冒号分隔的文件名、行和列匹配, %t匹配单个字符,用于推断错误类型,错误为e,警告为w,信息为i,提示不受支持, %.%\\{-}跳过类型字的其余部分, %m与消息的其余部分匹配。 此外,正确放置:help“errorformat”和:help“makeprg”的位置应该是:help:compiler文件:

OpenAPI检测逻辑的正确位置应该是:help-ftplugin:


以下几点就足够了:

setlocal errorformat=%f:%l:%c\ %t%.%\\{-}\ %m
%f:%l:%c与冒号分隔的文件名、行和列匹配, %t匹配单个字符,用于推断错误类型,错误为e,警告为w,信息为i,提示不受支持, %.%\\{-}跳过类型字的其余部分, %m与消息的其余部分匹配。 此外,正确放置:help“errorformat”和:help“makeprg”的位置应该是:help:compiler文件:

OpenAPI检测逻辑的正确位置应该是:help-ftplugin:


这是非常有用的,谢谢!从您的消息中得到一个提示,我继续创建了编译器定义,并将一个副本推送到Github,以防它对其他人有用:这非常有用,谢谢!根据您的消息,我继续创建了编译器定义,并将副本推送到Github,以防它对其他人有用: