diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index a8bcad7c..efa1fe75 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -129,6 +129,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['hurl'], \ 'description': 'Fix hurl files with hurlfmt.', \ }, +\ 'kulala_fmt': { +\ 'function': 'ale#fixers#kulala_fmt#Fix', +\ 'suggested_filetypes': ['http', 'rest'], +\ 'description': 'Fix http and rest files with kulala_fmt.', +\ }, \ 'tidy': { \ 'function': 'ale#fixers#tidy#Fix', \ 'suggested_filetypes': ['html'], diff --git a/autoload/ale/fixers/kulala_fmt.vim b/autoload/ale/fixers/kulala_fmt.vim new file mode 100644 index 00000000..10e81450 --- /dev/null +++ b/autoload/ale/fixers/kulala_fmt.vim @@ -0,0 +1,11 @@ +" Author: hsanson +" Description: kulala_fmt fixer for http and rest files. + +call ale#Set('http_kulala_fmt_executable', 'kulala-fmt') + +function! ale#fixers#kulala_fmt#Fix(buffer) abort + return { + \ 'command': ale#Escape(ale#Var(a:buffer, 'http_kulala_fmt_executable')) . ' format %t > /dev/null', + \ 'read_temporary_file': 1 + \ } +endfunction diff --git a/doc/ale-http.txt b/doc/ale-http.txt new file mode 100644 index 00000000..aba52d34 --- /dev/null +++ b/doc/ale-http.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE HTTP Integration *ale-http-options* + + +=============================================================================== +kulala_fmt *ale-http-kulala_fmt* + +g:ale_http_kulala_fmt *g:ale_http_kulala_fmt_executable* + *b:ale_http_kulala_fmt_executable* + Type: |String| + Default: `'kulala_fmt'` + + Override the invoked kulala_fmt binary. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-rest.txt b/doc/ale-rest.txt new file mode 100644 index 00000000..e81d319a --- /dev/null +++ b/doc/ale-rest.txt @@ -0,0 +1,11 @@ +=============================================================================== +ALE REST Integration *ale-rest-options* + + +=============================================================================== +kulala_fmt *ale-rest-kulala_fmt* + +See |ale-http-kulala_fmt| + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 50b32ddc..ee225b72 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -291,6 +291,8 @@ Notes: * djlint * HTML Django * djlint +* HTTP + * kulala_fmt * Hurl * `hurlfmt` * Idris @@ -569,6 +571,8 @@ Notes: * `cspell` * `opacheck` * `opafmt` +* REST + * kulala_fmt * reStructuredText * `alex` * `cspell` diff --git a/doc/ale.txt b/doc/ale.txt index f50b2dfd..d97bbe76 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -3123,6 +3123,8 @@ documented in additional help files. djlint................................|ale-htmlangular-djlint| html django template....................|ale-htmldjango-options| djlint................................|ale-htmldjango-djlint| + http....................................|ale-http-options| + kulala_fmt............................|ale-http-kulala_fmt| hurl....................................|ale-hurl-options| hurlfmt...............................|ale-hurl-hurlfmt| idris...................................|ale-idris-options| @@ -3371,6 +3373,8 @@ documented in additional help files. cspell................................|ale-rego-cspell| opacheck..............................|ale-rego-opa-check| opafmt................................|ale-rego-opa-fmt-fixer| + rest....................................|ale-rest-options| + kulala_fmt............................|ale-rest-kulala_fmt| restructuredtext........................|ale-restructuredtext-options| cspell................................|ale-restructuredtext-cspell| textlint..............................|ale-restructuredtext-textlint| diff --git a/supported-tools.md b/supported-tools.md index 0ccf543e..fa3200ea 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -300,6 +300,8 @@ formatting. * [djlint](https://djlint.com/) * HTML Django * [djlint](https://djlint.com/) +* HTTP + * [kulala_fmt](https://github.com/mistweaverco/kulala-fmt) * Hurl * [hurlfmt](https://hurl.dev) * Idris @@ -578,6 +580,8 @@ formatting. * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) * [opacheck](https://www.openpolicyagent.org/docs/latest/cli/#opa-check) * [opafmt](https://www.openpolicyagent.org/docs/latest/cli/#opa-fmt) +* REST + * [kulala_fmt](https://github.com/mistweaverco/kulala-fmt) * reStructuredText * [alex](https://github.com/get-alex/alex) * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) diff --git a/test/fixers/test_kulala_fmt_fixer_callback.vader b/test/fixers/test_kulala_fmt_fixer_callback.vader new file mode 100644 index 00000000..8431a8fd --- /dev/null +++ b/test/fixers/test_kulala_fmt_fixer_callback.vader @@ -0,0 +1,23 @@ +Before: + Save g:ale_http_kulala_fmt_executable + + " Use an invalid global executable, so we don't match it. + let g:ale_http_kulala_fmt_executable = 'xxxinvalid' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The kualala_fmt callback should return the correct default values): + call ale#test#SetFilename('../test-files/http/dummy.http') + + AssertEqual + \ { + \ 'command': ale#Escape(g:ale_http_kulala_fmt_executable) + \ . ' format %t > /dev/null', + \ 'read_temporary_file': 1, + \ }, + \ ale#fixers#kulala_fmt#Fix(bufnr(''))