New update, things are working!
With the last updates to vim-rescript and rescript-vscode plugin, now we can easily add a linter to vim-ale.
Setup
Install GitHub - rescript-lang/vim-rescript. For example with Plug 'rescript-lang/vim-rescript', and then running :PlugInstall
On your vim configuration folder, create plugin/rescript_ale.vim, with this content (replace the path to your vim-rescript plugin folder in the first line with yours):
call ale#Set('rescript_lsp_js_file', '~/.vim/plugged/vim-rescript/server/out/server.js') " Give vim-ale the rescript executable to check because the LSP server is " a non-executable JS file call ale#Set('rescript_executable', 'rescript') call ale#Set('rescript_use_global', get(g:, 'ale_use_global_executables', 1)) function! rescript_ale#GetRootDir(buffer) abort let l:config = ale#path#FindNearestFile(a:buffer, 'bsconfig.json') return !empty(l:config) ? fnamemodify(l:config, ':p:h') : '' endfunction function! FormatRescript(buffer) abort return { \ 'command': 'rescript format -stdin .res' \} endfunction call ale#fix#registry#Add('rescript', 'FormatRescript', ['rescript'], 'rescript formatter') call ale#linter#Define('rescript', { \ 'name': 'rescript', \ 'lsp': 'stdio', \ 'executable': {b -> ale#node#FindExecutable(b, 'rescript', [ \ 'node_modules/.bin/rescript', \ 'rescript' \ ])}, \ 'command': {b -> 'node ' . ale#Var(b, 'rescript_lsp_js_file') . ' --stdio'}, \ 'project_root': function('rescript_ale#GetRootDir'), \ 'language': 'rescript', \})
On your vim configuration, init.vim or .vimrc for example, configure ale:
let g:ale_linters = { \ 'rescript': ['rescript'], \} let g:ale_fixers = { \ 'rescript': ['rescript'], \}
And that’s it! Remember to run rescript build -w on your rescript project to get up to date diagnostics.
At this point I’m not sure if this should be in vim-ale like all the other linters, or in vim-rescript, or nowhere.
Contributions to vim-ale take a longer to get accepted and merged, so if the editor story is still a WIP and may change, it doesn’t sound like a great idea.
On the other hand the configuration is minimal, so it may be interesting to keep it at least documented or added to vim-rescript so that it can be updated as the language develops.
For now I’m just happy that this works 