diff --git a/README.md b/README.md index 223c8d0..b875ad4 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ name. That seems to be the fairest way to arrange this table. | Haskell | [ghc](https://www.haskell.org/ghc/), [ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools) | | HTML | [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/) | | Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) | -| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [standard](http://standardjs.com/), [prettier](https://github.com/prettier/prettier) (and `prettier-eslint`), [xo](https://github.com/sindresorhus/xo) +| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [standard](http://standardjs.com/), [prettier](https://github.com/prettier/prettier) (and `prettier-eslint`, `prettier-standard`), [xo](https://github.com/sindresorhus/xo) | JSON | [jsonlint](http://zaa.ch/jsonlint/) | | Kotlin | [kotlinc](https://kotlinlang.org), [ktlint](https://ktlint.github.io) see `:help ale-integration-kotlin` for configuration instructions | LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/) | diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 0dbbc0c..176baad 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -12,6 +12,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['python'], \ 'description': 'Fix PEP8 issues with autopep8.', \ }, +\ 'prettier_standard': { +\ 'function': 'ale#fixers#prettier_standard#Fix', +\ 'suggested_filetypes': ['javascript'], +\ 'description': 'Apply prettier-standard to a file.', +\ }, \ 'eslint': { \ 'function': 'ale#fixers#eslint#Fix', \ 'suggested_filetypes': ['javascript', 'typescript'], diff --git a/autoload/ale/fixers/prettier_standard.vim b/autoload/ale/fixers/prettier_standard.vim new file mode 100644 index 0000000..7d938e1 --- /dev/null +++ b/autoload/ale/fixers/prettier_standard.vim @@ -0,0 +1,24 @@ +" Author: sheerun (Adam Stankiewicz) +" Description: Integration of Prettier Standard with ALE. + +call ale#Set('javascript_prettier_standard_executable', 'prettier-standard') +call ale#Set('javascript_prettier_standard_use_global', 0) +call ale#Set('javascript_prettier_standard_options', '') + +function! ale#fixers#prettier_standard#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'javascript_prettier_standard', [ + \ 'node_modules/prettier-standard/lib/index.js', + \ 'node_modules/.bin/prettier-standard', + \]) +endfunction + +function! ale#fixers#prettier_standard#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'javascript_prettier_standard_options') + + return { + \ 'command': ale#Escape(ale#fixers#prettier_standard#GetExecutable(a:buffer)) + \ . ' %t' + \ . ' ' . l:options, + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/doc/ale-javascript.txt b/doc/ale-javascript.txt index 296cb90..067eee6 100644 --- a/doc/ale-javascript.txt +++ b/doc/ale-javascript.txt @@ -118,6 +118,37 @@ g:ale_javascript_prettier_eslint_use_global See |ale-integrations-local-executables| +------------------------------------------------------------------------------- +prettier-standard *ale-javascript-prettier-eslint* + + +g:ale_javascript_prettier_standard_executable + *g:ale_javascript_prettier_eslint_executable* + *b:ale_javascript_prettier_eslint_executable* + Type: |String| + Default: `'prettier-standard'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_prettier_standard_options + *g:ale_javascript_prettier_standard_options* + *b:ale_javascript_prettier_standard_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to prettier-standard. + + +g:ale_javascript_prettier_standard_use_global + *g:ale_javascript_prettier_standard_use_global* + *b:ale_javascript_prettier_standard_use_global* + Type: |Number| + Default: `0` + + See |ale-integrations-local-executables| + + ------------------------------------------------------------------------------- flow *ale-javascript-flow* diff --git a/doc/ale.txt b/doc/ale.txt index 81999ab..0c2ecbb 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -53,6 +53,7 @@ CONTENTS *ale-contents* jshint..............................|ale-javascript-jshint| prettier............................|ale-javascript-prettier| prettier-eslint.....................|ale-javascript-prettier-eslint| + prettier-standard...................|ale-javascript-prettier-standard| standard............................|ale-javascript-standard| xo..................................|ale-javascript-xo| kotlin................................|ale-kotlin-options|