Format reason file in neovim


#1

Hi, i’m still wondering, how to format reason file in neovim?
currently i’m using these extensions:

  • vim-reason-plus (syntax highlight)
  • coc (autocomplete) + coc-reason extension

any idea?


#2

With this setting in your :CocConfig it should format on save for .re and .rei files.

  "coc.preferences.formatOnSaveFiletypes": [
    "reason"
  ]

#3

@believer 's answer should work when you want to format the file on save.
But if you need do this manually (by hotkey) you have to map your desired shortcut to coc’s format command :call CocAction('fomrat') . I use <leader>f for example.

nmap <silent> <leader>f :call CocAction('format')<CR>

#4

@believer @amiralies thanks it work, ah now i can peacefully continue my project :triumph:


#5

do you know how can I make it work with new syntax (i.e. .res and .resi files)?


#6

sorry, there is no support yet, except syntax highlighting and formating,
syntax : https://github.com/amiralies/vim-rescript/blob/master/syntax/rescript.vim
formater : using coc with (coc-rescript)