Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd6f1a47

Browse files
authored
tombi: support its LSP (#5022)
* tombi: support its LSP* tombi: support linting and formatting
1 parent487d915 commitd6f1a47

File tree

15 files changed

+232
-0
lines changed

15 files changed

+232
-0
lines changed

‎ale_linters/toml/tombi.vim‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
" Author: Ben Boeckel <github@me.benboeckel.net>
2+
" Description: TOML Formatter / Linter / Language Server
3+
4+
callale#Set('toml_tombi_executable','tombi')
5+
callale#Set('toml_tombi_lsp_options','')
6+
7+
function!ale_linters#toml#tombi#GetCommand(buffer)abort
8+
letl:options=ale#Var(a:buffer,'toml_tombi_lsp_options')
9+
10+
return'%e lsp'
11+
\ . (empty(l:options) ?'' :'' .l:options)
12+
endfunction
13+
14+
function!ale_linters#toml#tombi#GetProjectRoot(buffer)abort
15+
" Try to find nearest tombi.toml
16+
letl:tombiconfig_file=ale#path#FindNearestFile(a:buffer,'tombi.toml')
17+
18+
if!empty(l:tombiconfig_file)
19+
returnfnamemodify(l:tombiconfig_file .'/',':p:h:h')
20+
endif
21+
22+
" Try to find nearest pyproject.toml
23+
letl:pyproject_file=ale#path#FindNearestFile(a:buffer,'pyproject.toml')
24+
25+
if!empty(l:pyproject_file)
26+
returnfnamemodify(l:pyproject_file .'/',':p:h:h')
27+
endif
28+
29+
" Try to find nearest `git` directory
30+
letl:gitdir=ale#path#FindNearestFile(a:buffer,'.git')
31+
32+
if!empty(l:gitdir)
33+
returnfnamemodify(l:gitdir .'/',':p:h:h')
34+
endif
35+
36+
return''
37+
endfunction
38+
39+
callale#linter#Define('toml', {
40+
\'name':'tombi',
41+
\'lsp':'stdio',
42+
\'executable': {b->ale#Var(b,'toml_tombi_executable')},
43+
\'command':function('ale_linters#toml#tombi#GetCommand'),
44+
\'project_root':function('ale_linters#toml#tombi#GetProjectRoot'),
45+
\})

‎autoload/ale/fix/registry.vim‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,16 @@ let s:default_registry = {
732732
\'suggested_filetypes': ['roc'],
733733
\'description':'Annotates all top-level definitions in Roc files.',
734734
\ },
735+
\'tombi_format': {
736+
\'function':'ale#fixers#tombi_format#Fix',
737+
\'suggested_filetypes': ['toml'],
738+
\'description':'Formats TOML files',
739+
\ },
740+
\'tombi_lint': {
741+
\'function':'ale#fixers#tombi_lint#Fix',
742+
\'suggested_filetypes': ['toml'],
743+
\'description':'Lints TOML files',
744+
\ },
735745
\}
736746

737747
" Reset the function registry to the default entries.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
" Author: Ben Boeckel <github@me.benboeckel.net>
2+
" Description: Integration of tombi formatting with ALE.
3+
4+
callale#Set('toml_tombi_executable','tombi')
5+
callale#Set('toml_tombi_format_options','')
6+
7+
function!ale#fixers#tombi_format#Fix(buffer)abort
8+
letl:executable=ale#Var(a:buffer,'toml_tombi_executable')
9+
letl:options=ale#Var(a:buffer,'toml_tombi_format_options')
10+
11+
return {
12+
\'command':ale#Escape(l:executable)
13+
\ .' format'
14+
\ . (empty(l:options) ?'' :'' .l:options),
15+
\}
16+
endfunction

‎autoload/ale/fixers/tombi_lint.vim‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
" Author: Ben Boeckel <github@me.benboeckel.net>
2+
" Description: Integration of tombi linting with ALE.
3+
4+
callale#Set('toml_tombi_executable','tombi')
5+
callale#Set('toml_tombi_lint_options','')
6+
7+
function!ale#fixers#tombi_lint#Fix(buffer)abort
8+
letl:executable=ale#Var(a:buffer,'toml_tombi_executable')
9+
letl:options=ale#Var(a:buffer,'toml_tombi_lint_options')
10+
11+
return {
12+
\'command':ale#Escape(l:executable)
13+
\ .' lint'
14+
\ . (empty(l:options) ?'' :'' .l:options),
15+
\}
16+
endfunction

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ Notes:
698698
*`thriftcheck`
699699
* TOML
700700
*`dprint`
701+
*`tombi`
701702
* TypeScript
702703
*`biome`
703704
*`cspell`

‎doc/ale-toml.txt‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,58 @@ dprint *ale-toml-dprint*
88
See|ale-dprint-options| andhttps://dprint.dev/plugins/toml
99

1010

