Merge pull request #1018 from zkourouma/master

Pretter fixer support for Less filetype
This commit is contained in:
w0rp 2017-10-21 11:31:15 +01:00 committed by GitHub
commit 3878be9977
5 changed files with 30 additions and 2 deletions

View File

@ -39,7 +39,7 @@ let s:default_registry = {
\ }, \ },
\ 'prettier': { \ 'prettier': {
\ 'function': 'ale#fixers#prettier#Fix', \ '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.', \ 'description': 'Apply prettier to a file.',
\ }, \ },
\ 'prettier_eslint': { \ 'prettier_eslint': {

View File

@ -49,7 +49,7 @@ function! ale#fixers#prettier#Fix(buffer) abort
if match(l:options, '--parser') == -1 if match(l:options, '--parser') == -1
if l:filetype is# 'typescript' if l:filetype is# 'typescript'
let l:parser = 'typescript' let l:parser = 'typescript'
elseif l:filetype =~# 'css\|scss' elseif l:filetype =~# 'css\|scss\|less'
let l:parser = 'postcss' let l:parser = 'postcss'
elseif l:filetype is# 'json' elseif l:filetype is# 'json'
let l:parser = 'json' let l:parser = 'json'

12
doc/ale-less.txt Normal file
View File

@ -0,0 +1,12 @@
===============================================================================
ALE Less Integration *ale-less-options*
===============================================================================
prettier *ale-less-prettier*
See |ale-javascript-prettier| for information about the available options.
===============================================================================

View File

@ -95,6 +95,8 @@ CONTENTS *ale-contents*
kotlin................................|ale-kotlin-options| kotlin................................|ale-kotlin-options|
kotlinc.............................|ale-kotlin-kotlinc| kotlinc.............................|ale-kotlin-kotlinc|
ktlint..............................|ale-kotlin-ktlint| ktlint..............................|ale-kotlin-ktlint|
less..................................|ale-less-options|
prettier............................|ale-less-prettier|
llvm..................................|ale-llvm-options| llvm..................................|ale-llvm-options|
llc.................................|ale-llvm-llc| llc.................................|ale-llvm-llc|
lua...................................|ale-lua-options| lua...................................|ale-lua-options|

View File

@ -114,3 +114,17 @@ Execute(Append '--parser postcss' for filetype=css):
\ . ' --write', \ . ' --write',
\ }, \ },
\ ale#fixers#prettier#Fix(bufnr('')) \ 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(''))