diff options
author | w0rp <w0rp@users.noreply.github.com> | 2018-08-10 18:28:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-10 18:28:38 +0100 |
commit | 6167f756280c6d4d10a5d6dc7453393588d90178 (patch) | |
tree | dbf30d13f49cd3598b7ed3a39d51ddc6a6b9a498 /autoload | |
parent | a56e801567907c683987858dc9a7a913c2d0cec4 (diff) | |
parent | 63c66dc5d2bd37cdd1c5abd78e635bfc3b08e14c (diff) | |
download | ale-6167f756280c6d4d10a5d6dc7453393588d90178.zip |
Merge pull request #1802 from flybayer/fix-prettier-d
Don't use error output from prettier_d for fixing files
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/prettier.vim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim index 9a4a5d8e..608240a5 100644 --- a/autoload/ale/fixers/prettier.vim +++ b/autoload/ale/fixers/prettier.vim @@ -27,6 +27,17 @@ function! ale#fixers#prettier#Fix(buffer) abort \} endfunction +function! ale#fixers#prettier#ProcessPrettierDOutput(buffer, output) abort + " If the output is an error message, don't use it. + for l:line in a:output[:10] + if l:line =~# '^\w*Error:' + return [] + endif + endfor + + return a:output +endfunction + function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort let l:executable = ale#fixers#prettier#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'javascript_prettier_options') @@ -62,6 +73,17 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort let l:options = (!empty(l:options) ? l:options . ' ' : '') . '--parser ' . l:parser endif + " Special error handling needed for prettier_d + if l:executable =~# 'prettier_d$' + return { + \ 'command': ale#path#BufferCdString(a:buffer) + \ . ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin-filepath %s --stdin', + \ 'process_with': 'ale#fixers#prettier#ProcessPrettierDOutput', + \} + endif + " 1.4.0 is the first version with --stdin-filepath if ale#semver#GTE(l:version, [1, 4, 0]) return { |