diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index e7b48b4583..1ae6763452 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -656,6 +656,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['javascript', 'typescript'], \ 'description': 'Apply biome (ex. rome) check to a file.', \ }, +\ 'taplo': { +\ 'function': 'ale#fixers#taplo#Fix', +\ 'suggested_filetypes': ['toml'], +\ 'description': 'Fix TOML files using taplo.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/taplo.vim b/autoload/ale/fixers/taplo.vim new file mode 100644 index 0000000000..e11e08ae10 --- /dev/null +++ b/autoload/ale/fixers/taplo.vim @@ -0,0 +1,10 @@ +" Author: Jeremy Cantrell +" Description: A versatile, feature-rich TOML toolkit + +function! ale#fixers#taplo#Fix(buffer) abort + let l:executable = ale#handlers#taplo#GetExecutable(a:buffer) + + return { + \ 'command': ale#Escape(l:executable) . ' format -' + \} +endfunction diff --git a/autoload/ale/handlers/taplo.vim b/autoload/ale/handlers/taplo.vim new file mode 100644 index 0000000000..42dd4d275b --- /dev/null +++ b/autoload/ale/handlers/taplo.vim @@ -0,0 +1,8 @@ +" Author: Jeremy Cantrell +" Description: A versatile, feature-rich TOML toolkit + +call ale#Set('taplo_executable', 'taplo') + +function! ale#handlers#taplo#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'taplo_executable') +endfunction diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 4b583d56ad..446cba3e88 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -654,6 +654,7 @@ Notes: * `thriftcheck` * TOML * `dprint` + * `taplo` * TypeScript * `biome` * `cspell` diff --git a/doc/ale-toml.txt b/doc/ale-toml.txt index 222a91f445..9f7bb7d7b5 100644 --- a/doc/ale-toml.txt +++ b/doc/ale-toml.txt @@ -8,5 +8,11 @@ dprint *ale-toml-dprint* See |ale-dprint-options| and https://dprint.dev/plugins/toml +=============================================================================== +taplo *ale-toml-taplo* + +See https://taplo.tamasfe.dev/ + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 5254b9d65a..c4734cfe91 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -3440,6 +3440,7 @@ documented in additional help files. thriftcheck...........................|ale-thrift-thriftcheck| toml....................................|ale-toml-options| dprint................................|ale-toml-dprint| + taplo.................................|ale-toml-taplo| typescript..............................|ale-typescript-options| biome.................................|ale-typescript-biome| cspell................................|ale-typescript-cspell| diff --git a/supported-tools.md b/supported-tools.md index aa6f65ddf1..78d09e7387 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -663,6 +663,7 @@ formatting. * [thriftcheck](https://github.com/pinterest/thriftcheck) * TOML * [dprint](https://dprint.dev) + * [taplo](https://taplo.tamasfe.dev) * TypeScript * [biome](http://biomejs.dev) * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) diff --git a/test/fixers/test_taplo_fixer.vader b/test/fixers/test_taplo_fixer.vader new file mode 100644 index 0000000000..f58e2d5276 --- /dev/null +++ b/test/fixers/test_taplo_fixer.vader @@ -0,0 +1,12 @@ +Before: + Save g:ale_taplo_executable + +After: + Restore + +Execute(The taplo fixer should use the options you set): + let g:ale_taplo_executable = 'foo' + + AssertEqual + \ {'command': ale#Escape('foo') . ' format -'}, + \ ale#fixers#taplo#Fix(bufnr(''))