From e023e7a2fe698cb36921c8e47f48e6a072c1b0a6 Mon Sep 17 00:00:00 2001 From: Zack Kourouma Date: Fri, 20 Oct 2017 18:29:57 -0700 Subject: [PATCH 1/2] add prettier fixer support for 'less' filetype --- autoload/ale/fix/registry.vim | 2 +- autoload/ale/fixers/prettier.vim | 2 +- doc/ale.txt | 2 ++ test/fixers/test_prettier_fixer_callback.vader | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 93ddf0f5..d26c71ab 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -39,7 +39,7 @@ let s:default_registry = { \ }, \ 'prettier': { \ 'function': 'ale#fixers#prettier#Fix', -\ 'suggested_filetypes': ['javascript', 'typescript', 'json', 'css', 'scss'], +\ 'suggested_filetypes': ['javascript', 'typescript', 'json', 'css', 'scss', 'less'], \ 'description': 'Apply prettier to a file.', \ }, \ 'prettier_eslint': { diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim index 4adc3b08..d66e00f0 100644 --- a/autoload/ale/fixers/prettier.vim +++ b/autoload/ale/fixers/prettier.vim @@ -49,7 +49,7 @@ function! ale#fixers#prettier#Fix(buffer) abort if match(l:options, '--parser') == -1 if l:filetype is# 'typescript' let l:parser = 'typescript' - elseif l:filetype =~# 'css\|scss' + elseif l:filetype =~# 'css\|scss\|less' let l:parser = 'postcss' elseif l:filetype is# 'json' let l:parser = 'json' diff --git a/doc/ale.txt b/doc/ale.txt index d393c4d9..fb0b5a76 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -95,6 +95,8 @@ CONTENTS *ale-contents* kotlin................................|ale-kotlin-options| kotlinc.............................|ale-kotlin-kotlinc| ktlint..............................|ale-kotlin-ktlint| + less..................................|ale-less-options| + prettier............................|ale-less-prettier| llvm..................................|ale-llvm-options| llc.................................|ale-llvm-llc| lua...................................|ale-lua-options| diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader index cc7d34d0..471a8632 100644 --- a/test/fixers/test_prettier_fixer_callback.vader +++ b/test/fixers/test_prettier_fixer_callback.vader @@ -114,3 +114,17 @@ Execute(Append '--parser postcss' for filetype=css): \ . ' --write', \ }, \ ale#fixers#prettier#Fix(bufnr('')) + +Execute(Append '--parser postcss' for filetype=less): + set filetype=less + call ale#test#SetFilename('../prettier-test-files/testfile.less') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape(g:ale_javascript_prettier_executable) + \ . ' %t' + \ . ' --parser postcss' + \ . ' --write', + \ }, + \ ale#fixers#prettier#Fix(bufnr('')) From b43ed6baf59c4fc9bf0de89db78870343ceec2ec Mon Sep 17 00:00:00 2001 From: Zack Kourouma Date: Fri, 20 Oct 2017 18:30:34 -0700 Subject: [PATCH 2/2] add doc file for less --- doc/ale-less.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doc/ale-less.txt diff --git a/doc/ale-less.txt b/doc/ale-less.txt new file mode 100644 index 00000000..a6b5998e --- /dev/null +++ b/doc/ale-less.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE Less Integration *ale-less-options* + + +=============================================================================== +prettier *ale-less-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +