refmt fixer for ReasonML
This commit is contained in:
parent
1aa737cdc9
commit
634eb1920c
7 changed files with 83 additions and 2 deletions
|
@ -126,7 +126,7 @@ formatting.
|
||||||
| Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) |
|
| Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) |
|
||||||
| Python | [autopep8](https://github.com/hhatto/autopep8), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pylint](https://www.pylint.org/) !!, [yapf](https://github.com/google/yapf) |
|
| Python | [autopep8](https://github.com/hhatto/autopep8), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pylint](https://www.pylint.org/) !!, [yapf](https://github.com/google/yapf) |
|
||||||
| R | [lintr](https://github.com/jimhester/lintr) |
|
| R | [lintr](https://github.com/jimhester/lintr) |
|
||||||
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions |
|
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions, [refmt](https://github.com/reasonml/reason-cli) |
|
||||||
| reStructuredText | [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
|
| reStructuredText | [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
|
||||||
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
||||||
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org) |
|
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org) |
|
||||||
|
|
|
@ -127,6 +127,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['haskell'],
|
\ 'suggested_filetypes': ['haskell'],
|
||||||
\ 'description': 'Fix Haskell files with hfmt.',
|
\ 'description': 'Fix Haskell files with hfmt.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'refmt': {
|
||||||
|
\ 'function': 'ale#fixers#refmt#Fix',
|
||||||
|
\ 'suggested_filetypes': ['reason'],
|
||||||
|
\ 'description': 'Fix ReasonML files with refmt.',
|
||||||
|
\ },
|
||||||
\}
|
\}
|
||||||
|
|
||||||
" Reset the function registry to the default entries.
|
" Reset the function registry to the default entries.
|
||||||
|
|
18
autoload/ale/fixers/refmt.vim
Normal file
18
autoload/ale/fixers/refmt.vim
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
" Author: Ahmed El Gabri <@ahmedelgabri>
|
||||||
|
" Description: Integration of refmt with ALE.
|
||||||
|
|
||||||
|
call ale#Set('reasonml_refmt_executable', 'refmt')
|
||||||
|
call ale#Set('reasonml_refmt_options', '')
|
||||||
|
|
||||||
|
function! ale#fixers#refmt#Fix(buffer) abort
|
||||||
|
let l:executable = ale#Var(a:buffer, 'reasonml_refmt_executable')
|
||||||
|
let l:options = ale#Var(a:buffer, 'reasonml_refmt_options')
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable)
|
||||||
|
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||||
|
\ . ' --in-place'
|
||||||
|
\ . ' %t',
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\}
|
||||||
|
endfunction
|
|
@ -10,6 +10,22 @@ merlin *ale-reasonml-merlin*
|
||||||
detailed instructions
|
detailed instructions
|
||||||
(https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch).
|
(https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch).
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
refmt *ale-reasonml-refmt*
|
||||||
|
|
||||||
|
g:ale_reasonml_refmt_executable *g:ale_reasonml_refmt_executable*
|
||||||
|
*b:ale_reasonml_refmt_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'refmt'`
|
||||||
|
|
||||||
|
This variable can be set to pass the path of the refmt fixer.
|
||||||
|
|
||||||
|
g:ale_reasonml_refmt_options *g:ale_reasonml_refmt_options*
|
||||||
|
*b:ale_reasonml_refmt_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to the refmt fixer.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|
|
@ -150,6 +150,7 @@ CONTENTS *ale-contents*
|
||||||
lintr...............................|ale-r-lintr|
|
lintr...............................|ale-r-lintr|
|
||||||
reasonml..............................|ale-reasonml-options|
|
reasonml..............................|ale-reasonml-options|
|
||||||
merlin..............................|ale-reasonml-merlin|
|
merlin..............................|ale-reasonml-merlin|
|
||||||
|
refmt...............................|ale-reasonml-refmt|
|
||||||
restructuredtext......................|ale-restructuredtext-options|
|
restructuredtext......................|ale-restructuredtext-options|
|
||||||
write-good..........................|ale-restructuredtext-write-good|
|
write-good..........................|ale-restructuredtext-write-good|
|
||||||
ruby..................................|ale-ruby-options|
|
ruby..................................|ale-ruby-options|
|
||||||
|
@ -308,7 +309,7 @@ Notes:
|
||||||
* Puppet: `puppet`, `puppet-lint`
|
* Puppet: `puppet`, `puppet-lint`
|
||||||
* Python: `autopep8`, `flake8`, `isort`, `mypy`, `pycodestyle`, `pylint`!!, `yapf`
|
* Python: `autopep8`, `flake8`, `isort`, `mypy`, `pycodestyle`, `pylint`!!, `yapf`
|
||||||
* R: `lintr`
|
* R: `lintr`
|
||||||
* ReasonML: `merlin`
|
* ReasonML: `merlin`, `refmt`
|
||||||
* reStructuredText: `proselint`, `write-good`
|
* reStructuredText: `proselint`, `write-good`
|
||||||
* RPM spec: `rpmlint`
|
* RPM spec: `rpmlint`
|
||||||
* Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby`
|
* Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby`
|
||||||
|
|
41
test/fixers/test_refmt_fixer_callback.vader
Normal file
41
test/fixers/test_refmt_fixer_callback.vader
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
Before:
|
||||||
|
Save g:ale_reasonml_refmt_executable
|
||||||
|
Save g:ale_reasonml_refmt_options
|
||||||
|
|
||||||
|
" Use an invalid global executable, so we don't match it.
|
||||||
|
let g:ale_reasonml_refmt_executable = 'xxxinvalid'
|
||||||
|
let g:ale_reasonml_refmt_options = ''
|
||||||
|
|
||||||
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
|
Execute(The refmt callback should return the correct default values):
|
||||||
|
call ale#test#SetFilename('../reasonml_files/testfile.re')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command': ale#Escape('xxxinvalid')
|
||||||
|
\ . ' --in-place'
|
||||||
|
\ . ' %t',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#refmt#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The refmt callback should include custom refmt options):
|
||||||
|
let g:ale_reasonml_refmt_options = "-w 80"
|
||||||
|
call ale#test#SetFilename('../reasonml_files/testfile.re')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command': ale#Escape('xxxinvalid')
|
||||||
|
\ . ' ' . g:ale_reasonml_refmt_options
|
||||||
|
\ . ' --in-place'
|
||||||
|
\ . ' %t',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#refmt#Fix(bufnr(''))
|
||||||
|
|
0
test/reasonml_files/testfile.re
Normal file
0
test/reasonml_files/testfile.re
Normal file
Reference in a new issue