I am attempting to define an error format for the Spectral OpenAPI linter (https://github.com/stoplightio/spectral). The code I have is below, but what I'm seeing is that after I run :make the quickfix window populates with lines from Spectral, but I can't navigate to error spots using it. There are no errors in Vim, the quick fix window just doesn't do much.
The messages from Spectral look like this:
/path/to/sample.yaml:25:9 error oas3-schema "Property `think` is not expected to be here."
My current Vimscript looks like this:
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
The following should be enough:
%f:%l:%cmatches the colon-separated filename, line, and column,%tmatches a single character, used to infer the type of the error (errorife,warningifw,infoifi,hintis not supported),%.%\\{-}skips over the rest of the "type" word,%mmatches the rest of the message.Also, the right place for
:help 'errorformat'and:help 'makeprg'would be a:help :compilerfile:and the right place for that OpenAPI detection logic would be a
:help ftplugin: