Skip to content

Commit ac0495d

Browse files
authored
Add dprint fixer (#4024)
* Add dprint fixer * Fix windows tests * dd dprint documentation
1 parent 48f6859 commit ac0495d

File tree

15 files changed

+195
-3
lines changed

15 files changed

+195
-3
lines changed

autoload/ale/fix/registry.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ let s:default_registry = {
496496
\ 'suggested_filetypes': ['lua'],
497497
\ 'description': 'Fix Lua files with luafmt.',
498498
\ },
499+
\ 'dprint': {
500+
\ 'function': 'ale#fixers#dprint#Fix',
501+
\ 'suggested_filetypes': ['javascript', 'typescript', 'json', 'markdown'],
502+
\ 'description': 'Pluggable and configurable code formatting platform',
503+
\ },
499504
\ 'stylua': {
500505
\ 'function': 'ale#fixers#stylua#Fix',
501506
\ 'suggested_filetypes': ['lua'],

autoload/ale/fixers/dprint.vim

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
call ale#Set('dprint_executable', 'dprint')
2+
call ale#Set('dprint_executable_override', 0)
3+
call ale#Set('dprint_use_global', get(g:, 'ale_use_global_executables', 0))
4+
call ale#Set('dprint_options', '')
5+
call ale#Set('dprint_config', 'dprint.json')
6+
7+
function! ale#fixers#dprint#Fix(buffer) abort
8+
let l:executable = ale#path#FindExecutable(a:buffer, 'dprint', ['dprint'])
9+
let l:executable_override = ale#Var(a:buffer, 'dprint_executable_override')
10+
11+
if !executable(l:executable) && !l:executable_override
12+
return 0
13+
endif
14+
15+
let l:options = ale#Var(a:buffer, 'dprint_options')
16+
let l:config = ale#path#FindNearestFile(a:buffer, ale#Var(a:buffer, 'dprint_config'))
17+
18+
if !empty(l:config)
19+
let l:options = l:options . ' -c ' . ale#Escape(l:config)
20+
endif
21+
22+
let l:options = l:options . ' --stdin %s'
23+
24+
return {
25+
\ 'command': ale#Escape(l:executable)
26+
\ . ' fmt '
27+
\ . l:options
28+
\}
29+
endfunction

doc/ale-dockerfile.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ g:ale_dockerfile_dockerfile_lint_options
2525
the dockerfile lint invocation - like custom rule file definitions.
2626

2727

28+
===============================================================================
29+
dprint *ale-dockerfile-dprint*
30+
31+
See |ale-dprint-options| and https://dprint.dev/plugins/dockerfile
32+
33+
2834
===============================================================================
2935
hadolint *ale-dockerfile-hadolint*
3036

doc/ale-javascript.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ deno *ale-javascript-deno*
3535
Check the docs over at |ale-typescript-deno|.
3636

3737

38+
===============================================================================
39+
dprint *ale-javascript-dprint*
40+
41+
See |ale-dprint-options| and https://dprint.dev/plugins/typescript
42+
43+
3844
===============================================================================
3945
eslint *ale-javascript-eslint*
4046

doc/ale-json.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ cspell *ale-json-cspell*
88
See |ale-cspell-options|
99

1010

11+
===============================================================================
12+
dprint *ale-json-dprint*
13+
14+
See |ale-dprint-options| and https://dprint.dev/plugins/json
15+
16+
1117
===============================================================================
1218
eslint *ale-json-eslint*
1319

doc/ale-markdown.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ cspell *ale-markdown-cspell*
88
See |ale-cspell-options|
99

1010

11+
===============================================================================
12+
dprint *ale-markdown-dprint*
13+
14+
See |ale-dprint-options| and https://dprint.dev/plugins/markdown
15+
16+
1117
===============================================================================
1218
markdownlint *ale-markdown-markdownlint*
1319

doc/ale-sql.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
ALE SQL Integration *ale-sql-options*
33

44

5+
===============================================================================
6+
dprint *ale-sql-dprint*
7+
8+
See |ale-dprint-options|
9+
and https://github.com/dprint/dprint-plugin-sql/releases
10+
11+
512
===============================================================================
613
pgformatter *ale-sql-pgformatter*
714

doc/ale-supported-languages-and-tools.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Notes:
147147
* `dhall-lint`
148148
* Dockerfile
149149
* `dockerfile_lint`
150+
* `dprint`
150151
* `hadolint`
151152
* Elixir
152153
* `credo`
@@ -267,6 +268,7 @@ Notes:
267268
* JavaScript
268269
* `cspell`
269270
* `deno`
271+
* `dprint`
270272
* `eslint`
271273
* `fecs`
272274
* `flow`
@@ -280,6 +282,7 @@ Notes:
280282
* `xo`
281283
* JSON
282284
* `cspell`
285+
* `dprint`
283286
* `eslint`
284287
* `fixjson`
285288
* `jq`
@@ -537,6 +540,7 @@ Notes:
537540
* `solhint`
538541
* `solium`
539542
* SQL
543+
* `dprint`
540544
* `pgformatter`
541545
* `sql-lint`
542546
* `sqlfmt`
@@ -583,9 +587,12 @@ Notes:
583587
* Thrift
584588
* `thrift`
585589
* `thriftcheck`
590+
* TOML
591+
* `dprint`
586592
* TypeScript
587593
* `cspell`
588594
* `deno`
595+
* `dprint`
589596
* `eslint`
590597
* `fecs`
591598
* `prettier`

doc/ale-toml.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
===============================================================================
2+
ALE TOML Integration *ale-toml-options*
3+
4+
5+
===============================================================================
6+
dprint *ale-toml-dprint*
7+
8+
See |ale-dprint-options| and https://dprint.dev/plugins/toml
9+
10+
11+
===============================================================================
12+
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

doc/ale-typescript.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ g:ale_deno_importMap *g:ale_deno_importMap*
5050
Specify the import map filename to load url maps in a deno project.
5151

5252

53+
===============================================================================
54+
dprint *ale-typescript-dprint*
55+
56+
See |ale-dprint-options| and https://dprint.dev/plugins/typescript
57+
58+
5359
===============================================================================
5460
eslint *ale-typescript-eslint*
5561

0 commit comments

Comments
 (0)