vscode-reasonml
vscode-reasonml copied to clipboard
Get syntax error information from refmt
Merlin doesn't provide very good Reason syntax error information; in particular the location of the error is often way off. The positional information from refmt is way better, so I think it would make sense to implement a linter which sends the code to refmt upon change, and displays any errors. You can see how sublime-reason uses refmt as a linter here: https://github.com/chenglou/sublime-reason/blob/master/Reason.py#L77-L95
If what I'm saying sounds good, I'm happy to have a go at implementing it. I've already put up a similar PR for atom-reason-refmt
Example of unhelpful syntax error info (the error is on line 6 but the Invalid token
error points to line 8):
This sounds interesting.
I would be willing to use this approach if it really does improve the reported errors. However, it would need to be implemented in such a way that it does not interfere with using the standard merlin output for plain OCaml. I don't think there is any technical problem with that but it might mean integrating it into this extension is more work than it would seem at first glance.
If you want to give it a try, the place where you would probably want to start with the integration would be the Analyzer
class in the ocaml-language-server
project, specifically the refreshWithKind
method here. You can see how I handle some other parts of the server differently for OCaml and Reason by looking at the formatter support, starting here.
Would like to see this fixed too, since as an Ocaml/ReasonML beginner, I still experience a lot of friction fighting with syntax errors. I can try to help implementing the suggested solution but not sure it's suited for a beginner...
@jsdf is there anything I can do to help you fix this ?