robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
fe5d1279a4
master
1" Maintainer: Maxim Kim <habamax@gmail.com> 2" Converted from vim9script 3" Last Update: 2024-06-18 4 5if exists ( "b:current_syntax" ) 6finish 7endif 8 9let s: delimiter = get ( b:, "csv_delimiter" , "," ) 10 11" generate bunch of following syntaxes: 12" syntax match csvCol8 /.\{-}\(,\|$\)/ nextgroup=escCsvCol0,csvCol0 13" syntax region escCsvCol8 start=/ *"\([^"]*""\)*[^"]*/ end=/" *\(,\|$\)/ nextgroup=escCsvCol0,csvCol0 14for s: col in range ( 8 , 0 , -1 ) 15let s: ncol = ( s: col == 8 ? 0 : s: col + 1 ) 16exe $ 'syntax match csvCol{s: col }' .. ' /.\{-}\(' ..s: delimiter .. '\|$\)/ nextgroup=escCsvCol' .. s: ncol .. ',csvCol' .. s: ncol 17exe $ 'syntax region escCsvCol{s: col }' .. ' start=/ *"\([^"]*""\)*[^"]*/ end=/" *\(' ..s: delimiter .. '\|$\)/ nextgroup=escCsvCol' .. s: ncol .. ',csvCol' .. s: ncol 18endfor 19 20hi def link csvCol1 Statement 21hi def link csvCol2 Constant 22hi def link csvCol3 Type 23hi def link csvCol4 PreProc 24hi def link csvCol5 Identifier 25hi def link csvCol6 Special 26hi def link csvCol7 String 27hi def link csvCol8 Comment 28 29hi def link escCsvCol1 csvCol1 30hi def link escCsvCol2 csvCol2 31hi def link escCsvCol3 csvCol3 32hi def link escCsvCol4 csvCol4 33hi def link escCsvCol5 csvCol5 34hi def link escCsvCol6 csvCol6 35hi def link escCsvCol7 csvCol7 36hi def link escCsvCol8 csvCol8 37 38let b: current_syntax = "csv"