mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 05:04:28 +08:00
Rewrite Alex Integration to Use stdin (#3982)
Since having been added, the `alex` tool has added support for linting on stdin. Rewrite this integration to reduce the number of tools requiring disk-write access. Signed-off-by: David Houston <houstdav000@gmail.com>
This commit is contained in:
@@ -11,8 +11,9 @@ endfunction
|
|||||||
|
|
||||||
function! ale#handlers#alex#CreateCommandCallback(flags) abort
|
function! ale#handlers#alex#CreateCommandCallback(flags) abort
|
||||||
return {b -> ale#node#Executable(b, ale#handlers#alex#GetExecutable(b))
|
return {b -> ale#node#Executable(b, ale#handlers#alex#GetExecutable(b))
|
||||||
\ . ' %s '
|
\ . ' --stdin '
|
||||||
\ . a:flags}
|
\ . a:flags
|
||||||
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#handlers#alex#Handle(buffer, lines) abort
|
function! ale#handlers#alex#Handle(buffer, lines) abort
|
||||||
@@ -38,6 +39,7 @@ endfunction
|
|||||||
" Define a linter for a specific filetype. Accept flags to adapt to the filetype.
|
" Define a linter for a specific filetype. Accept flags to adapt to the filetype.
|
||||||
" no flags treat input as markdown
|
" no flags treat input as markdown
|
||||||
" --html treat input as HTML
|
" --html treat input as HTML
|
||||||
|
" --mdx treat input as MDX
|
||||||
" --text treat input as plaintext
|
" --text treat input as plaintext
|
||||||
function! ale#handlers#alex#DefineLinter(filetype, flags) abort
|
function! ale#handlers#alex#DefineLinter(filetype, flags) abort
|
||||||
call ale#Set('alex_executable', 'alex')
|
call ale#Set('alex_executable', 'alex')
|
||||||
@@ -49,6 +51,5 @@ function! ale#handlers#alex#DefineLinter(filetype, flags) abort
|
|||||||
\ 'command': ale#handlers#alex#CreateCommandCallback(a:flags),
|
\ 'command': ale#handlers#alex#CreateCommandCallback(a:flags),
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'callback': 'ale#handlers#alex#Handle',
|
\ 'callback': 'ale#handlers#alex#Handle',
|
||||||
\ 'lint_file': 1,
|
|
||||||
\})
|
\})
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Notes:
|
|||||||
* `apkbuild-lint`
|
* `apkbuild-lint`
|
||||||
* `secfixes-check`
|
* `secfixes-check`
|
||||||
* AsciiDoc
|
* AsciiDoc
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `languagetool`!!
|
* `languagetool`!!
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `redpen`
|
* `redpen`
|
||||||
@@ -227,7 +227,7 @@ Notes:
|
|||||||
* HCL
|
* HCL
|
||||||
* `terraform-fmt`
|
* `terraform-fmt`
|
||||||
* HTML
|
* HTML
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `angular`
|
* `angular`
|
||||||
* `fecs`
|
* `fecs`
|
||||||
* `html-beautify`
|
* `html-beautify`
|
||||||
@@ -286,7 +286,7 @@ Notes:
|
|||||||
* `ktlint`
|
* `ktlint`
|
||||||
* `languageserver`
|
* `languageserver`
|
||||||
* LaTeX (tex)
|
* LaTeX (tex)
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `chktex`
|
* `chktex`
|
||||||
* `lacheck`
|
* `lacheck`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
@@ -308,14 +308,14 @@ Notes:
|
|||||||
* `luafmt`
|
* `luafmt`
|
||||||
* `stylua`
|
* `stylua`
|
||||||
* Mail
|
* Mail
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `languagetool`!!
|
* `languagetool`!!
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `vale`
|
* `vale`
|
||||||
* Make
|
* Make
|
||||||
* `checkmake`
|
* `checkmake`
|
||||||
* Markdown
|
* Markdown
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `languagetool`!!
|
* `languagetool`!!
|
||||||
* `markdownlint`!!
|
* `markdownlint`!!
|
||||||
* `mdl`
|
* `mdl`
|
||||||
@@ -344,7 +344,7 @@ Notes:
|
|||||||
* `rnix-lsp`
|
* `rnix-lsp`
|
||||||
* `statix`
|
* `statix`
|
||||||
* nroff
|
* nroff
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `write-good`
|
* `write-good`
|
||||||
* Objective-C
|
* Objective-C
|
||||||
@@ -390,12 +390,12 @@ Notes:
|
|||||||
* `psalm`!!
|
* `psalm`!!
|
||||||
* `tlint`
|
* `tlint`
|
||||||
* PO
|
* PO
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `msgfmt`
|
* `msgfmt`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `write-good`
|
* `write-good`
|
||||||
* Pod
|
* Pod
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `write-good`
|
* `write-good`
|
||||||
* Pony
|
* Pony
|
||||||
@@ -458,7 +458,7 @@ Notes:
|
|||||||
* `reason-language-server`
|
* `reason-language-server`
|
||||||
* `refmt`
|
* `refmt`
|
||||||
* reStructuredText
|
* reStructuredText
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `redpen`
|
* `redpen`
|
||||||
* `rstcheck`
|
* `rstcheck`
|
||||||
@@ -541,11 +541,11 @@ Notes:
|
|||||||
* `terraform-lsp`
|
* `terraform-lsp`
|
||||||
* `tflint`
|
* `tflint`
|
||||||
* Texinfo
|
* Texinfo
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `write-good`
|
* `write-good`
|
||||||
* Text^
|
* Text^
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `languagetool`!!
|
* `languagetool`!!
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `redpen`
|
* `redpen`
|
||||||
@@ -585,14 +585,14 @@ Notes:
|
|||||||
* `vimls`
|
* `vimls`
|
||||||
* `vint`
|
* `vint`
|
||||||
* Vim help^
|
* Vim help^
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `write-good`
|
* `write-good`
|
||||||
* Vue
|
* Vue
|
||||||
* `prettier`
|
* `prettier`
|
||||||
* `vls`
|
* `vls`
|
||||||
* XHTML
|
* XHTML
|
||||||
* `alex`!!
|
* `alex`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `write-good`
|
* `write-good`
|
||||||
* XML
|
* XML
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ formatting.
|
|||||||
* [apkbuild-lint](https://gitlab.alpinelinux.org/Leo/atools)
|
* [apkbuild-lint](https://gitlab.alpinelinux.org/Leo/atools)
|
||||||
* [secfixes-check](https://gitlab.alpinelinux.org/Leo/atools)
|
* [secfixes-check](https://gitlab.alpinelinux.org/Leo/atools)
|
||||||
* AsciiDoc
|
* AsciiDoc
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [languagetool](https://languagetool.org/) :floppy_disk:
|
* [languagetool](https://languagetool.org/) :floppy_disk:
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
* [redpen](http://redpen.cc/)
|
* [redpen](http://redpen.cc/)
|
||||||
@@ -236,7 +236,7 @@ formatting.
|
|||||||
* HCL
|
* HCL
|
||||||
* [terraform-fmt](https://github.com/hashicorp/terraform)
|
* [terraform-fmt](https://github.com/hashicorp/terraform)
|
||||||
* HTML
|
* HTML
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [angular](https://www.npmjs.com/package/@angular/language-server)
|
* [angular](https://www.npmjs.com/package/@angular/language-server)
|
||||||
* [fecs](http://fecs.baidu.com/)
|
* [fecs](http://fecs.baidu.com/)
|
||||||
* [html-beautify](https://beautifier.io/)
|
* [html-beautify](https://beautifier.io/)
|
||||||
@@ -295,7 +295,7 @@ formatting.
|
|||||||
* [ktlint](https://ktlint.github.io)
|
* [ktlint](https://ktlint.github.io)
|
||||||
* [languageserver](https://github.com/fwcd/KotlinLanguageServer) see `:help ale-integration-kotlin` for configuration instructions
|
* [languageserver](https://github.com/fwcd/KotlinLanguageServer) see `:help ale-integration-kotlin` for configuration instructions
|
||||||
* LaTeX
|
* LaTeX
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [chktex](http://www.nongnu.org/chktex/)
|
* [chktex](http://www.nongnu.org/chktex/)
|
||||||
* [lacheck](https://www.ctan.org/pkg/lacheck)
|
* [lacheck](https://www.ctan.org/pkg/lacheck)
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
@@ -317,14 +317,14 @@ formatting.
|
|||||||
* [luafmt](https://github.com/trixnz/lua-fmt)
|
* [luafmt](https://github.com/trixnz/lua-fmt)
|
||||||
* [stylua](https://github.com/johnnymorganz/stylua)
|
* [stylua](https://github.com/johnnymorganz/stylua)
|
||||||
* Mail
|
* Mail
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [languagetool](https://languagetool.org/) :floppy_disk:
|
* [languagetool](https://languagetool.org/) :floppy_disk:
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
* [vale](https://github.com/ValeLint/vale)
|
* [vale](https://github.com/ValeLint/vale)
|
||||||
* Make
|
* Make
|
||||||
* [checkmake](https://github.com/mrtazz/checkmake)
|
* [checkmake](https://github.com/mrtazz/checkmake)
|
||||||
* Markdown
|
* Markdown
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [languagetool](https://languagetool.org/) :floppy_disk:
|
* [languagetool](https://languagetool.org/) :floppy_disk:
|
||||||
* [markdownlint](https://github.com/DavidAnson/markdownlint) :floppy_disk:
|
* [markdownlint](https://github.com/DavidAnson/markdownlint) :floppy_disk:
|
||||||
* [mdl](https://github.com/mivok/markdownlint)
|
* [mdl](https://github.com/mivok/markdownlint)
|
||||||
@@ -353,7 +353,7 @@ formatting.
|
|||||||
* [rnix-lsp](https://github.com/nix-community/rnix-lsp)
|
* [rnix-lsp](https://github.com/nix-community/rnix-lsp)
|
||||||
* [statix](https://github.com/nerdypepper/statix)
|
* [statix](https://github.com/nerdypepper/statix)
|
||||||
* nroff
|
* nroff
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
* [write-good](https://github.com/btford/write-good)
|
* [write-good](https://github.com/btford/write-good)
|
||||||
* Objective-C
|
* Objective-C
|
||||||
@@ -399,12 +399,12 @@ formatting.
|
|||||||
* [psalm](https://getpsalm.org) :floppy_disk:
|
* [psalm](https://getpsalm.org) :floppy_disk:
|
||||||
* [tlint](https://github.com/tightenco/tlint)
|
* [tlint](https://github.com/tightenco/tlint)
|
||||||
* PO
|
* PO
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html)
|
* [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html)
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
* [write-good](https://github.com/btford/write-good)
|
* [write-good](https://github.com/btford/write-good)
|
||||||
* Pod
|
* Pod
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
* [write-good](https://github.com/btford/write-good)
|
* [write-good](https://github.com/btford/write-good)
|
||||||
* Pony
|
* Pony
|
||||||
@@ -467,7 +467,7 @@ formatting.
|
|||||||
* [reason-language-server](https://github.com/jaredly/reason-language-server)
|
* [reason-language-server](https://github.com/jaredly/reason-language-server)
|
||||||
* [refmt](https://github.com/reasonml/reason-cli)
|
* [refmt](https://github.com/reasonml/reason-cli)
|
||||||
* reStructuredText
|
* reStructuredText
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
* [redpen](http://redpen.cc/)
|
* [redpen](http://redpen.cc/)
|
||||||
* [rstcheck](https://github.com/myint/rstcheck)
|
* [rstcheck](https://github.com/myint/rstcheck)
|
||||||
@@ -550,11 +550,11 @@ formatting.
|
|||||||
* [terraform-lsp](https://github.com/juliosueiras/terraform-lsp)
|
* [terraform-lsp](https://github.com/juliosueiras/terraform-lsp)
|
||||||
* [tflint](https://github.com/wata727/tflint)
|
* [tflint](https://github.com/wata727/tflint)
|
||||||
* Texinfo
|
* Texinfo
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
* [write-good](https://github.com/btford/write-good)
|
* [write-good](https://github.com/btford/write-good)
|
||||||
* Text
|
* Text
|
||||||
* [alex](https://github.com/wooorm/alex) :warning: :floppy_disk:
|
* [alex](https://github.com/get-alex/alex) :warning:
|
||||||
* [languagetool](https://languagetool.org/) :floppy_disk:
|
* [languagetool](https://languagetool.org/) :floppy_disk:
|
||||||
* [proselint](http://proselint.com/) :warning:
|
* [proselint](http://proselint.com/) :warning:
|
||||||
* [redpen](http://redpen.cc/) :warning:
|
* [redpen](http://redpen.cc/) :warning:
|
||||||
@@ -594,14 +594,14 @@ formatting.
|
|||||||
* [vimls](https://github.com/iamcco/vim-language-server)
|
* [vimls](https://github.com/iamcco/vim-language-server)
|
||||||
* [vint](https://github.com/Kuniwak/vint)
|
* [vint](https://github.com/Kuniwak/vint)
|
||||||
* Vim help
|
* Vim help
|
||||||
* [alex](https://github.com/wooorm/alex) :warning: :floppy_disk:
|
* [alex](https://github.com/get-alex/alex) :warning:
|
||||||
* [proselint](http://proselint.com/) :warning:
|
* [proselint](http://proselint.com/) :warning:
|
||||||
* [write-good](https://github.com/btford/write-good) :warning:
|
* [write-good](https://github.com/btford/write-good) :warning:
|
||||||
* Vue
|
* Vue
|
||||||
* [prettier](https://github.com/prettier/prettier)
|
* [prettier](https://github.com/prettier/prettier)
|
||||||
* [vls](https://github.com/vuejs/vetur/tree/master/server)
|
* [vls](https://github.com/vuejs/vetur/tree/master/server)
|
||||||
* XHTML
|
* XHTML
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
* [write-good](https://github.com/btford/write-good)
|
* [write-good](https://github.com/btford/write-good)
|
||||||
* XML
|
* XML
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ After:
|
|||||||
|
|
||||||
Execute(The global executable should be used when the local one cannot be found):
|
Execute(The global executable should be used when the local one cannot be found):
|
||||||
AssertLinter 'alex',
|
AssertLinter 'alex',
|
||||||
\ ale#Escape('alex') . ' %s --text',
|
\ ale#Escape('alex') . ' --stdin --text',
|
||||||
|
|
||||||
Execute(Should use the node_modules/.bin executable, if available):
|
Execute(Should use the node_modules/.bin executable, if available):
|
||||||
call ale#test#SetFilename('../test-files/alex/node-modules/test_file.tex')
|
call ale#test#SetFilename('../test-files/alex/node-modules/test_file.tex')
|
||||||
|
|
||||||
AssertLinter ale#path#Simplify(g:dir . '/../test-files/alex/node-modules/node_modules/.bin/alex'),
|
AssertLinter ale#path#Simplify(g:dir . '/../test-files/alex/node-modules/node_modules/.bin/alex'),
|
||||||
\ ale#Escape(ale#path#Simplify(g:dir . '/../test-files/alex/node-modules/node_modules/.bin/alex'))
|
\ ale#Escape(ale#path#Simplify(g:dir . '/../test-files/alex/node-modules/node_modules/.bin/alex'))
|
||||||
\ . ' %s --text',
|
\ . ' --stdin --text',
|
||||||
|
|
||||||
Execute(Should use the node_modules/alex executable, if available):
|
Execute(Should use the node_modules/alex executable, if available):
|
||||||
call ale#test#SetFilename('../test-files/alex/node-modules-2/test_file.tex')
|
call ale#test#SetFilename('../test-files/alex/node-modules-2/test_file.tex')
|
||||||
@@ -22,7 +22,7 @@ Execute(Should use the node_modules/alex executable, if available):
|
|||||||
AssertLinter ale#path#Simplify(g:dir . '/../test-files/alex/node-modules-2/node_modules/alex/cli.js'),
|
AssertLinter ale#path#Simplify(g:dir . '/../test-files/alex/node-modules-2/node_modules/alex/cli.js'),
|
||||||
\ (has('win32') ? 'node.exe ' : '')
|
\ (has('win32') ? 'node.exe ' : '')
|
||||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/alex/node-modules-2/node_modules/alex/cli.js'))
|
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/alex/node-modules-2/node_modules/alex/cli.js'))
|
||||||
\ . ' %s --text',
|
\ . ' --stdin --text',
|
||||||
|
|
||||||
Execute(Should let users configure a global executable and override local paths):
|
Execute(Should let users configure a global executable and override local paths):
|
||||||
call ale#test#SetFilename('../test-files/write-good/node-modules-2/test_file.tex')
|
call ale#test#SetFilename('../test-files/write-good/node-modules-2/test_file.tex')
|
||||||
@@ -31,4 +31,4 @@ Execute(Should let users configure a global executable and override local paths)
|
|||||||
let g:ale_alex_use_global = 1
|
let g:ale_alex_use_global = 1
|
||||||
|
|
||||||
AssertLinter '/path/to/custom/alex',
|
AssertLinter '/path/to/custom/alex',
|
||||||
\ ale#Escape('/path/to/custom/alex') . ' %s --text'
|
\ ale#Escape('/path/to/custom/alex') . ' --stdin --text'
|
||||||
|
|||||||
Reference in New Issue
Block a user