I’ve been revamping my neovim setup to switch from coc to the neovim lsp. I found that the neoformat plugin was working better than the lsp formatting for most languages, but it doesn’t support Rescript out of the box. If anyone else is in this situation, the fix is to create the file ~/.config/nvim/autoload/neoformat/formatters/rescript.vim
as follows:
function! neoformat#formatters#rescript#enabled() abort
return ['rescript']
endfunction
function! neoformat#formatters#rescript#rescript() abort
return {
\ 'exe': 'rescript',
\ 'args': ['format', '-stdin', '.res'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction