Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions ale_linters/markdown/rumdl.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
" Author: Evan Chen <evan@evanchen.cc>
" Description: Fast Markdown linter and formatter written in Rust


call ale#Set('markdown_rumdl_executable', 'rumdl')
call ale#Set('markdown_rumdl_options', '')

function! ale_linters#markdown#rumdl#GetProjectRoot(buffer) abort
let l:dotconfig = ale#path#FindNearestFile(a:buffer, '.rumdl.toml')
let l:config = ale#path#FindNearestFile(a:buffer, 'rumdl.toml')

if !empty(l:dotconfig) && !empty(l:config)
let l:nearest = len(l:dotconfig) >= len(l:config) ? l:dotconfig : l:config

return fnamemodify(l:nearest, ':h')
elseif !empty(l:dotconfig)
return fnamemodify(l:dotconfig, ':h')
elseif !empty(l:config)
return fnamemodify(l:config, ':h')
endif

" Try to find nearest pyproject.toml
let l:pyproject_file = ale#path#FindNearestFile(a:buffer, 'pyproject.toml')

if !empty(l:pyproject_file)
return fnamemodify(l:pyproject_file . '/', ':p:h:h')
endif

" Try to find nearest `git` directory
let l:gitdir = ale#path#FindNearestFile(a:buffer, '.git')

if !empty(l:gitdir)
return fnamemodify(l:gitdir . '/', ':p:h:h')
endif

return fnamemodify(bufname(a:buffer), ':p:h')
endfunction

call ale#linter#Define('markdown', {
\ 'name': 'rumdl',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'markdown_rumdl_executable')},
\ 'command': {b -> ale#Escape(ale#Var(b, 'markdown_rumdl_executable'))
\ . ' server --stdio'
\ . ale#Pad(ale#Var(b, 'markdown_rumdl_options'))},
\ 'project_root': function('ale_linters#markdown#rumdl#GetProjectRoot'),
\ 'language': 'markdown',
\})
5 changes: 5 additions & 0 deletions autoload/ale/fix/registry.vim
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['markdown'],
\ 'description': 'Fix markdown files with markdownlint.',
\ },
\ 'rumdl': {
\ 'function': 'ale#fixers#rumdl#Fix',
\ 'suggested_filetypes': ['markdown'],
\ 'description': 'Fix markdown files with rumdl.',
\ },
\}

" Reset the function registry to the default entries.
Expand Down
18 changes: 18 additions & 0 deletions autoload/ale/fixers/rumdl.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
scriptencoding utf-8

" Author: Evan Chen <evan@evanchen.cc>
" Description: Fast Markdown linter and formatter written in Rust


call ale#Set('markdown_rumdl_executable', 'rumdl')
call ale#Set('markdown_rumdl_fmt_options', '--silent')

function! ale#fixers#rumdl#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'markdown_rumdl_executable')
let l:options = ale#Var(a:buffer, 'markdown_rumdl_fmt_options')

return {
\ 'command': ale#Escape(l:executable) . ' fmt -'
\ . ale#Pad(l:options),
\}
endfunction
34 changes: 34 additions & 0 deletions doc/ale-markdown.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,40 @@ g:ale_markdown_remark_lint_use_global
See |ale-integrations-local-executables|


===============================================================================
rumdl *ale-markdown-rumdl*

*ale-options.markdown_rumdl_executable*
*g:ale_markdown_rumdl_executable*
*b:ale_markdown_rumdl_executable*
markdown_rumdl_executable
g:ale_markdown_rumdl_executable
Type: |String|
Default: `'rumdl'`

Override the invoked `rumdl` binary.

*ale-options.markdown_rumdl_options*
*g:ale_markdown_rumdl_options*
*b:ale_markdown_rumdl_options*
markdown_rumdl_options
g:ale_markdown_rumdl_options
Type: |String|
Default: `''`

This variable can be set to pass additional options to `rumdl server`.

*ale-options.markdown_rumdl_fmt_options*
*g:ale_markdown_rumdl_fmt_options*
*b:ale_markdown_rumdl_fmt_options*
markdown_rumdl_fmt_options
g:ale_markdown_rumdl_fmt_options
Type: |String|
Default: `'--silent'`

This variable can be set to pass additional options to `rumdl fmt`.


===============================================================================
textlint *ale-markdown-textlint*

Expand Down
1 change: 1 addition & 0 deletions doc/ale-supported-languages-and-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ Notes:
* `pymarkdown`
* `redpen`
* `remark-lint`
* `rumdl`
* `textlint`
* `vale`
* `write-good`
Expand Down
1 change: 1 addition & 0 deletions doc/ale.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3746,6 +3746,7 @@ documented in additional help files.
prettier..............................|ale-markdown-prettier|
pymarkdown............................|ale-markdown-pymarkdown|
remark-lint...........................|ale-markdown-remark-lint|
rumdl.................................|ale-markdown-rumdl|
textlint..............................|ale-markdown-textlint|
write-good............................|ale-markdown-write-good|
redpen................................|ale-markdown-redpen|
Expand Down
1 change: 1 addition & 0 deletions supported-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ formatting.
* [pymarkdown](https://github.com/jackdewinter/pymarkdown) :floppy_disk:
* [redpen](http://redpen.cc/)
* [remark-lint](https://github.com/wooorm/remark-lint)
* [rumdl](https://github.com/rvben/rumdl/issues) :speech_balloon:
* [textlint](https://textlint.github.io/)
* [vale](https://github.com/ValeLint/vale)
* [write-good](https://github.com/btford/write-good)
Expand Down
24 changes: 24 additions & 0 deletions test/fixers/test_rumdl_fixer_callback.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Before:
call ale#assert#SetUpFixerTest('markdown', 'rumdl')

After:
call ale#assert#TearDownFixerTest()

Execute:
AssertFixer {
\ 'command': ale#Escape('rumdl') . ' fmt - --silent',
\}

Execute:
let g:ale_markdown_rumdl_executable = 'rumdl_custom'

AssertFixer {
\ 'command': ale#Escape('rumdl_custom') . ' fmt - --silent',
\}

Execute:
let g:ale_markdown_rumdl_fmt_options = ''

AssertFixer {
\ 'command': ale#Escape('rumdl') . ' fmt -',
\}
18 changes: 18 additions & 0 deletions test/linter/test_markdown_rumdl.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Before:
call ale#assert#SetUpLinterTest('markdown', 'rumdl')

After:
call ale#assert#TearDownLinterTest()

Execute(The default command should be correct):
AssertLinter 'rumdl', ale#Escape('rumdl') . ' server --stdio'

Execute(The executable should be configurable):
let b:ale_markdown_rumdl_executable = 'rumdl_custom'

AssertLinter 'rumdl_custom', ale#Escape('rumdl_custom') . ' server --stdio'

Execute(The server options should be configurable):
let b:ale_markdown_rumdl_options = '--some-flag'

AssertLinter 'rumdl', ale#Escape('rumdl') . ' server --stdio --some-flag'
Loading