parent
b3a9a0e3e8
commit
f3da8f45c1
8 changed files with 137 additions and 2 deletions
|
@ -87,7 +87,7 @@ formatting.
|
||||||
| Dart | [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) |
|
| Dart | [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) |
|
||||||
| Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) |
|
| Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) |
|
||||||
| Elixir | [credo](https://github.com/rrrene/credo), [dogma](https://github.com/lpil/dogma) !! |
|
| Elixir | [credo](https://github.com/rrrene/credo), [dogma](https://github.com/lpil/dogma) !! |
|
||||||
| Elm | [elm-make](https://github.com/elm-lang/elm-make) |
|
| Elm | [elm-make](https://github.com/elm-lang/elm-make), [elm-format](https://github.com/avh4/elm-format) |
|
||||||
| Erb | [erb](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) |
|
| Erb | [erb](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) |
|
||||||
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |
|
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |
|
||||||
| Fortran | [gcc](https://gcc.gnu.org/) |
|
| Fortran | [gcc](https://gcc.gnu.org/) |
|
||||||
|
|
|
@ -27,6 +27,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
||||||
\ 'description': 'Apply eslint --fix to a file.',
|
\ 'description': 'Apply eslint --fix to a file.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'format': {
|
||||||
|
\ 'function': 'ale#fixers#format#Fix',
|
||||||
|
\ 'suggested_filetypes': ['elm'],
|
||||||
|
\ 'description': 'Apply elm-format to a file.',
|
||||||
|
\ },
|
||||||
\ 'isort': {
|
\ 'isort': {
|
||||||
\ 'function': 'ale#fixers#isort#Fix',
|
\ 'function': 'ale#fixers#isort#Fix',
|
||||||
\ 'suggested_filetypes': ['python'],
|
\ 'suggested_filetypes': ['python'],
|
||||||
|
|
23
autoload/ale/fixers/format.vim
Normal file
23
autoload/ale/fixers/format.vim
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
" Author: soywod <clement.douin@gmail.com>
|
||||||
|
" Description: Integration of elm-format with ALE.
|
||||||
|
|
||||||
|
call ale#Set('elm_format_executable', 'elm-format')
|
||||||
|
call ale#Set('elm_format_use_global', 0)
|
||||||
|
call ale#Set('elm_format_options', '--yes')
|
||||||
|
|
||||||
|
function! ale#fixers#format#GetExecutable(buffer) abort
|
||||||
|
return ale#node#FindExecutable(a:buffer, 'elm_format', [
|
||||||
|
\ 'node_modules/.bin/elm-format',
|
||||||
|
\])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale#fixers#format#Fix(buffer) abort
|
||||||
|
let l:options = ale#Var(a:buffer, 'elm_format_options')
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(ale#fixers#format#GetExecutable(a:buffer))
|
||||||
|
\ . ' %t'
|
||||||
|
\ . (empty(l:options) ? '' : ' ' . l:options),
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\}
|
||||||
|
endfunction
|
32
doc/ale-elm.txt
Normal file
32
doc/ale-elm.txt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
===============================================================================
|
||||||
|
ALE Elm Integration *ale-elm-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
elm-format *ale-elm-format*
|
||||||
|
|
||||||
|
g:ale_elm_format_executable *g:ale_elm_format_executable*
|
||||||
|
*b:ale_elm_format_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'elm-format'`
|
||||||
|
|
||||||
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_elm_format_use_global *g:ale_elm_format_use_global*
|
||||||
|
*b:ale_elm_format_use_global*
|
||||||
|
Type: |Number|
|
||||||
|
Default: `0`
|
||||||
|
|
||||||
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_elm_format_options *g:ale_elm_format_options*
|
||||||
|
*b:ale_elm_format_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'--yes'`
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to elm-format.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
|
@ -217,7 +217,7 @@ Notes:
|
||||||
* Dart: `dartanalyzer`
|
* Dart: `dartanalyzer`
|
||||||
* Dockerfile: `hadolint`
|
* Dockerfile: `hadolint`
|
||||||
* Elixir: `credo`, `dogma`!!
|
* Elixir: `credo`, `dogma`!!
|
||||||
* Elm: `elm-make`
|
* Elm: `elm-make, elm-format`
|
||||||
* Erb: `erb`, `erubis`
|
* Erb: `erb`, `erubis`
|
||||||
* Erlang: `erlc`, `SyntaxErl`
|
* Erlang: `erlc`, `SyntaxErl`
|
||||||
* Fortran: `gcc`
|
* Fortran: `gcc`
|
||||||
|
|
0
test/elm-test-files/node_modules/.bin/elm-format
generated
vendored
Normal file
0
test/elm-test-files/node_modules/.bin/elm-format
generated
vendored
Normal file
0
test/elm-test-files/src/subdir/testfile.elm
Normal file
0
test/elm-test-files/src/subdir/testfile.elm
Normal file
75
test/fixers/test_elm_format_fixer_callback.vader
Normal file
75
test/fixers/test_elm_format_fixer_callback.vader
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
Before:
|
||||||
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
|
||||||
|
After:
|
||||||
|
unlet! b:ale_elm_format_executable
|
||||||
|
unlet! b:ale_elm_format_use_global
|
||||||
|
unlet! b:ale_elm_format_options
|
||||||
|
|
||||||
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
|
Execute(The elm-format command should have default params):
|
||||||
|
call ale#test#SetFilename('../elm-test-files/src/subdir/testfile.elm')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command':
|
||||||
|
\ ale#Escape(simplify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format'))
|
||||||
|
\ . ' %t --yes',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#format#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The elm-format command should manage use_global = 1 param):
|
||||||
|
call ale#test#SetFilename('../elm-test-files/src/subdir/testfile.elm')
|
||||||
|
let b:ale_elm_format_use_global = 1
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command':
|
||||||
|
\ ale#Escape('elm-format')
|
||||||
|
\ . ' %t --yes',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#format#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The elm-format command should manage executable param):
|
||||||
|
call ale#test#SetFilename('../elm-test-files/src/subdir/testfile.elm')
|
||||||
|
let b:ale_elm_format_use_global = 1
|
||||||
|
let b:ale_elm_format_executable = 'elmformat'
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command':
|
||||||
|
\ ale#Escape('elmformat')
|
||||||
|
\ . ' %t --yes',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#format#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The elm-format command should manage empty options):
|
||||||
|
call ale#test#SetFilename('../elm-test-files/src/subdir/testfile.elm')
|
||||||
|
let b:ale_elm_format_options = ''
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command':
|
||||||
|
\ ale#Escape(simplify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format'))
|
||||||
|
\ . ' %t',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#format#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The elm-format command should manage custom options):
|
||||||
|
call ale#test#SetFilename('../elm-test-files/src/subdir/testfile.elm')
|
||||||
|
let b:ale_elm_format_options = '--param1 --param2'
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command':
|
||||||
|
\ ale#Escape(simplify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format'))
|
||||||
|
\ . ' %t --param1 --param2',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#format#Fix(bufnr(''))
|
||||||
|
|
Reference in a new issue