mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 05:04:28 +08:00
Add remark-lint for a markdown fixer (#2836)
This commit is contained in:
@@ -365,6 +365,11 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['nix'],
|
\ 'suggested_filetypes': ['nix'],
|
||||||
\ 'description': 'A formatter for Nix code',
|
\ 'description': 'A formatter for Nix code',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'remark-lint': {
|
||||||
|
\ 'function': 'ale#fixers#remark_lint#Fix',
|
||||||
|
\ 'suggested_filetypes': ['markdown'],
|
||||||
|
\ 'description': 'Fix markdown files with remark-lint',
|
||||||
|
\ },
|
||||||
\ 'html-beautify': {
|
\ 'html-beautify': {
|
||||||
\ 'function': 'ale#fixers#html_beautify#Fix',
|
\ 'function': 'ale#fixers#html_beautify#Fix',
|
||||||
\ 'suggested_filetypes': ['html', 'htmldjango'],
|
\ 'suggested_filetypes': ['html', 'htmldjango'],
|
||||||
|
|||||||
24
autoload/ale/fixers/remark_lint.vim
Normal file
24
autoload/ale/fixers/remark_lint.vim
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
" Author: blyoa <blyoa110@gmail.com>
|
||||||
|
" Description: Fixing files with remark-lint.
|
||||||
|
|
||||||
|
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#fixers#remark_lint#GetExecutable(buffer) abort
|
||||||
|
return ale#node#FindExecutable(a:buffer, 'markdown_remark_lint', [
|
||||||
|
\ 'node_modules/remark-cli/cli.js',
|
||||||
|
\ 'node_modules/.bin/remark',
|
||||||
|
\])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale#fixers#remark_lint#Fix(buffer) abort
|
||||||
|
let l:executable = ale#fixers#remark_lint#GetExecutable(a:buffer)
|
||||||
|
let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options')
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable)
|
||||||
|
\ . (!empty(l:options) ? ' ' . l:options : ''),
|
||||||
|
\}
|
||||||
|
endfunction
|
||||||
|
|
||||||
24
test/fixers/test_remark_lint_fixer_callback.vader
Normal file
24
test/fixers/test_remark_lint_fixer_callback.vader
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
Before:
|
||||||
|
Save g:ale_markdown_remark_lint_executable
|
||||||
|
Save g:ale_markdown_remark_lint_options
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
Execute(The remark callback should return the correct default values):
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('remark')
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#remark_lint#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The remark executable and options should be configurable):
|
||||||
|
let g:ale_markdown_remark_lint_executable = '/path/to/remark'
|
||||||
|
let g:ale_markdown_remark_lint_options = '-h'
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('/path/to/remark')
|
||||||
|
\ . ' -h',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#remark_lint#Fix(bufnr(''))
|
||||||
Reference in New Issue
Block a user