summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2017-06-28 17:35:19 +0200
committerw0rp <w0rp@users.noreply.github.com>2017-06-28 16:35:19 +0100
commit7eec1f2efc01b0674ccc96baaa4f529d803ddf55 (patch)
treefe44e456c8687ac1009e80dd83a3dbce246b942e
parent8846a8860f39027c0c2a7aba9e49ad2fdacd5428 (diff)
downloadale-7eec1f2efc01b0674ccc96baaa4f529d803ddf55.zip
Add prettier-standard support (#702)
* Add prettier-standard support * Update ale-javascript.txt Remove a duplicated header line.
-rw-r--r--README.md2
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/prettier_standard.vim24
-rw-r--r--doc/ale-javascript.txt31
-rw-r--r--doc/ale.txt1
5 files changed, 62 insertions, 1 deletions
diff --git a/README.md b/README.md
index 223c8d00..b875ad4c 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 0dbbc0c5..176baadf 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 00000000..7d938e19
--- /dev/null
+++ b/autoload/ale/fixers/prettier_standard.vim
@@ -0,0 +1,24 @@
+" Author: sheerun (Adam Stankiewicz) <sheerun@sher.pl>
+" 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 296cb901..067eee6f 100644
--- a/doc/ale-javascript.txt
+++ b/doc/ale-javascript.txt
@@ -119,6 +119,37 @@ g:ale_javascript_prettier_eslint_use_global
-------------------------------------------------------------------------------
+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*
g:ale_javascript_flow_executable *g:ale_javascript_flow_executable*
diff --git a/doc/ale.txt b/doc/ale.txt
index 81999ab0..0c2ecbb7 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|