Ale: Add support for ReScript

Created on 5 Sep 2020  路  4Comments  路  Source: dense-analysis/ale

Name: rescript
URL: https://rescript-lang.org/

A little detail: ReScript is the new syntax for bucklescript (the compiler used by reasonml). reason-language-server is compatible with this new syntax. But the fixer is different, instead of refmt --in-place we need to run bsc -format % -o %.

Please let me know if I can be of any help, I'm not very familiar with the inner workings of ALE but I might be able to help with more details about rescript if needed.

new tool

Most helpful comment

I've made a post in the forum to reach more people. https://forum.rescript-lang.org/t/vim-ale-rescript-support/632

I've hacked together fixer support in my vim config:

let g:ale_fixers = {
\   'rescript': [
\     {buffers -> {
\       'command': 'bsc -color never -format %t'
\     }},
\   ],
\}

Works well but it doesn't have the fancy support like other fixers to find the right executables in node modules or globally.

Re: linter, like I mention in the post ryyppy鈥檚 vim-rescript fork has a function rescript#parsing#ParseCompilerErrorOutput(lines) that is supposed to parse errors into quickfix format. Maybe it could be a good start for making a linter.

All 4 comments

If I try running :!bsc -format % -o % in the vim command line this shows the output of the formatted file but it doesn't put it into the buffer. You can however run :!bsrefmt --in-place %. bsrefmt also gets installed when you install bs-platform.

bsc is included with bs-platform as well. The problem here is that bsrefmt is meant for the reasonml syntax, bsc -format for the new/rescript syntax (and they are not compatible).
You're right the command I provided doesn't seem to work as intended but, :%!bsc -format % -o - seems to do the trick.

Ah - thanks for that :%!bsc -format % -o - works.

I've just tested bsc and it starts giving reason-language-server linting errors for my Reason file (old style *.re).

I think there needs to be a new filetype rescript / ReScript that uses bsc and the current reason filetype should switch to bsrefmt.

I've made a post in the forum to reach more people. https://forum.rescript-lang.org/t/vim-ale-rescript-support/632

I've hacked together fixer support in my vim config:

let g:ale_fixers = {
\   'rescript': [
\     {buffers -> {
\       'command': 'bsc -color never -format %t'
\     }},
\   ],
\}

Works well but it doesn't have the fancy support like other fixers to find the right executables in node modules or globally.

Re: linter, like I mention in the post ryyppy鈥檚 vim-rescript fork has a function rescript#parsing#ParseCompilerErrorOutput(lines) that is supposed to parse errors into quickfix format. Maybe it could be a good start for making a linter.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lervag picture lervag  路  3Comments

ilyakopy picture ilyakopy  路  4Comments

catbaron0 picture catbaron0  路  3Comments

amerov picture amerov  路  4Comments

janhellmich picture janhellmich  路  3Comments