11+
===============================================================================
12+
tombi*ale-toml-tombi*
13+
14+
`'tombi'` is a TOML formatter, linter, and language server.
15+
16+
*ale-options.toml_tombi_executable*
17+
*g:ale_toml_tombi_executable*
18+
*b:ale_toml_tombi_executable*
19+
toml_tombi_executable
20+
g:ale_toml_tombi_executable
21+
Type:|String|
22+
Default:`'tombi'`
23+
24+
This variable can be modified to change the executable path for
25+
`tombi`.
26+
27+
28+
*ale-options.toml_tombi_lsp_options*
29+
*g:ale_toml_tombi_lsp_options*
30+
*b:ale_toml_tombi_lsp_options*
31+
toml_tombi_lsp_options
32+
g:ale_toml_tombi_lsp_options
33+
Type:|String|
34+
Default:`''`
35+
36+
This variable can be modified to provide options when using`tombi` as an
37+
LSP server.
38+
39+
40+
*ale-options.toml_tombi_format_options*
41+
*g:ale_toml_tombi_format_options*
42+
*b:ale_toml_tombi_format_options*
43+
toml_tombi_format_options
44+
g:ale_toml_tombi_format_options
45+
Type:|String|
46+
Default:`''`
47+
48+
This variable can be modified to provide options when using`tombi` as a
49+
formatter.
50+
51+
52+
*ale-options.toml_tombi_lint_options*
53+
*g:ale_toml_tombi_lint_options*
54+
*b:ale_toml_tombi_lint_options*
55+
toml_tombi_lint_options
56+
g:ale_toml_tombi_lint_options
57+
Type:|String|
58+
Default:`''`
59+
60+
This variable can be modified to provide options when using`tombi` as a
61+
linter.
62+
63+
1164
===============================================================================
1265
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

‎doc/ale.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,6 +3928,7 @@ documented in additional help files.
39283928
thriftcheck...........................|ale-thrift-thriftcheck|
39293929
toml....................................|ale-toml-options|
39303930
dprint................................|ale-toml-dprint|
3931+
tombi.................................|ale-toml-tombi|
39313932
typescript..............................|ale-typescript-options|
39323933
biome.................................|ale-typescript-biome|
39333934
cspell................................|ale-typescript-cspell|

‎supported-tools.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ formatting.
707707
*[thriftcheck](https://github.com/pinterest/thriftcheck)
708708
* TOML
709709
*[dprint](https://dprint.dev)
710+
*[tombi](https://tombi-toml.github.io/tombi/)
710711
* TypeScript
711712
*[biome](https://biomejs.dev/)
712713
*[cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Before:
2+
Save g:ale_toml_tombi_executable
3+
Save g:ale_toml_tombi_format_options
4+
5+
" Use an invalid global executable, so we don't match it.
6+
let g:ale_toml_tombi_executable = 'xxxinvalid'
7+
let g:ale_toml_tombi_format_options = ''
8+
9+
call ale#test#SetDirectory('/testplugin/test/fixers')
10+
11+
After:
12+
Restore
13+
14+
call ale#test#RestoreDirectory()
15+
16+
Execute(The tombi format callback should return the correct default values):
17+
18+
AssertEqual
19+
\ {
20+
\ 'command': ale#Escape('xxxinvalid') . ' format',
21+
\ },
22+
\ ale#fixers#tombi_format#Fix(bufnr(''))
23+
24+
Execute(The tombi format callback should include custom options):
25+
let g:ale_toml_tombi_format_options = "--offline"
26+
27+
AssertEqual
28+
\ {
29+
\ 'command': ale#Escape('xxxinvalid')
30+
\ . ' format'
31+
\ . ' ' . g:ale_toml_tombi_format_options
32+
\ },
33+
\ ale#fixers#tombi_format#Fix(bufnr(''))
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Before:
2+
Save g:ale_toml_tombi_executable
3+
Save g:ale_toml_tombi_lint_options
4+
5+
" Use an invalid global executable, so we don't match it.
6+
let g:ale_toml_tombi_executable = 'xxxinvalid'
7+
let g:ale_toml_tombi_lint_options = ''
8+
9+
call ale#test#SetDirectory('/testplugin/test/fixers')
10+
11+
After:
12+
Restore
13+
14+
call ale#test#RestoreDirectory()
15+
16+
Execute(The tombi lint callback should return the correct default values):
17+
18+
AssertEqual
19+
\ {
20+
\ 'command': ale#Escape('xxxinvalid') . ' lint',
21+
\ },
22+
\ ale#fixers#tombi_lint#Fix(bufnr(''))
23+
24+
Execute(The tombi lint callback should include custom options):
25+
let g:ale_toml_tombi_lint_options = "--offline"
26+
27+
AssertEqual
28+
\ {
29+
\ 'command': ale#Escape('xxxinvalid')
30+
\ . ' lint'
31+
\ . ' ' . g:ale_toml_tombi_lint_options
32+
\ },
33+
\ ale#fixers#tombi_lint#Fix(bufnr(''))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp