diff options
-rw-r--r-- | autoload/ale/fixers/prettier.vim | 10 | ||||
-rw-r--r-- | doc/ale-handlebars.txt | 7 | ||||
-rw-r--r-- | doc/ale.txt | 1 | ||||
-rw-r--r-- | rplugin/python3/deoplete/sources/ale.py | 2 | ||||
-rw-r--r-- | test/fixers/test_prettier_fixer_callback.vader | 14 | ||||
-rw-r--r-- | test/python/test_deoplete_source.py | 2 |
6 files changed, 32 insertions, 4 deletions
diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim index b7f0ecd7..23120777 100644 --- a/autoload/ale/fixers/prettier.vim +++ b/autoload/ale/fixers/prettier.vim @@ -39,9 +39,15 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort let l:options = ale#Var(a:buffer, 'javascript_prettier_options') let l:parser = '' + let l:filetypes = split(getbufvar(a:buffer, '&filetype'), '\.') + + if index(l:filetypes, 'handlebars') > -1 + let l:parser = 'glimmer' + endif + " 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 + if empty(expand('#' . a:buffer . ':e')) && l:parser is# '' && 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. @@ -65,7 +71,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort \ 'html': 'html', \} - for l:filetype in split(getbufvar(a:buffer, '&filetype'), '\.') + for l:filetype in l:filetypes if has_key(l:prettier_parsers, l:filetype) let l:parser = l:prettier_parsers[l:filetype] break diff --git a/doc/ale-handlebars.txt b/doc/ale-handlebars.txt index 061c5d3c..5daec5b3 100644 --- a/doc/ale-handlebars.txt +++ b/doc/ale-handlebars.txt @@ -3,6 +3,13 @@ ALE Handlebars Integration *ale-handlebars-options* =============================================================================== +prettier *ale-handlebars-prettier* + +See |ale-javascript-prettier| for information about the available options. +Uses glimmer parser by default. + + +=============================================================================== ember-template-lint *ale-handlebars-embertemplatelint* g:ale_handlebars_embertemplatelint_executable diff --git a/doc/ale.txt b/doc/ale.txt index 6aa03a12..40ebe594 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2042,6 +2042,7 @@ documented in additional help files. hackfmt...............................|ale-hack-hackfmt| hhast.................................|ale-hack-hhast| handlebars..............................|ale-handlebars-options| + prettier..............................|ale-handlebars-prettier| ember-template-lint...................|ale-handlebars-embertemplatelint| haskell.................................|ale-haskell-options| brittany..............................|ale-haskell-brittany| diff --git a/rplugin/python3/deoplete/sources/ale.py b/rplugin/python3/deoplete/sources/ale.py index 7ed2f6c0..7f1c1d60 100644 --- a/rplugin/python3/deoplete/sources/ale.py +++ b/rplugin/python3/deoplete/sources/ale.py @@ -21,7 +21,7 @@ class Source(Base): self.name = 'ale' self.mark = '[L]' - self.rank = 100 + self.rank = 1000 self.is_bytepos = True self.min_pattern_length = 1 diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader index 9be161ac..062ae8cf 100644 --- a/test/fixers/test_prettier_fixer_callback.vader +++ b/test/fixers/test_prettier_fixer_callback.vader @@ -280,6 +280,20 @@ Execute(Should set --parser based on first filetype of multiple filetypes): \ . ' --stdin-filepath %s --stdin', \ } +Execute(Should set --parser for experimental language, Handlebars): + call ale#test#SetFilename('../prettier-test-files/testfile.hbs') + + set filetype=html.handlebars + + GivenCommandOutput ['1.6.0'] + AssertFixer + \ { + \ 'command': ale#path#CdString(expand('%:p:h')) + \ . ale#Escape(g:ale_javascript_prettier_executable) + \ . ' --parser glimmer' + \ . ' --stdin-filepath %s --stdin', + \ } + Execute(The prettier_d post-processor should permit regular JavaScript content): AssertEqual \ [ diff --git a/test/python/test_deoplete_source.py b/test/python/test_deoplete_source.py index 28eec5cd..1462f77d 100644 --- a/test/python/test_deoplete_source.py +++ b/test/python/test_deoplete_source.py @@ -45,7 +45,7 @@ class DeopleteSourceTest(unittest.TestCase): 'mark': '[L]', 'min_pattern_length': 1, 'name': 'ale', - 'rank': 100, + 'rank': 1000, }) def test_completion_position(self): |