summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorblyoa <blyoa@users.noreply.github.com>2020-08-17 18:14:38 +0900
committerGitHub <noreply@github.com>2020-08-17 10:14:38 +0100
commitd5c1d842307a4c916905d5160544cfe152a16ee0 (patch)
tree85bc13692b7dadda74d54c9a409043ddc16d3a5a /autoload
parent5c778e1ae752163a849609318ace6c3c6a37d6f7 (diff)
downloadale-d5c1d842307a4c916905d5160544cfe152a16ee0.zip
Add remark-lint for a markdown fixer (#2836)
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/remark_lint.vim24
2 files changed, 29 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 02b02699..94476ca9 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -365,6 +365,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['nix'],
\ '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': {
\ 'function': 'ale#fixers#html_beautify#Fix',
\ 'suggested_filetypes': ['html', 'htmldjango'],
diff --git a/autoload/ale/fixers/remark_lint.vim b/autoload/ale/fixers/remark_lint.vim
new file mode 100644
index 00000000..3ce442f3
--- /dev/null
+++ b/autoload/ale/fixers/remark_lint.vim
@@ -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
+