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