upenn-cis1xx / camelot

A fully-modular OCaml style linter
https://opam.ocaml.org/packages/camelot/
Apache License 2.0
44 stars 5 forks source link

A very optional feature: adding (easier) compatibility with language servers #66

Closed esinx closed 3 years ago

esinx commented 3 years ago

Background

An implementation of language server for using camelot with vscode is in the works!

The current PoC implementation uses regex to parse the ta's version of output to display warnings in the editor:

/File (.*), line[s]? ([0-9]+(?:-[0-9]+)?), columns: ([0-9]+(?:-[0-9]+)?)\nWarning:(.*)/

This is because the ta's version of formatting is relatively easier to parse(from plaintext to data) and has enough information to display warnings. IMHO this process could be improved using some formatting tweaks in camelot's output logic.

Proposal

An option to print a JSON-formatted list of the warnings. For instance, the following flag would produce an output according to the schema presented below:

camelot -show json
[{
    "filename": "./examples/lexical.ml",
    "lines": [5, 5],
    "cols": [0, 80],
    "warning": "exceeding the 80 character line limit",
    "fix": "indenting to avoid exceeding the 80 character line limit",
    "source": "let verylongvariablenamethisispainful = [1;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1]"
},
...
]