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', + \}