vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

tombi.vim (2122B)


      1 " Vim compiler file
      2 " Language:    TOML
      3 " Maintainer:  Konfekt
      4 " Last Change: 2025 Oct 29
      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