Support remark-lint installed locally
This commit is contained in:
parent
fcd62342d5
commit
f369aa65a2
4 changed files with 84 additions and 2 deletions
|
@ -1,5 +1,23 @@
|
||||||
" Author rhysd https://rhysd.github.io/, Dirk Roorda (dirkroorda), Adrián González Rus (@adrigzr)
|
" Author rhysd https://rhysd.github.io/, Dirk Roorda (dirkroorda), Adrián González Rus (@adrigzr)
|
||||||
" Description: remark-lint for Markdown files
|
" 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
|
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'
|
" 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', {
|
call ale#linter#Define('markdown', {
|
||||||
\ 'name': 'remark-lint',
|
\ 'name': 'remark-lint',
|
||||||
\ 'executable': 'remark',
|
\ 'executable_callback': 'ale_linters#markdown#remark_lint#GetExecutable',
|
||||||
\ 'command': 'remark --no-stdout --no-color %s',
|
\ 'command_callback': 'ale_linters#markdown#remark_lint#GetCommand',
|
||||||
\ 'callback': 'ale_linters#markdown#remark_lint#Handle',
|
\ 'callback': 'ale_linters#markdown#remark_lint#Handle',
|
||||||
\ 'lint_file': 1,
|
\ 'lint_file': 1,
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
|
|
|
@ -28,6 +28,33 @@ prettier *ale-markdown-prettier*
|
||||||
See |ale-javascript-prettier| for information about the available options.
|
See |ale-javascript-prettier| for information about the available options.
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
remark-lint *ale-markdown-remark-lint*
|
||||||
|
|
||||||
|
g:ale_markdown_remark_lint_executable *g:ale_markdown_remark_lint_executable*
|
||||||
|
*b:ale_markdown_remark_lint_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'remark'`
|
||||||
|
|
||||||
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_markdown_remark_lint_options *g:ale_markdown_remark_lint_options*
|
||||||
|
*b:ale_markdown_remark_lint_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to remark-lint.
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_markdown_remark_lint_use_global *g:ale_markdown_remark_lint_use_global*
|
||||||
|
*b:ale_markdown_remark_lint_use_global*
|
||||||
|
Type: |Number|
|
||||||
|
Default: `get(g:, 'ale_use_global_executables', 0)`
|
||||||
|
|
||||||
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
textlint *ale-markdown-textlint*
|
textlint *ale-markdown-textlint*
|
||||||
|
|
||||||
|
|
0
test/command_callback/remark_lint_paths/with_bin_path/node_modules/.bin/remark
generated
vendored
Executable file
0
test/command_callback/remark_lint_paths/with_bin_path/node_modules/.bin/remark
generated
vendored
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
Before:
|
||||||
|
" This is just one language for the linter.
|
||||||
|
call ale#assert#SetUpLinterTest('markdown', 'remark_lint')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
Execute(The default command should be correct):
|
||||||
|
AssertLinter 'remark',
|
||||||
|
\ ale#Escape('remark') . ' --no-stdout --no-color %s'
|
||||||
|
|
||||||
|
Execute(The executable should be configurable):
|
||||||
|
let b:ale_markdown_remark_lint_executable = 'foobar'
|
||||||
|
|
||||||
|
AssertLinter 'foobar',
|
||||||
|
\ ale#Escape('foobar') . ' --no-stdout --no-color %s'
|
||||||
|
|
||||||
|
Execute(The options should be configurable):
|
||||||
|
let b:ale_markdown_remark_lint_options = '--something'
|
||||||
|
|
||||||
|
AssertLinter 'remark',
|
||||||
|
\ ale#Escape('remark') . ' --something --no-stdout --no-color %s'
|
||||||
|
|
||||||
|
Execute(The local executable from .bin should be used if available):
|
||||||
|
call ale#test#SetFilename('remark_lint_paths/with_bin_path/foo.md')
|
||||||
|
|
||||||
|
AssertLinter
|
||||||
|
\ ale#path#Simplify(g:dir . '/remark_lint_paths/with_bin_path/node_modules/.bin/remark'),
|
||||||
|
\ ale#Escape(ale#path#Simplify(g:dir . '/remark_lint_paths/with_bin_path/node_modules/.bin/remark'))
|
||||||
|
\ . ' --no-stdout --no-color %s'
|
||||||
|
|
||||||
|
Execute(The global executable should be uesd if the option is set):
|
||||||
|
let b:ale_markdown_remark_lint_use_global = 1
|
||||||
|
call ale#test#SetFilename('remark_lint_paths/with_bin_path/foo.md')
|
||||||
|
|
||||||
|
AssertLinter 'remark', ale#Escape('remark')
|
||||||
|
\ . ' --no-stdout --no-color %s'
|
Reference in a new issue