From ca1da76d5e91e42f676654905c0c7b6d074b8068 Mon Sep 17 00:00:00 2001 From: yoan667 <125768742+yoan667@users.noreply.github.com> Date: Sat, 22 Nov 2025 13:16:50 +0100 Subject: [PATCH] add markdownlint fixer for markdown (#5066) --- autoload/ale/fix/registry.vim | 5 +++++ autoload/ale/fixers/markdownlint.vim | 15 +++++++++++++++ .../test_markdownlint_fixer_callback.vader | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 autoload/ale/fixers/markdownlint.vim create mode 100644 test/fixers/test_markdownlint_fixer_callback.vader diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index debfb88a..eac4efb9 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -752,6 +752,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['verilog'], \ 'description': 'Formats verilog files using verible.', \ }, +\ 'markdownlint': { +\ 'function': 'ale#fixers#markdownlint#Fix', +\ 'suggested_filetypes': ['markdown'], +\ 'description': 'Fix markdown files with markdownlint.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/markdownlint.vim b/autoload/ale/fixers/markdownlint.vim new file mode 100644 index 00000000..10e7a091 --- /dev/null +++ b/autoload/ale/fixers/markdownlint.vim @@ -0,0 +1,15 @@ +:scriptencoding utf-8 + +call ale#Set('markdownlint_executable', 'markdownlint') +call ale#Set('markdownlint_options', '--fix') + +function! ale#fixers#markdownlint#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'markdownlint_executable') + let l:options = ale#Var(a:buffer, 'markdownlint_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . l:options, + \} +endfunction + diff --git a/test/fixers/test_markdownlint_fixer_callback.vader b/test/fixers/test_markdownlint_fixer_callback.vader new file mode 100644 index 00000000..2a03e734 --- /dev/null +++ b/test/fixers/test_markdownlint_fixer_callback.vader @@ -0,0 +1,17 @@ +Before: + call ale#assert#SetUpFixerTest('markdown', 'markdownlint') + +After: + call ale#assert#TearDownFixerTest() + +Execute: + AssertFixer { + \ 'command': ale#Escape('markdownlint') . ' --fix', + \} + +Execute: + let g:ale_markdownlint_executable = 'custom_markdownlint' + + AssertFixer { + \ 'command': ale#Escape('custom_markdownlint') . ' --fix', + \}