From 916c8764ce9d395f788eae9adf207a4bfe8a038e Mon Sep 17 00:00:00 2001 From: Matheus Gabriel Werny <46067952+Spixmaster@users.noreply.github.com> Date: Fri, 15 May 2026 00:00:05 +0200 Subject: [PATCH] Support for tex-fmt (#5127) * Support for tex-fmt Support for tex-fmt, https://github.com/WGUNDERWOOD/tex-fmt. * Remove file type plaintex Remove file type plaintex as tex-fmt is solely for LaTeX. See https://superuser.com/questions/208177/vim-and-tex-filetypes-plaintex-vs-tex for a distinction. --- autoload/ale/fix/registry.vim | 5 ++++ autoload/ale/fixers/tex_fmt.vim | 20 ++++++++++++++++ doc/ale-supported-languages-and-tools.txt | 1 + doc/ale-tex.txt | 24 +++++++++++++++++++ doc/ale.txt | 1 + supported-tools.md | 1 + test/fixers/test_tex_fmt_fixer_callback.vader | 12 ++++++++++ 7 files changed, 64 insertions(+) create mode 100644 autoload/ale/fixers/tex_fmt.vim create mode 100644 test/fixers/test_tex_fmt_fixer_callback.vader diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index c40f802b3..9fb97345d 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -777,6 +777,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['markdown'], \ 'description': 'Fix markdown files with rumdl.', \ }, +\ 'tex-fmt': { +\ 'function': 'ale#fixers#tex_fmt#Fix', +\ 'suggested_filetypes': ['bib', 'tex'], +\ 'description': 'Fix LaTeX and bibliography files with tex-fmt.', +\ } \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/tex_fmt.vim b/autoload/ale/fixers/tex_fmt.vim new file mode 100644 index 000000000..34f51f3f2 --- /dev/null +++ b/autoload/ale/fixers/tex_fmt.vim @@ -0,0 +1,20 @@ +" Author: https://github.com/Spixmaster +" Description: Fix LaTeX and bibliography files with tex-fmt. + +call ale#Set('tex_tex_fmt_executable', 'tex-fmt') +call ale#Set('tex_tex_fmt_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('tex_tex_fmt_options', '') + +function! ale#fixers#tex_fmt#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'tex_tex_fmt', + \ ['tex-fmt'] + \) + + let l:options = ale#Var(a:buffer, 'tex_tex_fmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -s', + \} +endfunction diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 97cec8144..b53c5c915 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -373,6 +373,7 @@ Notes: * `lacheck` * `proselint` * `redpen` + * `tex-fmt` * `texlab` * `textlint` * `vale` diff --git a/doc/ale-tex.txt b/doc/ale-tex.txt index fde97b8e4..ca0a0e26f 100644 --- a/doc/ale-tex.txt +++ b/doc/ale-tex.txt @@ -70,6 +70,30 @@ g:ale_tex_latexindent_options This variable can be changed to modify flags given to latexindent. +=============================================================================== +tex-fmt *ale-tex-tex-fmt* + + *ale-options.tex_tex_fmt_executable* + *g:ale_tex_tex_fmt_executable* + *b:ale_tex_tex_fmt_executable* +tex_tex_fmt_executable +g:ale_tex_tex_fmt_executable + Type: |String| + Default: `'tex-fmt'` + + See |ale-integrations-local-executables|. + + *ale-options.tex_tex_fmt_options* + *g:ale_tex_tex_fmt_options* + *b:ale_tex_tex_fmt_options* +tex_tex_fmt_options +g:ale_tex_tex_fmt_options + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to tex-fmt. + + =============================================================================== texlab *ale-tex-texlab* diff --git a/doc/ale.txt b/doc/ale.txt index 361dc75e0..0c20eaf19 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -4008,6 +4008,7 @@ documented in additional help files. cspell................................|ale-tex-cspell| lacheck...............................|ale-tex-lacheck| latexindent...........................|ale-tex-latexindent| + tex-fmt...............................|ale-tex-tex-fmt| texlab................................|ale-tex-texlab| redpen................................|ale-tex-redpen| texinfo.................................|ale-texinfo-options| diff --git a/supported-tools.md b/supported-tools.md index 7a077ff87..fad93f2ff 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -383,6 +383,7 @@ formatting. * [lacheck](https://www.ctan.org/pkg/lacheck) * [proselint](http://proselint.com/) * [redpen](http://redpen.cc/) + * [tex-fmt](https://github.com/WGUNDERWOOD/tex-fmt) * [texlab](https://texlab.netlify.com) :speech_balloon: * [textlint](https://textlint.github.io/) * [vale](https://github.com/ValeLint/vale) diff --git a/test/fixers/test_tex_fmt_fixer_callback.vader b/test/fixers/test_tex_fmt_fixer_callback.vader new file mode 100644 index 000000000..4bea7df20 --- /dev/null +++ b/test/fixers/test_tex_fmt_fixer_callback.vader @@ -0,0 +1,12 @@ +Before: + call ale#assert#SetUpFixerTest('tex', 'tex-fmt') + +After: + Restore + + call ale#assert#TearDownFixerTest() + +Execute(The tex-fmt callback should return the correct default command): + AssertEqual + \ {'command': ale#Escape('tex-fmt') . ' -s'}, + \ ale#fixers#tex_fmt#Fix(bufnr(''))