diff options
author | Alvin Chan <chaucerbao@users.noreply.github.com> | 2019-01-22 02:24:15 -0800 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2019-01-22 10:24:15 +0000 |
commit | f12d312aa4aa49c4698056933030cd5adb60b489 (patch) | |
tree | 3e65607877adf96c5734c873b3c8125b9a04bced /autoload | |
parent | d0284f22ea45a5e7796da2224373c22232af1777 (diff) | |
download | ale-f12d312aa4aa49c4698056933030cd5adb60b489.zip |
Add `babylon` as default Prettier parser (#2220)
* Mimic Prettier's default parser by setting it to `babylon`
* Add tests to check default Prettier `parser`
* Set Prettier default parser based on version
* Update the comment to explain the reason for an explicit default
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/prettier.vim | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim index 58dea159..95932474 100644 --- a/autoload/ale/fixers/prettier.vim +++ b/autoload/ale/fixers/prettier.vim @@ -47,6 +47,15 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort " Append the --parser flag depending on the current filetype (unless it's " already set in g:javascript_prettier_options). if empty(expand('#' . a:buffer . ':e')) && match(l:options, '--parser') == -1 + " Mimic Prettier's defaults. In cases without a file extension or + " filetype (scratch buffer), Prettier needs `parser` set to know how + " to process the buffer. + if ale#semver#GTE(l:version, [1, 16, 0]) + let l:parser = 'babel' + else + let l:parser = 'babylon' + endif + let l:prettier_parsers = { \ 'typescript': 'typescript', \ 'css': 'css', @@ -60,7 +69,6 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort \ 'yaml': 'yaml', \ 'html': 'html', \} - let l:parser = '' for l:filetype in split(getbufvar(a:buffer, '&filetype'), '\.') if has_key(l:prettier_parsers, l:filetype) |