diff options
-rw-r--r-- | ale_linters/java/checkstyle.vim | 14 | ||||
-rw-r--r-- | autoload/ale/fixers/prettier.vim | 10 | ||||
-rw-r--r-- | doc/ale-handlebars.txt | 7 | ||||
-rw-r--r-- | doc/ale-java.txt | 2 | ||||
-rw-r--r-- | doc/ale.txt | 1 | ||||
-rw-r--r-- | rplugin/python3/deoplete/sources/ale.py | 2 | ||||
-rw-r--r-- | test/command_callback/checkstyle_paths/google_checks.xml | 0 | ||||
-rw-r--r-- | test/command_callback/test_checkstyle_command_callback.vader | 20 | ||||
-rw-r--r-- | test/fixers/test_prettier_fixer_callback.vader | 14 | ||||
-rw-r--r-- | test/python/test_deoplete_source.py | 2 |
10 files changed, 60 insertions, 12 deletions
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim index ee3ca7a3..7901ff7e 100644 --- a/ale_linters/java/checkstyle.vim +++ b/ale_linters/java/checkstyle.vim @@ -2,7 +2,7 @@ " Description: checkstyle for Java files call ale#Set('java_checkstyle_executable', 'checkstyle') -call ale#Set('java_checkstyle_config', 'google_checks.xml') +call ale#Set('java_checkstyle_config', '/google_checks.xml') call ale#Set('java_checkstyle_options', '') function! ale_linters#java#checkstyle#Handle(buffer, lines) abort @@ -39,11 +39,21 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort return l:output endfunction +function! s:GetConfig(buffer, config) abort + if ale#path#IsAbsolute(a:config) + return a:config + endif + + let s:file = ale#path#FindNearestFile(a:buffer, a:config) + + return !empty(s:file) ? s:file : a:config +endfunction + function! ale_linters#java#checkstyle#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'java_checkstyle_options') let l:config_option = ale#Var(a:buffer, 'java_checkstyle_config') let l:config = l:options !~# '\v(^| )-c' && !empty(l:config_option) - \ ? ale#path#FindNearestFile(a:buffer, l:config_option) + \ ? s:GetConfig(a:buffer, l:config_option) \ : '' return '%e' 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-java.txt b/doc/ale-java.txt index a563f1fb..58acc272 100644 --- a/doc/ale-java.txt +++ b/doc/ale-java.txt @@ -9,7 +9,7 @@ g:ale_java_checkstyle_config *g:ale_java_checkstyle_config* *b:ale_java_checkstyle_config* Type: |String| - Default: `'google_checks.xml'` + Default: `'/google_checks.xml'` A path to a checkstyle configuration file. 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/command_callback/checkstyle_paths/google_checks.xml b/test/command_callback/checkstyle_paths/google_checks.xml deleted file mode 100644 index e69de29b..00000000 --- a/test/command_callback/checkstyle_paths/google_checks.xml +++ /dev/null diff --git a/test/command_callback/test_checkstyle_command_callback.vader b/test/command_callback/test_checkstyle_command_callback.vader index d775f9f2..7a9f26b3 100644 --- a/test/command_callback/test_checkstyle_command_callback.vader +++ b/test/command_callback/test_checkstyle_command_callback.vader @@ -6,17 +6,27 @@ After: call ale#assert#TearDownLinterTest() Execute(The checkstyle callback should return the correct default value): - AssertLinter 'checkstyle', ale#Escape('checkstyle') . ' %s' + AssertLinter 'checkstyle', + \ ale#Escape('checkstyle') + \ . ' -c ' . ale#Escape('/google_checks.xml') + \ . ' %s' Execute(The checkstyle executable should be configurable): let b:ale_java_checkstyle_executable = 'foobar' - AssertLinter 'foobar', ale#Escape('foobar') . ' %s' + AssertLinter 'foobar', + \ ale#Escape('foobar') + \ . ' -c ' . ale#Escape('/google_checks.xml') + \ . ' %s' Execute(Custom options should be supported): let b:ale_java_checkstyle_options = '--foobar' - AssertLinter 'checkstyle', ale#Escape('checkstyle') . ' --foobar %s' + AssertLinter 'checkstyle', + \ ale#Escape('checkstyle') + \ . ' --foobar' + \ . ' -c ' . ale#Escape('/google_checks.xml') + \ . ' %s' Execute(configuration files set in _config should be supported): let b:ale_java_checkstyle_config = ale#path#Simplify(g:dir . '/checkstyle_paths/other_config.xml') @@ -36,12 +46,12 @@ Execute(configuration files set in _options should be preferred over _config): AssertLinter 'checkstyle', ale#Escape('checkstyle') . ' -x -c /bar.xml %s' -Execute(google_checks.xml should be detected automatically): +Execute(google_checks.xml should be used by default): call ale#test#SetFilename('checkstyle_paths/test.java') AssertLinter 'checkstyle', \ ale#Escape('checkstyle') - \ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/checkstyle_paths/google_checks.xml')) + \ . ' -c ' . ale#Escape('/google_checks.xml') \ . ' %s' Execute(Other relative paths should be supported): 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): |