mirror of
https://github.com/dense-analysis/ale
synced 2024-12-24 23:22:29 +00:00
Use the configured mdl executable, escape it in the command, and add test for it
This commit is contained in:
parent
857723e7d5
commit
565ffa0dc5
@ -4,6 +4,18 @@
|
||||
call ale#Set('markdown_mdl_executable', 'mdl')
|
||||
call ale#Set('markdown_mdl_options', '')
|
||||
|
||||
function! ale_linters#markdown#mdl#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'markdown_mdl_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#markdown#mdl#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#markdown#mdl#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'markdown_mdl_options')
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
|
||||
" matches: '(stdin):173: MD004 Unordered list style'
|
||||
let l:pattern = ':\(\d*\): \(.*\)$'
|
||||
@ -20,17 +32,9 @@ function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#markdown#mdl#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'markdown_mdl_executable')
|
||||
let l:options = ale#Var(a:buffer, 'markdown_mdl_options')
|
||||
|
||||
return l:executable . (!empty(l:options) ? ' ' . l:options : '')
|
||||
endfunction
|
||||
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'mdl',
|
||||
\ 'executable': 'mdl',
|
||||
\ 'executable_callback': 'ale_linters#markdown#mdl#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#markdown#mdl#GetCommand',
|
||||
\ 'callback': 'ale_linters#markdown#mdl#Handle'
|
||||
\})
|
||||
|
@ -0,0 +1,28 @@
|
||||
Before:
|
||||
Save g:ale_markdown_mdl_executable
|
||||
Save g:ale_markdown_mdl_options
|
||||
|
||||
unlet! g:ale_markdown_mdl_executable
|
||||
unlet! g:ale_markdown_mdl_options
|
||||
|
||||
runtime ale_linters/markdown/mdl.vim
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The default command should be correct):
|
||||
AssertEqual ale_linters#markdown#mdl#GetExecutable(bufnr('')), 'mdl'
|
||||
AssertEqual
|
||||
\ ale_linters#markdown#mdl#GetCommand(bufnr('')),
|
||||
\ ale#Escape('mdl')
|
||||
|
||||
Execute(The executable and options should be configurable):
|
||||
let g:ale_markdown_mdl_executable = 'foo bar'
|
||||
let g:ale_markdown_mdl_options = '--wat'
|
||||
|
||||
AssertEqual ale_linters#markdown#mdl#GetExecutable(bufnr('')), 'foo bar'
|
||||
AssertEqual
|
||||
\ ale_linters#markdown#mdl#GetCommand(bufnr('')),
|
||||
\ ale#Escape('foo bar') . ' --wat'
|
Loading…
Reference in New Issue
Block a user