diff options
author | Paul Reimer <paulreimer@users.noreply.github.com> | 2018-08-02 12:20:19 -0700 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2018-08-02 20:20:19 +0100 |
commit | cb8ad9fbd82df92993e526a8e48d4400ba08936b (patch) | |
tree | cfd921f3daa66ead4c7612041eea5e2f7d431e20 /autoload | |
parent | 649934230bf9e10d3597814986cffca955b2fe05 (diff) | |
download | ale-cb8ad9fbd82df92993e526a8e48d4400ba08936b.zip |
Javascript prettier filetype detect fix (#1769)
Support fixing YAML and HTML files with prettier for files without file extensions.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/prettier.vim | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim index e8f4e92e..9a4a5d8e 100644 --- a/autoload/ale/fixers/prettier.vim +++ b/autoload/ale/fixers/prettier.vim @@ -36,12 +36,23 @@ 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 - let l:prettier_parsers = ['typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue'] - let l:parser = 'babylon' + let l:prettier_parsers = { + \ 'typescript': 'typescript', + \ 'css': 'css', + \ 'less': 'less', + \ 'scss': 'scss', + \ 'json': 'json', + \ 'json5': 'json5', + \ 'graphql': 'graphql', + \ 'markdown': 'markdown', + \ 'vue': 'vue', + \ 'yaml': 'yaml', + \} + let l:parser = '' for l:filetype in split(getbufvar(a:buffer, '&filetype'), '\.') - if index(l:prettier_parsers, l:filetype) > -1 - let l:parser = l:filetype + if has_key(l:prettier_parsers, l:filetype) + let l:parser = l:prettier_parsers[l:filetype] break endif endfor |