mirror of
https://github.com/dense-analysis/ale.git
synced 2026-04-21 15:17:58 +08:00
feat(markdown): add rumdl server and fixer (#5115)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
* feat: put in the main linter files * feat: add to registry * docs: add rumdl to docs * tests: vader tests * edit: actually split the options into two * style: make rumdl fixer test mimic markdownlint * fix: stupidity overwhelming * fix: actually let's look for pyproject too copied from tombi * i'm a buffoon fix wrong indentation * alignment ci is made for people like me * missed toc entry
This commit is contained in:
48
ale_linters/markdown/rumdl.vim
Normal file
48
ale_linters/markdown/rumdl.vim
Normal file
@@ -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',
|
||||
\})
|
||||
@@ -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.
|
||||
|
||||
18
autoload/ale/fixers/rumdl.vim
Normal file
18
autoload/ale/fixers/rumdl.vim
Normal file
@@ -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
|
||||
@@ -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*
|
||||
|
||||
|
||||
@@ -417,6 +417,7 @@ Notes:
|
||||
* `pymarkdown`
|
||||
* `redpen`
|
||||
* `remark-lint`
|
||||
* `rumdl`
|
||||
* `textlint`
|
||||
* `vale`
|
||||
* `write-good`
|
||||
|
||||
@@ -3748,6 +3748,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|
|
||||
|
||||
@@ -427,6 +427,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)
|
||||
|
||||
24
test/fixers/test_rumdl_fixer_callback.vader
Normal file
24
test/fixers/test_rumdl_fixer_callback.vader
Normal file
@@ -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
test/linter/test_markdown_rumdl.vader
Normal file
18
test/linter/test_markdown_rumdl.vader
Normal file
@@ -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'
|
||||
Reference in New Issue
Block a user