Skip to content

Commit

Permalink
Fix matching of "str", $(cmd), and interpolated variables within
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Ober committed Nov 6, 2019
1 parent 67f90b0 commit dda1af7
Showing 1 changed file with 32 additions and 61 deletions.
93 changes: 32 additions & 61 deletions syntax/abs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ if exists("b:current_syntax")
finish
endif

syn match absShebang "\%^#!.*" display
syn match absComment "#.*$"

syn match absEscSeq "\\\(\o\{1,3}\|[\"\\'\\?ntbrfva]\|u\x\{4}\|U\x\{8}\|x\x\x\)"
syn match absEscSeq "\\&[^;& \t]\+;"
syn match absFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
syn match absFormat display "%%" contained
syn region absDblQuotString start=+"+ end=+"[cwd]\=+ skip=+\\\\\|\\"+ contains=absFormat,absEscSeq,@Spell
syn region absQuotString start=+'+ end=+"[cwd]\=+ skip=+\\\\\|\\'+ contains=absFormat,@Spell

syn match absShebang display "\%^#!.*"

syn match absFormat display contained "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)"
syn match absFormat display contained "%%"
syn match absEscapeError display contained /\\./
syn match absEscape display contained /\\\([nrt\\'"]\|x\x\{2}\)/
syn match absIntplVar display contained /$\h*/
syn region absString1 start=+c\?'+ skip=+\\\\\|\\'+ end=+'+ oneline contains=@Spell
syn region absString2 start=+c\?"+ skip=+\\\\\|\\"+ end=+"+ oneline contains=absEscape,absEscapeUnicode,absEscapeError,absIntplVar,absFormat,@Spell
syn region absBacktick start=+c\?`+ skip=+\\\\\|\\`+ end=+`+ oneline contains=@Spell
syn region absShellCmd start=+c\?$(+ skip=+\\\\\|\\(+ end=+)+ oneline contains=absEscape,absEscapeUnicode,absEscapeError,absIntplVar,@Spell

syn keyword absFunction f echo stdin exit rand env eval arg type cd pwd flag sleep require source
syn keyword absFunction len fmt number is_number int round ceil floor split lines json contains
Expand All @@ -28,42 +30,7 @@ syn keyword absConstant true false null
syn keyword absConditional if else
syn keyword absRepeat for while in return break continue

syn region absShellCmd start="`" skip="\\`" end="`"

syn keyword absOperator "=="
syn keyword absOperator "!="
syn keyword absOperator "+"
syn keyword absOperator "+="
syn keyword absOperator "-"
syn keyword absOperator "-="
syn keyword absOperator "*"
syn keyword absOperator "*="
syn keyword absOperator "/"
syn keyword absOperator "/="
syn keyword absOperator "in"
syn keyword absOperator "**"
syn keyword absOperator "**="
syn keyword absOperator "%"
syn keyword absOperator "%="
syn keyword absOperator ">"
syn keyword absOperator ">="
syn keyword absOperator "<"
syn keyword absOperator "<="
syn keyword absOperator "<=>"
syn keyword absOperator "&&"
syn keyword absOperator "||"
syn keyword absOperator ".."
syn keyword absOperator "!"
syn keyword absOperator "!!"
syn keyword absOperator "~"
syn keyword absOperator "&"
syn keyword absOperator "|"
syn keyword absOperator "^"
syn keyword absOperator ">>"
syn keyword absOperator "<<"
syn keyword absOperator "`"

syn keyword absStructure "[" "]" "{" "}" "," "$" "(" ")" '"' "'"
syn keyword absStructure "[" "]" "{" "}" "," "$" "(" ")"

syn match absNumber "<\d+>"
syn match absNumber "<\d+\.\d+>"
Expand All @@ -72,21 +39,25 @@ syn match absNumber "<0x\x+([Pp]-?)?\x+>"
syn match absNumber "<0b[01]+>"
syn match absNumber "<0o\o+>"


let b:current_syntax = "abs"

hi def link absShebang PreProc
hi def link absComment Comment
hi def link absFunction Function
hi def link absType Type
hi def link absConstant Constant
hi def link absConditional Conditional
hi def link absRepeat Repeat
hi def link absShellCmd String
hi def link absOperator Operator
hi def link absStructure Structure
hi def link absNumber Number
hi def link absQuotString String
hi def link absDblQuotString String
hi def link absEscSeq SpecialChar
hi def link absFormat SpecialChar
hi def link absShebang PreProc
hi def link absComment Comment
hi def link absFunction Function
hi def link absType Type
hi def link absConstant Constant
hi def link absConditional Conditional
hi def link absRepeat Repeat

hi def link absStructure Structure
hi def link absNumber Number

hi def link absEscSeq SpecialChar
hi def link absFormat SpecialChar
hi def link absIntplVar SpecialChar
hi def link absEscape SpecialChar

hi def link absString1 String
hi def link absString2 String
hi def link absBacktick String
hi def link absShellCmd String

0 comments on commit dda1af7

Please sign in to comment.