File: tombi.vim

package info (click to toggle)
vim 2%3A9.1.2103-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 93,456 kB
  • sloc: ansic: 433,730; cpp: 6,399; makefile: 4,597; sh: 2,397; java: 2,312; xml: 2,099; python: 1,595; perl: 1,419; awk: 730; lisp: 501; cs: 458; objc: 369; sed: 8; csh: 6; haskell: 1
file content (69 lines) | stat: -rw-r--r-- 2,122 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
" Vim compiler file
" Language:    TOML
" Maintainer:  Konfekt
" Last Change: 2025 Oct 29

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, '\v\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 =~# '\v<%(cmd|cmd)>'
      CompilerSet makeprg=set\ NO_COLOR=1\ &&\ tombi\ lint
    elseif &shell =~# '\v<%(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