runtime(compiler): add tombi compiler to lint TOML files
Commit:
https://github.com/vim/vim/commit/d659fafccd945e2ab9596be5060b65dbd0b419a8
Author: Konfekt <[email protected]>
Date: Tue Oct 28 20:42:17 2025 +0000
runtime(compiler): add tombi compiler to lint TOML files
closes: https://github.com/vim/vim/issues/18590
Signed-off-by: Konfekt <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/compiler/tombi.vim b/runtime/compiler/tombi.vim
new file mode 100644
index 000000000..e79a1368c
--- /dev/null
+++ b/runtime/compiler/tombi.vim
@@ -0,0 +1,69 @@
+" Vim compiler file
+" Language: TOML
+" Maintainer: Konfekt
+" Last Change: 2025 Oct 28
+
+if exists("current_compiler") | finish | endif
+let current_compiler = "tombi"
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+if !executable('tombi')
+ echoerr "tombi compiler: 'tombi' executable not found in PATH"
+ let &cpo = s:cpo_save
+ unlet s:cpo_save
+ finish
+endif
+
+" NO_COLOR support requires tombi 0.6.40 or later
+if !exists('s:tombi_nocolor')
+ " Expect output like: 'tombi 0.6.40' or '0.6.40'
+ let s:out = trim(system('tombi --version'))
+ let s:tombi_ver = matchstr(s:out, ' \s\d+\.\d+\.\d+$')
+
+ function s:VersionGE(ver, req) abort
+ " Compare semantic versions a.b.c 竕・ x.y.z
+ let l:pa = map(split(a:ver), '\.'), 'str2nr(v:val)')
+ let l:pb = map(split(a:req, '\.'), 'str2nr(v:val)')
+ while len(l:pa) < 3 | call add(l:pa, 0) | endwhile
+ while len(l:pb) < 3 | call add(l:pb, 0) | endwhile
+ for i in range(0, 2)
+ if l:pa[i] > l:pb[i] | return 1
+ elseif l:pa[i] < l:pb[i] | return 0
+ endif
+ endfor
+ return 1
+ endfunction
+ let s:tombi_nocolor = s:VersionGE(s:tombi_ver, '0.6.40')
+ delfunction s:VersionGE
+endif
+
+if s:tombi_nocolor
+ if has('win32')
+ if &shell =~# ' <%(cmd|cmd)>'
+ CompilerSet makeprg=set\ NO_COLOR=1\ &&\ tombi\ lint
+ elseif &shell =~# ' <%(powershell|pwsh)>'
+ CompilerSet makeprg=$env:NO_COLOR="1";\ tombi\ lint
+ else
+ echoerr "tombi compiler: Unsupported shell for Windows"
+ endif
+ else " if has('unix')
+ CompilerSet makeprg=env\ NO_COLOR=1\ tombi\ lint
+ endif
+else
+ " Older tombi: strip ANSI color codes with sed.
+ if executable('sed')
+ CompilerSet makeprg=tombi\ lint\ $*\ \|\ sed\ -E\
\"s/\x1B(\[[0-9;]*[JKmsu]\|\(B)//g\"
+ else
+ echoerr "tombi compiler: tombi version < 0.6.40 requires 'sed' to strip
ANSI color codes"
+ endif
+endif
+
+CompilerSet errorformat=%E%*\sError:\ %m,%Z%*\sat\ %f:%l:%c
+CompilerSet errorformat+=%W%*\sWarning:\ %m,%Z%*\sat\ %f:%l:%c
+CompilerSet errorformat+=%-G1\ file\ failed\ to\ be\ linted
+CompilerSet errorformat+=%-G1\ file\ linted\ successfully
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 9a9788c2f..a3226020a 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -1,4 +1,4 @@
-*quickfix.txt* For Vim version 9.1. Last change: 2025 Oct 12
+*quickfix.txt* For Vim version 9.1. Last change: 2025 Oct 28
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1724,6 +1724,16 @@ shells and OSes and also does not allow to use other
available TeX options,
if any. If your TeX doesn't support "-interaction=nonstopmode", please
report it with different means to express
onstopmode from the command line.
+TOMBI *quickfix-toml* *compiler-tombi*
+
+The tombi compiler plugin does not compile.
+
+It runs "tombi lint" and parses diagnostics into the quickfix list.
+
+Color codes are stripped from the linter output to keep |errorformat|
+parsing reliable. This may require a working "sed" for old versions of the
+tombi linter.
+
TSC COMPILER *compiler-tsc*
The executable and compiler options can be added to 'makeprg' by setting the
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 944017088..6757a097a 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -6762,6 +6762,7 @@ compiler-select quickfix.txt /*compiler-select*
compiler-spotbugs quickfix.txt /*compiler-spotbugs*
compiler-tex quickfix.txt /*compiler-tex*
compiler-tsc quickfix.txt /*compiler-tsc*
+compiler-tombi quickfix.txt /*compiler-tombi*
compiler-typst quickfix.txt /*compiler-typst*
compiler-vaxada ft_ada.txt /*compiler-vaxada*
compl-current insert.txt /*compl-current*
@@ -9946,6 +9947,7 @@ quickfix-perl quickfix.txt /*quickfix-perl*
quickfix-size quickfix.txt /*quickfix-size*
quickfix-stack quickfix.txt /*quickfix-stack*
quickfix-title quickfix.txt /*quickfix-title*
+quickfix-toml quickfix.txt /*quickfix-toml*
quickfix-valid quickfix.txt /*quickfix-valid*
quickfix-window quickfix.txt /*quickfix-window*
quickfix-window-ID quickfix.txt /*quickfix-window-ID*
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1vDqZ2-008OhS-Ne%40256bit.org.