summaryrefslogtreecommitdiff
path: root/ale_linters/markdown
diff options
context:
space:
mode:
authorTakashi WADA <twada@amy.hi-ho.ne.jp>2018-07-10 22:05:49 +0900
committerWADA Takashi <twada@amy.hi-ho.ne.jp>2018-07-16 18:33:21 +0900
commitf369aa65a22e2aa2c4d7e6a1d30dcbcf2ad9ea4a (patch)
treeb49ce4aaea037665950336ec528c3ef15234b52d /ale_linters/markdown
parentfcd62342d531bdeacbd41a8dfa6163301f1fdf9b (diff)
downloadale-f369aa65a22e2aa2c4d7e6a1d30dcbcf2ad9ea4a.zip
Support remark-lint installed locally
Diffstat (limited to 'ale_linters/markdown')
-rw-r--r--ale_linters/markdown/remark_lint.vim22
1 files changed, 20 insertions, 2 deletions
diff --git a/ale_linters/markdown/remark_lint.vim b/ale_linters/markdown/remark_lint.vim
index 98dd0d7b..7e55c972 100644
--- a/ale_linters/markdown/remark_lint.vim
+++ b/ale_linters/markdown/remark_lint.vim
@@ -1,5 +1,23 @@
" Author rhysd https://rhysd.github.io/, Dirk Roorda (dirkroorda), Adrián González Rus (@adrigzr)
" Description: remark-lint for Markdown files
+call ale#Set('markdown_remark_lint_executable', 'remark')
+call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('markdown_remark_lint_options', '')
+
+function! ale_linters#markdown#remark_lint#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'markdown_remark_lint', [
+ \ 'node_modules/.bin/remark',
+ \])
+endfunction
+
+function! ale_linters#markdown#remark_lint#GetCommand(buffer) abort
+ let l:executable = ale_linters#markdown#remark_lint#GetExecutable(a:buffer)
+ let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options')
+
+ return ale#node#Executable(a:buffer, l:executable)
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' --no-stdout --no-color %s'
+endfunction
function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort
" matches: ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint'
@@ -26,8 +44,8 @@ endfunction
call ale#linter#Define('markdown', {
\ 'name': 'remark-lint',
-\ 'executable': 'remark',
-\ 'command': 'remark --no-stdout --no-color %s',
+\ 'executable_callback': 'ale_linters#markdown#remark_lint#GetExecutable',
+\ 'command_callback': 'ale_linters#markdown#remark_lint#GetCommand',
\ 'callback': 'ale_linters#markdown#remark_lint#Handle',
\ 'lint_file': 1,
\ 'output_stream': 'stderr',