summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGötz Christ <2220440+goetzc@users.noreply.github.com>2022-11-21 05:47:05 -0500
committerGitHub <noreply@github.com>2022-11-21 19:47:05 +0900
commitca355f4cb45ea3508548045ca7b9cc73f3741e69 (patch)
treef80d37a49fc27186b906f6be8e63b9bad7cade79
parent4b433e5693ccec8e408504c4b139b8f7cc6a4aa3 (diff)
downloadale-ca355f4cb45ea3508548045ca7b9cc73f3741e69.zip
Markdown: allow passing custom executable for markdownlint (#4358)
-rw-r--r--ale_linters/markdown/markdownlint.vim9
-rw-r--r--doc/ale-markdown.txt9
-rw-r--r--test/linter/test_markdown_markdownlint.vader5
3 files changed, 21 insertions, 2 deletions
diff --git a/ale_linters/markdown/markdownlint.vim b/ale_linters/markdown/markdownlint.vim
index 7a293938..424c9f24 100644
--- a/ale_linters/markdown/markdownlint.vim
+++ b/ale_linters/markdown/markdownlint.vim
@@ -1,10 +1,15 @@
" Author: Ty-Lucas Kelley <tylucaskelley@gmail.com>
" Description: Adds support for markdownlint
+call ale#Set('markdown_markdownlint_executable', 'markdownlint')
call ale#Set('markdown_markdownlint_options', '')
+function! ale_linters#markdown#markdownlint#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'markdown_markdownlint_executable')
+endfunction
+
function! ale_linters#markdown#markdownlint#GetCommand(buffer) abort
- let l:executable = 'markdownlint'
+ let l:executable = ale_linters#markdown#markdownlint#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'markdown_markdownlint_options')
@@ -14,7 +19,7 @@ endfunction
call ale#linter#Define('markdown', {
\ 'name': 'markdownlint',
-\ 'executable': 'markdownlint',
+\ 'executable': function('ale_linters#markdown#markdownlint#GetExecutable'),
\ 'lint_file': 1,
\ 'output_stream': 'both',
\ 'command': function('ale_linters#markdown#markdownlint#GetCommand'),
diff --git a/doc/ale-markdown.txt b/doc/ale-markdown.txt
index 6ba78ff0..3f44da27 100644
--- a/doc/ale-markdown.txt
+++ b/doc/ale-markdown.txt
@@ -17,6 +17,15 @@ See |ale-dprint-options| and https://dprint.dev/plugins/markdown
===============================================================================
markdownlint *ale-markdown-markdownlint*
+g:ale_markdown_markdown_executable *g:ale_markdown_markdownlint_executable*
+ *b:ale_markdown_markdownlint_executable*
+ Type: |String|
+ Default: `'markdownlint'`
+
+ Override the invoked markdownlint binary. You can use other binaries such as
+ markdownlint-cli2.
+
+
g:ale_markdown_markdownlint_options *g:ale_markdown_markdownlint_options*
*b:ale_markdown_markdownlint_options*
Type: |String|
diff --git a/test/linter/test_markdown_markdownlint.vader b/test/linter/test_markdown_markdownlint.vader
index 12766cfd..b938ac41 100644
--- a/test/linter/test_markdown_markdownlint.vader
+++ b/test/linter/test_markdown_markdownlint.vader
@@ -7,6 +7,11 @@ After:
Execute(The default command should be correct):
AssertLinter 'markdownlint', ale#Escape('markdownlint') . ' %s'
+Execute(The executable should be configurable):
+ let g:ale_markdown_markdownlint_executable = 'foo bar'
+
+ AssertLinter 'foo bar', ale#Escape('foo bar') . ' %s'
+
Execute(The options should be configurable):
let g:ale_markdown_markdownlint_options = '--config ~/custom/.markdownlintrc'