Skip to content

Commit ca1da76

Browse files
authored
add markdownlint fixer for markdown (#5066)
1 parent 962a932 commit ca1da76

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

autoload/ale/fix/registry.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,11 @@ let s:default_registry = {
752752
\ 'suggested_filetypes': ['verilog'],
753753
\ 'description': 'Formats verilog files using verible.',
754754
\ },
755+
\ 'markdownlint': {
756+
\ 'function': 'ale#fixers#markdownlint#Fix',
757+
\ 'suggested_filetypes': ['markdown'],
758+
\ 'description': 'Fix markdown files with markdownlint.',
759+
\ },
755760
\}
756761

757762
" Reset the function registry to the default entries.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
:scriptencoding utf-8
2+
3+
call ale#Set('markdownlint_executable', 'markdownlint')
4+
call ale#Set('markdownlint_options', '--fix')
5+
6+
function! ale#fixers#markdownlint#Fix(buffer) abort
7+
let l:executable = ale#Var(a:buffer, 'markdownlint_executable')
8+
let l:options = ale#Var(a:buffer, 'markdownlint_options')
9+
10+
return {
11+
\ 'command': ale#Escape(l:executable)
12+
\ . ' ' . l:options,
13+
\}
14+
endfunction
15+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Before:
2+
call ale#assert#SetUpFixerTest('markdown', 'markdownlint')
3+
4+
After:
5+
call ale#assert#TearDownFixerTest()
6+
7+
Execute:
8+
AssertFixer {
9+
\ 'command': ale#Escape('markdownlint') . ' --fix',
10+
\}
11+
12+
Execute:
13+
let g:ale_markdownlint_executable = 'custom_markdownlint'
14+
15+
AssertFixer {
16+
\ 'command': ale#Escape('custom_markdownlint') . ' --fix',
17+
\}

0 commit comments

Comments
 (0)