Skip to content

Commit 18cd44c

Browse files
pbnjPeter Benjamin
andauthored
feat(markdown): add marksman lsp (#4565)
* feat(markdown): add marksman lsp * docs: add marksman docs * test(markdown): add marksman test Co-authored-by: Peter Benjamin <peter.benjamin@peter.benjamin-FVFHP2WSQ05Q>
1 parent 1174b3b commit 18cd44c

File tree

6 files changed

+57
-0
lines changed

6 files changed

+57
-0
lines changed

ale_linters/markdown/marksman.vim

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
" Author: Peter Benjamin <petermbenjamin@gmail.com>
2+
" Description: Write Markdown with code assist and intelligence in the comfort of your favourite editor.
3+
4+
call ale#Set('markdown_marksman_executable', 'marksman')
5+
6+
function! ale_linters#markdown#marksman#GetCommand(buffer) abort
7+
return '%e server'
8+
endfunction
9+
10+
function! ale_linters#markdown#marksman#GetProjectRoot(buffer) abort
11+
" Find nearest .marksman.toml
12+
let l:marksman_toml = ale#path#FindNearestFile(a:buffer, '.marksman.toml')
13+
14+
if !empty(l:marksman_toml)
15+
return fnamemodify(l:marksman_toml, ':h')
16+
endif
17+
18+
" Find nearest .git/ directory
19+
let l:project_root = finddir('.git/..', expand('#' . a:buffer . '...').';')
20+
21+
if !empty(l:project_root)
22+
return l:project_root
23+
endif
24+
25+
return ''
26+
endfunction
27+
28+
call ale#linter#Define('markdown', {
29+
\ 'name': 'marksman',
30+
\ 'lsp': 'stdio',
31+
\ 'executable': {b -> ale#Var(b, 'markdown_marksman_executable')},
32+
\ 'command': function('ale_linters#markdown#marksman#GetCommand'),
33+
\ 'project_root': function('ale_linters#markdown#marksman#GetProjectRoot'),
34+
\ 'initialization_options': {},
35+
\})

doc/ale-markdown.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ g:ale_markdown_markdownlint_options *g:ale_markdown_markdownlint_options*
3434
This variable can be set to pass additional options to markdownlint.
3535

3636

37+
===============================================================================
38+
marksman *ale-markdown-marksman*
39+
40+
g:ale_markdown_marksman_executable *g:ale_markdown_marksman_executable*
41+
*b:ale_markdown_marksman_executable*
42+
Type: |String|
43+
Default: `'marksman'`
44+
45+
Override the invoked `marksman` binary.
46+
47+
3748
===============================================================================
3849
mdl *ale-markdown-mdl*
3950

doc/ale-supported-languages-and-tools.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ Notes:
364364
* `cspell`
365365
* `languagetool`!!
366366
* `markdownlint`!!
367+
* `marksman`
367368
* `mdl`
368369
* `pandoc`
369370
* `prettier`

doc/ale.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,6 +3123,7 @@ documented in additional help files.
31233123
cspell................................|ale-markdown-cspell|
31243124
dprint................................|ale-markdown-dprint|
31253125
markdownlint..........................|ale-markdown-markdownlint|
3126+
marksman..............................|ale-markdown-marksman|
31263127
mdl...................................|ale-markdown-mdl|
31273128
pandoc................................|ale-markdown-pandoc|
31283129
prettier..............................|ale-markdown-prettier|

supported-tools.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ formatting.
373373
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
374374
* [languagetool](https://languagetool.org/) :floppy_disk:
375375
* [markdownlint](https://github.com/DavidAnson/markdownlint) :floppy_disk:
376+
* [marksman](https://github.com/artempyanykh/marksman)
376377
* [mdl](https://github.com/mivok/markdownlint)
377378
* [pandoc](https://pandoc.org)
378379
* [prettier](https://github.com/prettier/prettier)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Before:
2+
call ale#assert#SetUpLinterTest('markdown', 'marksman')
3+
4+
After:
5+
call ale#assert#TearDownLinterTest()
6+
7+
Execute(The default command should be correct):
8+
AssertLinter 'marksman', ale#Escape('marksman') . ' server'

0 commit comments

Comments
 (0)