mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Add linting support for all formats supported by djlint (#4920)
Some checks are pending
CI / build_image (push) Waiting to run
CI / test_ale (--linters-only) (push) Blocked by required conditions
CI / test_ale (--neovim-07-only) (push) Blocked by required conditions
CI / test_ale (--neovim-08-only) (push) Blocked by required conditions
CI / test_ale (--vim-80-only) (push) Blocked by required conditions
CI / test_ale (--vim-90-only) (push) Blocked by required conditions
Some checks are pending
CI / build_image (push) Waiting to run
CI / test_ale (--linters-only) (push) Blocked by required conditions
CI / test_ale (--neovim-07-only) (push) Blocked by required conditions
CI / test_ale (--neovim-08-only) (push) Blocked by required conditions
CI / test_ale (--vim-80-only) (push) Blocked by required conditions
CI / test_ale (--vim-90-only) (push) Blocked by required conditions
* Refactor djlint linter code
This patch moves the code to the `autoload` directory, so it's available
when it's needed by a specific linter. This avoids redundant code when
another format supported by djlint is added.
* Add linting support for all formats supported by djlint
So far, the `djlint` linter in ALE only supported `html`, which is only
one of several file types supported by `djlint`.
This patch adds support for the following file types:
* gohtmltmpl
* handlebars
* htmlangular
* htmldjango
* jinja
* nunjucks
* Add djlint fixer for various HTML template formats
* Supported formats:
- html
- htmlangular
- htmldjango
- jinja
- handlebars
- nunjucks
- gohtmltmpl
* Add doc entries
* Add vader tests
---------
Co-authored-by: Adrian Vollmer <computerfluesterer@protonmail.com>
This commit is contained in:
12
ale_linters/gohtmltmpl/djlint.vim
Normal file
12
ale_linters/gohtmltmpl/djlint.vim
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
" Author: Adrian Vollmer <computerfluesterer@protonmail.com>
|
||||||
|
" Description: djlint for Django HTML template files
|
||||||
|
|
||||||
|
call ale#Set('html_djlint_executable', 'djlint')
|
||||||
|
call ale#Set('html_djlint_options', '')
|
||||||
|
|
||||||
|
call ale#linter#Define('gohtmltmpl', {
|
||||||
|
\ 'name': 'djlint',
|
||||||
|
\ 'executable': function('ale#handlers#djlint#GetExecutable'),
|
||||||
|
\ 'command': function('ale#handlers#djlint#GetCommand'),
|
||||||
|
\ 'callback': 'ale#handlers#djlint#Handle',
|
||||||
|
\})
|
||||||
12
ale_linters/handlebars/djlint.vim
Normal file
12
ale_linters/handlebars/djlint.vim
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
" Author: Adrian Vollmer <computerfluesterer@protonmail.com>
|
||||||
|
" Description: djlint for Django HTML template files
|
||||||
|
|
||||||
|
call ale#Set('html_djlint_executable', 'djlint')
|
||||||
|
call ale#Set('html_djlint_options', '')
|
||||||
|
|
||||||
|
call ale#linter#Define('handlebars', {
|
||||||
|
\ 'name': 'djlint',
|
||||||
|
\ 'executable': function('ale#handlers#djlint#GetExecutable'),
|
||||||
|
\ 'command': function('ale#handlers#djlint#GetCommand'),
|
||||||
|
\ 'callback': 'ale#handlers#djlint#Handle',
|
||||||
|
\})
|
||||||
@@ -4,45 +4,11 @@
|
|||||||
call ale#Set('html_djlint_executable', 'djlint')
|
call ale#Set('html_djlint_executable', 'djlint')
|
||||||
call ale#Set('html_djlint_options', '')
|
call ale#Set('html_djlint_options', '')
|
||||||
|
|
||||||
function! ale_linters#html#djlint#GetExecutable(buffer) abort
|
|
||||||
return ale#Var(a:buffer, 'html_djlint_executable')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! ale_linters#html#djlint#GetCommand(buffer) abort
|
|
||||||
let l:executable = ale_linters#html#djlint#GetExecutable(a:buffer)
|
|
||||||
|
|
||||||
let l:options = ale#Var(a:buffer, 'html_djlint_options')
|
|
||||||
|
|
||||||
return ale#Escape(l:executable)
|
|
||||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' %s'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! ale_linters#html#djlint#Handle(buffer, lines) abort
|
|
||||||
let l:output = []
|
|
||||||
let l:pattern = '\v^([A-Z]\d+) (\d+):(\d+) (.*)$'
|
|
||||||
let l:i = 0
|
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
|
||||||
let l:i += 1
|
|
||||||
let l:item = {
|
|
||||||
\ 'lnum': l:match[2] + 0,
|
|
||||||
\ 'col': l:match[3] + 0,
|
|
||||||
\ 'vcol': 1,
|
|
||||||
\ 'text': l:match[4],
|
|
||||||
\ 'code': l:match[1],
|
|
||||||
\ 'type': 'W',
|
|
||||||
\}
|
|
||||||
call add(l:output, l:item)
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return l:output
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#linter#Define('html', {
|
call ale#linter#Define('html', {
|
||||||
\ 'name': 'djlint',
|
\ 'name': 'djlint',
|
||||||
\ 'executable': function('ale_linters#html#djlint#GetExecutable'),
|
\ 'executable': function('ale#handlers#djlint#GetExecutable'),
|
||||||
\ 'command': function('ale_linters#html#djlint#GetCommand'),
|
\ 'command': function('ale#handlers#djlint#GetCommand'),
|
||||||
\ 'callback': 'ale_linters#html#djlint#Handle',
|
\ 'callback': 'ale#handlers#djlint#Handle',
|
||||||
\})
|
\})
|
||||||
|
|
||||||
" vim:ts=4:sw=4:et:
|
" vim:ts=4:sw=4:et:
|
||||||
|
|||||||
12
ale_linters/htmlangular/djlint.vim
Normal file
12
ale_linters/htmlangular/djlint.vim
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
" Author: Adrian Vollmer <computerfluesterer@protonmail.com>
|
||||||
|
" Description: djlint for Django HTML template files
|
||||||
|
|
||||||
|
call ale#Set('html_djlint_executable', 'djlint')
|
||||||
|
call ale#Set('html_djlint_options', '')
|
||||||
|
|
||||||
|
call ale#linter#Define('htmlangular', {
|
||||||
|
\ 'name': 'djlint',
|
||||||
|
\ 'executable': function('ale#handlers#djlint#GetExecutable'),
|
||||||
|
\ 'command': function('ale#handlers#djlint#GetCommand'),
|
||||||
|
\ 'callback': 'ale#handlers#djlint#Handle',
|
||||||
|
\})
|
||||||
12
ale_linters/htmldjango/djlint.vim
Normal file
12
ale_linters/htmldjango/djlint.vim
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
" Author: Adrian Vollmer <computerfluesterer@protonmail.com>
|
||||||
|
" Description: djlint for Django HTML template files
|
||||||
|
|
||||||
|
call ale#Set('html_djlint_executable', 'djlint')
|
||||||
|
call ale#Set('html_djlint_options', '')
|
||||||
|
|
||||||
|
call ale#linter#Define('htmldjango', {
|
||||||
|
\ 'name': 'djlint',
|
||||||
|
\ 'executable': function('ale#handlers#djlint#GetExecutable'),
|
||||||
|
\ 'command': function('ale#handlers#djlint#GetCommand'),
|
||||||
|
\ 'callback': 'ale#handlers#djlint#Handle',
|
||||||
|
\})
|
||||||
12
ale_linters/jinja/djlint.vim
Normal file
12
ale_linters/jinja/djlint.vim
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
" Author: Adrian Vollmer <computerfluesterer@protonmail.com>
|
||||||
|
" Description: djlint for Django HTML template files
|
||||||
|
|
||||||
|
call ale#Set('html_djlint_executable', 'djlint')
|
||||||
|
call ale#Set('html_djlint_options', '')
|
||||||
|
|
||||||
|
call ale#linter#Define('jinja', {
|
||||||
|
\ 'name': 'djlint',
|
||||||
|
\ 'executable': function('ale#handlers#djlint#GetExecutable'),
|
||||||
|
\ 'command': function('ale#handlers#djlint#GetCommand'),
|
||||||
|
\ 'callback': 'ale#handlers#djlint#Handle',
|
||||||
|
\})
|
||||||
12
ale_linters/nunjucks/djlint.vim
Normal file
12
ale_linters/nunjucks/djlint.vim
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
" Author: Adrian Vollmer <computerfluesterer@protonmail.com>
|
||||||
|
" Description: djlint for Django HTML template files
|
||||||
|
|
||||||
|
call ale#Set('html_djlint_executable', 'djlint')
|
||||||
|
call ale#Set('html_djlint_options', '')
|
||||||
|
|
||||||
|
call ale#linter#Define('nunjucks', {
|
||||||
|
\ 'name': 'djlint',
|
||||||
|
\ 'executable': function('ale#handlers#djlint#GetExecutable'),
|
||||||
|
\ 'command': function('ale#handlers#djlint#GetCommand'),
|
||||||
|
\ 'callback': 'ale#handlers#djlint#Handle',
|
||||||
|
\})
|
||||||
@@ -98,6 +98,11 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['dhall'],
|
\ 'suggested_filetypes': ['dhall'],
|
||||||
\ 'description': 'Standard code formatter for the Dhall language and removing dead code',
|
\ 'description': 'Standard code formatter for the Dhall language and removing dead code',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'djlint': {
|
||||||
|
\ 'function': 'ale#fixers#djlint#Fix',
|
||||||
|
\ 'suggested_filetypes': ['html', 'htmldjango', 'htmlangular', 'jinja', 'handlebars', 'nunjucks', 'gohtmltmpl'],
|
||||||
|
\ 'description': 'Fix HTML templates with `djlint --reformat`.',
|
||||||
|
\ },
|
||||||
\ 'dune': {
|
\ 'dune': {
|
||||||
\ 'function': 'ale#fixers#dune#Fix',
|
\ 'function': 'ale#fixers#dune#Fix',
|
||||||
\ 'suggested_filetypes': ['dune'],
|
\ 'suggested_filetypes': ['dune'],
|
||||||
|
|||||||
48
autoload/ale/fixers/djlint.vim
Normal file
48
autoload/ale/fixers/djlint.vim
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
" Author: Adrian Vollmer (computerfluesterer@protonmail.com)
|
||||||
|
" Description: HTML template formatter using `djlint --reformat`
|
||||||
|
|
||||||
|
call ale#Set('html_djlint_executable', 'djlint')
|
||||||
|
call ale#Set('html_djlint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||||
|
call ale#Set('html_djlint_options', '')
|
||||||
|
|
||||||
|
function! ale#fixers#djlint#Fix(buffer) abort
|
||||||
|
let l:executable = ale#python#FindExecutable(
|
||||||
|
\ a:buffer,
|
||||||
|
\ 'html_djlint',
|
||||||
|
\ ['djlint']
|
||||||
|
\)
|
||||||
|
|
||||||
|
let l:options = ale#Var(a:buffer, 'html_djlint_options')
|
||||||
|
|
||||||
|
let l:profile = ''
|
||||||
|
let l:filetypes = split(getbufvar(a:buffer, '&filetype'), '\.')
|
||||||
|
|
||||||
|
" Append the --profile flag depending on the current filetype (unless it's
|
||||||
|
" already set in g:html_djlint_options).
|
||||||
|
if match(l:options, '--profile') == -1
|
||||||
|
let l:djlint_profiles = {
|
||||||
|
\ 'html': 'html',
|
||||||
|
\ 'htmldjango': 'django',
|
||||||
|
\ 'jinja': 'jinja',
|
||||||
|
\ 'nunjucks': 'nunjucks',
|
||||||
|
\ 'handlebars': 'handlebars',
|
||||||
|
\ 'gohtmltmpl': 'golang',
|
||||||
|
\ 'htmlangular': 'angular',
|
||||||
|
\}
|
||||||
|
|
||||||
|
for l:filetype in l:filetypes
|
||||||
|
if has_key(l:djlint_profiles, l:filetype)
|
||||||
|
let l:profile = l:djlint_profiles[l:filetype]
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !empty(l:profile)
|
||||||
|
let l:options = (!empty(l:options) ? l:options . ' ' : '') . '--profile ' . l:profile
|
||||||
|
endif
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable) . ' --reformat ' . l:options . ' -',
|
||||||
|
\}
|
||||||
|
endfunction
|
||||||
64
autoload/ale/handlers/djlint.vim
Normal file
64
autoload/ale/handlers/djlint.vim
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
" Author: Vivian De Smedt <vds2212@gmail.com>, Adrian Vollmer <computerfluesterer@protonmail.com>
|
||||||
|
" Description: Adds support for djlint
|
||||||
|
"
|
||||||
|
function! ale#handlers#djlint#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'html_djlint_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale#handlers#djlint#GetCommand(buffer) abort
|
||||||
|
let l:executable = ale#handlers#djlint#GetExecutable(a:buffer)
|
||||||
|
|
||||||
|
let l:options = ale#Var(a:buffer, 'html_djlint_options')
|
||||||
|
|
||||||
|
let l:profile = ''
|
||||||
|
let l:filetypes = split(getbufvar(a:buffer, '&filetype'), '\.')
|
||||||
|
|
||||||
|
" Append the --profile flag depending on the current filetype (unless it's
|
||||||
|
" already set in g:html_djlint_options).
|
||||||
|
if match(l:options, '--profile') == -1
|
||||||
|
let l:djlint_profiles = {
|
||||||
|
\ 'html': 'html',
|
||||||
|
\ 'htmldjango': 'django',
|
||||||
|
\ 'jinja': 'jinja',
|
||||||
|
\ 'nunjucks': 'nunjucks',
|
||||||
|
\ 'handlebars': 'handlebars',
|
||||||
|
\ 'gohtmltmpl': 'golang',
|
||||||
|
\ 'htmlangular': 'angular',
|
||||||
|
\}
|
||||||
|
|
||||||
|
for l:filetype in l:filetypes
|
||||||
|
if has_key(l:djlint_profiles, l:filetype)
|
||||||
|
let l:profile = l:djlint_profiles[l:filetype]
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !empty(l:profile)
|
||||||
|
let l:options = (!empty(l:options) ? l:options . ' ' : '') . '--profile ' . l:profile
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ale#Escape(l:executable)
|
||||||
|
\ . (!empty(l:options) ? ' ' . l:options : '') . ' %s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale#handlers#djlint#Handle(buffer, lines) abort
|
||||||
|
let l:output = []
|
||||||
|
let l:pattern = '\v^([A-Z]\d+) (\d+):(\d+) (.*)$'
|
||||||
|
let l:i = 0
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
let l:i += 1
|
||||||
|
let l:item = {
|
||||||
|
\ 'lnum': l:match[2] + 0,
|
||||||
|
\ 'col': l:match[3] + 0,
|
||||||
|
\ 'vcol': 1,
|
||||||
|
\ 'text': l:match[4],
|
||||||
|
\ 'code': l:match[1],
|
||||||
|
\ 'type': 'W',
|
||||||
|
\}
|
||||||
|
call add(l:output, l:item)
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
11
doc/ale-gohtmltmpl.txt
Normal file
11
doc/ale-gohtmltmpl.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
===============================================================================
|
||||||
|
ALE Go HTML Template Integration *ale-gohtmltmpl-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
djlint *ale-gohtmltmpl-djlint*
|
||||||
|
|
||||||
|
See |ale-html-djlint|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
@@ -2,6 +2,13 @@
|
|||||||
ALE Handlebars Integration *ale-handlebars-options*
|
ALE Handlebars Integration *ale-handlebars-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
djlint *ale-handlebars-djlint*
|
||||||
|
|
||||||
|
See |ale-html-djlint|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
prettier *ale-handlebars-prettier*
|
prettier *ale-handlebars-prettier*
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ See |ale-cspell-options|
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
djlint *ale-html-djlint*
|
djlint *ale-html-djlint*
|
||||||
|
|
||||||
|
`djlint` options for HTML are the same as the options for htmlangular,
|
||||||
|
htmldjango, jinja, handlebars, nunjucks and gotmplhtml.
|
||||||
|
|
||||||
g:ale_html_djlint_executable *g:ale_html_djlint_executable*
|
g:ale_html_djlint_executable *g:ale_html_djlint_executable*
|
||||||
*b:ale_html_djlint_executable*
|
*b:ale_html_djlint_executable*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
|
|||||||
12
doc/ale-htmlangular.txt
Normal file
12
doc/ale-htmlangular.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
===============================================================================
|
||||||
|
ALE HTML Angular Template Integration *ale-htmlangular-options*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
djlint *ale-htmlangular-djlint*
|
||||||
|
|
||||||
|
See |ale-html-djlint|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
12
doc/ale-htmldjango.txt
Normal file
12
doc/ale-htmldjango.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
===============================================================================
|
||||||
|
ALE HTML Django Template Integration *ale-htmldjango-options*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
djlint *ale-htmldjango-djlint*
|
||||||
|
|
||||||
|
See |ale-html-djlint|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
12
doc/ale-jinja.txt
Normal file
12
doc/ale-jinja.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
===============================================================================
|
||||||
|
ALE Jinja Integration *ale-jinja-options*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
djlint *ale-jinja-djlint*
|
||||||
|
|
||||||
|
See |ale-html-djlint|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
12
doc/ale-nunjucks.txt
Normal file
12
doc/ale-nunjucks.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
===============================================================================
|
||||||
|
ALE Nunjucks Integration *ale-nunjucks-options*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
djlint *ale-nunjucks-djlint*
|
||||||
|
|
||||||
|
See |ale-html-djlint|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
@@ -234,6 +234,8 @@ Notes:
|
|||||||
* `gotype`!!
|
* `gotype`!!
|
||||||
* `revive`!!
|
* `revive`!!
|
||||||
* `staticcheck`!!
|
* `staticcheck`!!
|
||||||
|
* Go HTML Templates
|
||||||
|
* djlint
|
||||||
* GraphQL
|
* GraphQL
|
||||||
* `eslint`
|
* `eslint`
|
||||||
* `gqlint`
|
* `gqlint`
|
||||||
@@ -247,6 +249,7 @@ Notes:
|
|||||||
* Haml
|
* Haml
|
||||||
* `haml-lint`
|
* `haml-lint`
|
||||||
* Handlebars
|
* Handlebars
|
||||||
|
* djlint
|
||||||
* `ember-template-lint`
|
* `ember-template-lint`
|
||||||
* Haskell
|
* Haskell
|
||||||
* `brittany`
|
* `brittany`
|
||||||
@@ -284,6 +287,10 @@ Notes:
|
|||||||
* `rustywind`
|
* `rustywind`
|
||||||
* `tidy`
|
* `tidy`
|
||||||
* `write-good`
|
* `write-good`
|
||||||
|
* HTML Angular
|
||||||
|
* djlint
|
||||||
|
* HTML Django
|
||||||
|
* djlint
|
||||||
* Hurl
|
* Hurl
|
||||||
* `hurlfmt`
|
* `hurlfmt`
|
||||||
* Idris
|
* Idris
|
||||||
@@ -321,6 +328,8 @@ Notes:
|
|||||||
* `standard`
|
* `standard`
|
||||||
* `tsserver`
|
* `tsserver`
|
||||||
* `xo`
|
* `xo`
|
||||||
|
* Jinja
|
||||||
|
* djlint
|
||||||
* JSON
|
* JSON
|
||||||
* `VSCode JSON language server`
|
* `VSCode JSON language server`
|
||||||
* `biome`
|
* `biome`
|
||||||
@@ -421,6 +430,8 @@ Notes:
|
|||||||
* `alex`
|
* `alex`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
* `write-good`
|
* `write-good`
|
||||||
|
* Nunjucks
|
||||||
|
* djlint
|
||||||
* Objective-C
|
* Objective-C
|
||||||
* `ccls`
|
* `ccls`
|
||||||
* `clang`
|
* `clang`
|
||||||
|
|||||||
11
doc/ale.txt
11
doc/ale.txt
@@ -3067,6 +3067,8 @@ documented in additional help files.
|
|||||||
govet.................................|ale-go-govet|
|
govet.................................|ale-go-govet|
|
||||||
revive................................|ale-go-revive|
|
revive................................|ale-go-revive|
|
||||||
staticcheck...........................|ale-go-staticcheck|
|
staticcheck...........................|ale-go-staticcheck|
|
||||||
|
go html template........................|ale-gohtmltmpl-options|
|
||||||
|
djlint................................|ale-gohtmltmpl-djlint|
|
||||||
graphql.................................|ale-graphql-options|
|
graphql.................................|ale-graphql-options|
|
||||||
eslint................................|ale-graphql-eslint|
|
eslint................................|ale-graphql-eslint|
|
||||||
gqlint................................|ale-graphql-gqlint|
|
gqlint................................|ale-graphql-gqlint|
|
||||||
@@ -3078,6 +3080,7 @@ documented in additional help files.
|
|||||||
hackfmt...............................|ale-hack-hackfmt|
|
hackfmt...............................|ale-hack-hackfmt|
|
||||||
hhast.................................|ale-hack-hhast|
|
hhast.................................|ale-hack-hhast|
|
||||||
handlebars..............................|ale-handlebars-options|
|
handlebars..............................|ale-handlebars-options|
|
||||||
|
djlint................................|ale-handlebars-djlint|
|
||||||
prettier..............................|ale-handlebars-prettier|
|
prettier..............................|ale-handlebars-prettier|
|
||||||
ember-template-lint...................|ale-handlebars-embertemplatelint|
|
ember-template-lint...................|ale-handlebars-embertemplatelint|
|
||||||
haskell.................................|ale-haskell-options|
|
haskell.................................|ale-haskell-options|
|
||||||
@@ -3116,6 +3119,10 @@ documented in additional help files.
|
|||||||
tidy..................................|ale-html-tidy|
|
tidy..................................|ale-html-tidy|
|
||||||
vscodehtml............................|ale-html-vscode|
|
vscodehtml............................|ale-html-vscode|
|
||||||
write-good............................|ale-html-write-good|
|
write-good............................|ale-html-write-good|
|
||||||
|
html angular template...................|ale-htmlangular-options|
|
||||||
|
djlint................................|ale-htmlangular-djlint|
|
||||||
|
html django template....................|ale-htmldjango-options|
|
||||||
|
djlint................................|ale-htmldjango-djlint|
|
||||||
hurl....................................|ale-hurl-options|
|
hurl....................................|ale-hurl-options|
|
||||||
hurlfmt...............................|ale-hurl-hurlfmt|
|
hurlfmt...............................|ale-hurl-hurlfmt|
|
||||||
idris...................................|ale-idris-options|
|
idris...................................|ale-idris-options|
|
||||||
@@ -3153,6 +3160,8 @@ documented in additional help files.
|
|||||||
prettier-standard.....................|ale-javascript-prettier-standard|
|
prettier-standard.....................|ale-javascript-prettier-standard|
|
||||||
standard..............................|ale-javascript-standard|
|
standard..............................|ale-javascript-standard|
|
||||||
xo....................................|ale-javascript-xo|
|
xo....................................|ale-javascript-xo|
|
||||||
|
jinja...................................|ale-jinja-options|
|
||||||
|
djlint................................|ale-jinja-djlint|
|
||||||
json....................................|ale-json-options|
|
json....................................|ale-json-options|
|
||||||
biome.................................|ale-json-biome|
|
biome.................................|ale-json-biome|
|
||||||
clang-format..........................|ale-json-clangformat|
|
clang-format..........................|ale-json-clangformat|
|
||||||
@@ -3231,6 +3240,8 @@ documented in additional help files.
|
|||||||
deadnix...............................|ale-nix-deadnix|
|
deadnix...............................|ale-nix-deadnix|
|
||||||
nroff...................................|ale-nroff-options|
|
nroff...................................|ale-nroff-options|
|
||||||
write-good............................|ale-nroff-write-good|
|
write-good............................|ale-nroff-write-good|
|
||||||
|
nunjucks................................|ale-nunjucks-options|
|
||||||
|
djlint................................|ale-nunjucks-djlint|
|
||||||
objc....................................|ale-objc-options|
|
objc....................................|ale-objc-options|
|
||||||
ccls..................................|ale-objc-ccls|
|
ccls..................................|ale-objc-ccls|
|
||||||
clang.................................|ale-objc-clang|
|
clang.................................|ale-objc-clang|
|
||||||
|
|||||||
@@ -243,6 +243,8 @@ formatting.
|
|||||||
* [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) :warning: :floppy_disk:
|
* [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) :warning: :floppy_disk:
|
||||||
* [revive](https://github.com/mgechev/revive) :warning: :floppy_disk:
|
* [revive](https://github.com/mgechev/revive) :warning: :floppy_disk:
|
||||||
* [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) :warning: :floppy_disk:
|
* [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) :warning: :floppy_disk:
|
||||||
|
* Go HTML Templates
|
||||||
|
* [djlint](https://djlint.com/)
|
||||||
* GraphQL
|
* GraphQL
|
||||||
* [eslint](http://eslint.org/)
|
* [eslint](http://eslint.org/)
|
||||||
* [gqlint](https://github.com/happylinks/gqlint)
|
* [gqlint](https://github.com/happylinks/gqlint)
|
||||||
@@ -256,6 +258,7 @@ formatting.
|
|||||||
* Haml
|
* Haml
|
||||||
* [haml-lint](https://github.com/brigade/haml-lint)
|
* [haml-lint](https://github.com/brigade/haml-lint)
|
||||||
* Handlebars
|
* Handlebars
|
||||||
|
* [djlint](https://djlint.com/)
|
||||||
* [ember-template-lint](https://github.com/rwjblue/ember-template-lint)
|
* [ember-template-lint](https://github.com/rwjblue/ember-template-lint)
|
||||||
* Haskell
|
* Haskell
|
||||||
* [brittany](https://github.com/lspitzner/brittany)
|
* [brittany](https://github.com/lspitzner/brittany)
|
||||||
@@ -293,6 +296,10 @@ formatting.
|
|||||||
* [rustywind](https://github.com/avencera/rustywind)
|
* [rustywind](https://github.com/avencera/rustywind)
|
||||||
* [tidy](http://www.html-tidy.org/)
|
* [tidy](http://www.html-tidy.org/)
|
||||||
* [write-good](https://github.com/btford/write-good)
|
* [write-good](https://github.com/btford/write-good)
|
||||||
|
* HTML Angular
|
||||||
|
* [djlint](https://djlint.com/)
|
||||||
|
* HTML Django
|
||||||
|
* [djlint](https://djlint.com/)
|
||||||
* Hurl
|
* Hurl
|
||||||
* [hurlfmt](https://hurl.dev)
|
* [hurlfmt](https://hurl.dev)
|
||||||
* Idris
|
* Idris
|
||||||
@@ -330,6 +337,8 @@ formatting.
|
|||||||
* [standard](http://standardjs.com/)
|
* [standard](http://standardjs.com/)
|
||||||
* [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29)
|
* [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29)
|
||||||
* [xo](https://github.com/sindresorhus/xo)
|
* [xo](https://github.com/sindresorhus/xo)
|
||||||
|
* Jinja
|
||||||
|
* [djlint](https://djlint.com/)
|
||||||
* JSON
|
* JSON
|
||||||
* [VSCode JSON language server](https://github.com/hrsh7th/vscode-langservers-extracted)
|
* [VSCode JSON language server](https://github.com/hrsh7th/vscode-langservers-extracted)
|
||||||
* [biome](https://biomejs.dev/)
|
* [biome](https://biomejs.dev/)
|
||||||
@@ -430,6 +439,8 @@ formatting.
|
|||||||
* [alex](https://github.com/get-alex/alex)
|
* [alex](https://github.com/get-alex/alex)
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
* [write-good](https://github.com/btford/write-good)
|
* [write-good](https://github.com/btford/write-good)
|
||||||
|
* Nunjucks
|
||||||
|
* [djlint](https://djlint.com/)
|
||||||
* Objective-C
|
* Objective-C
|
||||||
* [ccls](https://github.com/MaskRay/ccls)
|
* [ccls](https://github.com/MaskRay/ccls)
|
||||||
* [clang](http://clang.llvm.org/)
|
* [clang](http://clang.llvm.org/)
|
||||||
|
|||||||
98
test/fixers/test_djlint_fixer_callback.vader
Normal file
98
test/fixers/test_djlint_fixer_callback.vader
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
Before:
|
||||||
|
call ale#assert#SetUpFixerTest('html', 'djlint', 'djlint')
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
call ale#assert#TearDownFixerTest()
|
||||||
|
|
||||||
|
Execute(The djlint callback should return the correct default command):
|
||||||
|
AssertEqual
|
||||||
|
\ {'command': ale#Escape('djlint') . ' --reformat -'},
|
||||||
|
\ ale#fixers#djlint#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The --profile option should not be overridden):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=htmldjango
|
||||||
|
let g:ale_html_djlint_options = '--profile jinja'
|
||||||
|
|
||||||
|
AssertFixer
|
||||||
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --reformat'
|
||||||
|
\ . ' --profile jinja'
|
||||||
|
\ . ' -',
|
||||||
|
\ }
|
||||||
|
|
||||||
|
|
||||||
|
Execute(Should set --profile for experimental language, Handlebars):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.hbs')
|
||||||
|
|
||||||
|
set filetype=handlebars
|
||||||
|
|
||||||
|
AssertFixer
|
||||||
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --reformat'
|
||||||
|
\ . ' --profile handlebars'
|
||||||
|
\ . ' -',
|
||||||
|
\ }
|
||||||
|
|
||||||
|
Execute(Should set --profile for htmldjango, Django templates):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=htmldjango
|
||||||
|
|
||||||
|
AssertFixer
|
||||||
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --reformat'
|
||||||
|
\ . ' --profile django'
|
||||||
|
\ . ' -',
|
||||||
|
\ }
|
||||||
|
|
||||||
|
Execute(Should set --profile for htmlangular):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=htmlangular
|
||||||
|
|
||||||
|
AssertFixer
|
||||||
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --reformat'
|
||||||
|
\ . ' --profile angular'
|
||||||
|
\ . ' -',
|
||||||
|
\ }
|
||||||
|
|
||||||
|
Execute(Should set --profile for jinja):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.jinja2')
|
||||||
|
|
||||||
|
set filetype=jinja
|
||||||
|
|
||||||
|
AssertFixer
|
||||||
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --reformat'
|
||||||
|
\ . ' --profile jinja'
|
||||||
|
\ . ' -',
|
||||||
|
\ }
|
||||||
|
|
||||||
|
Execute(Should set --profile for nunjucks):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.njk')
|
||||||
|
|
||||||
|
set filetype=nunjucks
|
||||||
|
|
||||||
|
AssertFixer
|
||||||
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --reformat'
|
||||||
|
\ . ' --profile nunjucks'
|
||||||
|
\ . ' -',
|
||||||
|
\ }
|
||||||
|
|
||||||
|
Execute(Should set --profile for Go HTML templates):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=gohtmltmpl
|
||||||
|
|
||||||
|
AssertFixer
|
||||||
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --reformat'
|
||||||
|
\ . ' --profile golang'
|
||||||
|
\ . ' -',
|
||||||
|
\ }
|
||||||
@@ -16,6 +16,6 @@ Execute(The Djlint handler should parse output with a column correctly):
|
|||||||
\ 'type': 'W'
|
\ 'type': 'W'
|
||||||
\ }
|
\ }
|
||||||
\ ],
|
\ ],
|
||||||
\ ale_linters#html#djlint#Handle(0, [
|
\ ale#handlers#djlint#Handle(0, [
|
||||||
\ 'H008 47:8 Attributes should be double quoted.'
|
\ 'H008 47:8 Attributes should be double quoted.'
|
||||||
\ ])
|
\ ])
|
||||||
|
|||||||
@@ -12,3 +12,58 @@ Execute(The executable should be configurable):
|
|||||||
let g:ale_html_djlint_options = '--option'
|
let g:ale_html_djlint_options = '--option'
|
||||||
|
|
||||||
AssertLinter 'foo bar', ale#Escape('foo bar') . ' --option %s'
|
AssertLinter 'foo bar', ale#Escape('foo bar') . ' --option %s'
|
||||||
|
|
||||||
|
Execute(The --profile option should not be overridden):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=htmldjango
|
||||||
|
let g:ale_html_djlint_options = '--profile jinja'
|
||||||
|
|
||||||
|
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --profile jinja'
|
||||||
|
\ . ' %s',
|
||||||
|
|
||||||
|
Execute(Should set --profile for htmlangular):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=htmlangular
|
||||||
|
|
||||||
|
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --profile angular'
|
||||||
|
\ . ' %s',
|
||||||
|
|
||||||
|
Execute(Should set --profile for jinja):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=jinja
|
||||||
|
|
||||||
|
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --profile jinja'
|
||||||
|
\ . ' %s',
|
||||||
|
|
||||||
|
Execute(Should set --profile for Handlebars):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=handlebars
|
||||||
|
|
||||||
|
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --profile handlebars'
|
||||||
|
\ . ' %s',
|
||||||
|
|
||||||
|
Execute(Should set --profile for nunjucks):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=nunjucks
|
||||||
|
|
||||||
|
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --profile nunjucks'
|
||||||
|
\ . ' %s',
|
||||||
|
|
||||||
|
Execute(Should set --profile for Go HTML Templates):
|
||||||
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
||||||
|
|
||||||
|
set filetype=gohtmltmpl
|
||||||
|
|
||||||
|
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
|
||||||
|
\ . ' --profile golang'
|
||||||
|
\ . ' %s',
|
||||||
|
|||||||
Reference in New Issue
Block a user