JuliaEditorSupport / julia-vim

Vim support for Julia.
http://julialang.org/
Other
756 stars 94 forks source link

Support for `errorformat` #275

Open kdheepak opened 3 years ago

kdheepak commented 3 years ago

Vim has support for writing compiler plugins: https://vimhelp.org/usr_41.txt.html#write-compiler-plugin

It would be nice to run tests and get the stacktrace populated in the quickfix list. I imagine this is not straightforward but setting the right errorformat is probably a good place to start. This is what a sample stacktrace looks like:

KeyError: key foobar not found
   [1] getindex
     @ ./dict.jl:481 [inlined]
   [2] function_name!()
     @ ModuleName /path/to/folder/PackageName/src/filename.jl:17

I imagine a file placed in ./runtime/compiler/julia.vim might be able to parse this line: @ ModuleName /path/to/folder/PackageName/src/filename.jl:17:

" Vim compiler file
" julia-vim/runtime/compiler/julia.vim

let s:cpo_save = &cpo
set cpo&vim

if exists(":CompilerSet") != 2
    command -nargs=* CompilerSet setlocal <args>
endif

CompilerSet makeprg=julia\ --project\ -e\ 'using Pkg; Pkg.test()'

CompilerSet errorformat=
            @ %o %f:%l

let &cpo = s:cpo_save
unlet s:cpo_save

I haven't tested this. I used other compiler plugin files in the vim source directory as reference. The help documentation for errorformat has a lot more options: https://vimhelp.org/quickfix.txt.html#errorformat.