rescript-lang / vim-rescript

MIT License
154 stars 15 forks source link

Add errorformat #74

Open johnridesabike opened 11 months ago

johnridesabike commented 11 months ago

Since the commands like :RescriptBuild were removed, it would be very useful if this included support for Vim's built-in makeprg and errorformat features. I assume makeprg can just be npx rescript $*, but I'm not skilled enough at using errorformat to know what it needs to be.

johnridesabike commented 11 months ago

After a little bit of trial and error, I have an errorformat that seems to mostly work:

if exists("g:current_compiler")
  finish
endif
let current_compiler = "rescript"

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

CompilerSet makeprg=npx\ rescript\ $*
CompilerSet errorformat=
  \%-GFAILED:%m,
  \%-Grescript:%m,
  \%E\ \ We've\ found\ a\ bug\ for\ you!,
  \%E\ \ Syntax\ error!,
  \%W\ \ Warning\ number\ %n%.%#,
  \%C%f:%l:%c,
  \%C%f:%l:%c-%k,
  \%C%f:%l:%c-%e:%k,
  \%-C\ \ %l\ %.%#,
  \%-C\ \ \ \ %.%#,
  \%-C\\s%#,
  \%-G\\s%#,
  \%C%m,

I'm not confident that it properly handles every error message though, and I've only tested it on ReScript 10. But in case anyone else wants to take a crack at it, this may be a starting point!