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

Commit d659faf

Browse files
Konfektchrisbra
authored andcommitted
runtime(compiler): add tombi compiler to lint TOML files
closes: #18590 Signed-off-by: Konfekt <Konfekt@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 433d2ab commit d659faf

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

‎runtime/compiler/tombi.vim‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
" Vim compiler file
2+
" Language: TOML
3+
" Maintainer: Konfekt
4+
" Last Change: 2025 Oct 28
5+
6+
if exists("current_compiler") | finish | endif
7+
let current_compiler = "tombi"
8+
9+
let s:cpo_save = &cpo
10+
set cpo&vim
11+
12+
if !executable('tombi')
13+
echoerr "tombi compiler: 'tombi' executable not found in PATH"
14+
let &cpo = s:cpo_save
15+
unlet s:cpo_save
16+
finish
17+
endif
18+
19+
" NO_COLOR support requires tombi 0.6.40 or later
20+
if !exists('s:tombi_nocolor')
21+
" Expect output like: 'tombi 0.6.40' or '0.6.40'
22+
let s:out = trim(system('tombi --version'))
23+
let s:tombi_ver = matchstr(s:out, '\v\s\d+\.\d+\.\d+$')
24+
25+
function s:VersionGE(ver, req) abort
26+
" Compare semantic versions a.b.c ≥ x.y.z
27+
let l:pa = map(split(a:ver), '\.'), 'str2nr(v:val)')
28+
let l:pb = map(split(a:req, '\.'), 'str2nr(v:val)')
29+
while len(l:pa) < 3 | call add(l:pa, 0) | endwhile
30+
while len(l:pb) < 3 | call add(l:pb, 0) | endwhile
31+
for i in range(0, 2)
32+
if l:pa[i] > l:pb[i] | return 1
33+
elseif l:pa[i] < l:pb[i] | return 0
34+
endif
35+
endfor
36+
return 1
37+
endfunction
38+
let s:tombi_nocolor = s:VersionGE(s:tombi_ver, '0.6.40')
39+
delfunction s:VersionGE
40+
endif
41+
42+
if s:tombi_nocolor
43+
if has('win32')
44+
if &shell =~# '\v<%(cmd|cmd)>'
45+
CompilerSet makeprg=set\ NO_COLOR=1\ &&\ tombi\ lint
46+
elseif &shell =~# '\v<%(powershell|pwsh)>'
47+
CompilerSet makeprg=$env:NO_COLOR="1";\ tombi\ lint
48+
else
49+
echoerr "tombi compiler: Unsupported shell for Windows"
50+
endif
51+
else " if has('unix')
52+
CompilerSet makeprg=env\ NO_COLOR=1\ tombi\ lint
53+
endif
54+
else
55+
" Older tombi: strip ANSI color codes with sed.
56+
if executable('sed')
57+
CompilerSet makeprg=tombi\ lint\ $*\ \|\ sed\ -E\ \"s/\\x1B(\\[[0-9;]*[JKmsu]\|\\(B)//g\"
58+
else
59+
echoerr "tombi compiler: tombi version < 0.6.40 requires 'sed' to strip ANSI color codes"
60+
endif
61+
endif
62+
63+
CompilerSet errorformat=%E%*\\sError:\ %m,%Z%*\\sat\ %f:%l:%c
64+
CompilerSet errorformat+=%W%*\\sWarning:\ %m,%Z%*\\sat\ %f:%l:%c
65+
CompilerSet errorformat+=%-G1\ file\ failed\ to\ be\ linted
66+
CompilerSet errorformat+=%-G1\ file\ linted\ successfully
67+
68+
let &cpo = s:cpo_save
69+
unlet s:cpo_save

‎runtime/doc/quickfix.txt‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*quickfix.txt* For Vim version 9.1. Last change: 2025 Oct 12
1+
*quickfix.txt* For Vim version 9.1. Last change: 2025 Oct 28
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1724,6 +1724,16 @@ shells and OSes and also does not allow to use other available TeX options,
17241724
if any. If your TeX doesn't support "-interaction=nonstopmode", please
17251725
report it with different means to express \nonstopmode from the command line.
17261726

1727+
TOMBI *quickfix-toml* *compiler-tombi*
1728+
1729+
The tombi compiler plugin does not compile.
1730+
1731+
It runs "tombi lint" and parses diagnostics into the quickfix list.
1732+
1733+
Color codes are stripped from the linter output to keep |errorformat|
1734+
parsing reliable. This may require a working "sed" for old versions of the
1735+
tombi linter.
1736+
17271737
TSC COMPILER *compiler-tsc*
17281738

17291739
The executable and compiler options can be added to 'makeprg' by setting the

‎runtime/doc/tags‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6762,6 +6762,7 @@ compiler-select quickfix.txt /*compiler-select*
67626762
compiler-spotbugs quickfix.txt /*compiler-spotbugs*
67636763
compiler-tex quickfix.txt /*compiler-tex*
67646764
compiler-tsc quickfix.txt /*compiler-tsc*
6765+
compiler-tombi quickfix.txt /*compiler-tombi*
67656766
compiler-typst quickfix.txt /*compiler-typst*
67666767
compiler-vaxada ft_ada.txt /*compiler-vaxada*
67676768
compl-current insert.txt /*compl-current*
@@ -9946,6 +9947,7 @@ quickfix-perl quickfix.txt /*quickfix-perl*
99469947
quickfix-size quickfix.txt /*quickfix-size*
99479948
quickfix-stack quickfix.txt /*quickfix-stack*
99489949
quickfix-title quickfix.txt /*quickfix-title*
9950+
quickfix-toml quickfix.txt /*quickfix-toml*
99499951
quickfix-valid quickfix.txt /*quickfix-valid*
99509952
quickfix-window quickfix.txt /*quickfix-window*
99519953
quickfix-window-ID quickfix.txt /*quickfix-window-ID*

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /