diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 9fb97345d3..2fb46b3778 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -737,6 +737,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['clojure'], \ 'description': 'formatter and linter for clojure files', \ }, +\ 'janet-format': { +\ 'function': 'ale#fixers#janet_format#Fix', +\ 'suggested_filetypes': ['janet'], +\ 'description': 'Formatter for janet files', +\ }, \ 'typstyle': { \ 'function': 'ale#fixers#typstyle#Fix', \ 'suggested_filetypes': ['typst'], diff --git a/autoload/ale/fixers/janet_format.vim b/autoload/ale/fixers/janet_format.vim new file mode 100644 index 0000000000..7a8ddc45f4 --- /dev/null +++ b/autoload/ale/fixers/janet_format.vim @@ -0,0 +1,13 @@ +" Author: David Gouch +" Description: Format with janet-format https://github.com/janet-lang/spork + +call ale#Set('janet_janet_format_executable', 'janet-format') + +function! ale#fixers#janet_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'janet_janet_format_executable') + + return { + \ 'command': ale#Escape(l:executable) . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/doc/ale-janet.txt b/doc/ale-janet.txt new file mode 100644 index 0000000000..acc6dd5234 --- /dev/null +++ b/doc/ale-janet.txt @@ -0,0 +1,19 @@ +=============================================================================== +ALE Janet Integration *ale-janet-options* + + +=============================================================================== +janet-format *ale-janet-janet-format* + + *ale-options.janet_janet_format_executable* + *g:ale_janet_janet_format_executable* + *b:ale_janet_janet_format_executable* +janet_janet_format_executable +g:ale_janet_janet_format_executable + Type: |String| + Default: `'janet-format'` + + This variable sets the executable used for janet-format. + +=============================================================================== + 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 90b470b932..6579f196fe 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -309,6 +309,8 @@ Notes: * `inko` !! * ISPC * `ispc`!! +* Janet + * `janet-format` * Java * `PMD` * `checkstyle`!! diff --git a/doc/ale.txt b/doc/ale.txt index 99d1d621f6..6cf109f7d4 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -3667,6 +3667,8 @@ documented in additional help files. inko..................................|ale-inko-inko| ispc....................................|ale-ispc-options| ispc..................................|ale-ispc-ispc| + janet...................................|ale-janet-options| + janet-format..........................|ale-janet-janet-format| java....................................|ale-java-options| checkstyle............................|ale-java-checkstyle| clang-format..........................|ale-java-clangformat| diff --git a/supported-tools.md b/supported-tools.md index 6007ced02c..5e44297d13 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -319,6 +319,8 @@ formatting. * [inko](https://inko-lang.org/) :floppy_disk: * ISPC * [ispc](https://ispc.github.io/) :floppy_disk: +* Janet + * [janet-format](https://github.com/janet-lang/spork) * Java * [PMD](https://pmd.github.io/) * [checkstyle](http://checkstyle.sourceforge.net) :floppy_disk: diff --git a/test/fixers/test_janet_format_fixer_callback.vader b/test/fixers/test_janet_format_fixer_callback.vader new file mode 100644 index 0000000000..db34bd4a9c --- /dev/null +++ b/test/fixers/test_janet_format_fixer_callback.vader @@ -0,0 +1,19 @@ +Before: + call ale#assert#SetUpFixerTest('janet', 'janet-format') + +After: + call ale#assert#TearDownFixerTest() + +Execute(The janet-format callback should return the correct default values): + AssertFixer { + \ 'command': ale#Escape('janet-format') . ' %t', + \ 'read_temporary_file': 1, + \} + +Execute(The janet-format callback should allow a custom executable): + let g:ale_janet_janet_format_executable = '/custom/path/to/janet-format' + + AssertFixer { + \ 'command': ale#Escape('/custom/path/to/janet-format') . ' %t', + \ 'read_temporary_file': 1, + \}