Ticket #3471: 3471-Improve-Lua-syntax-highlighting.patch

File 3471-Improve-Lua-syntax-highlighting.patch, 4.6 KB (added by mooffie, 9 years ago)
  • misc/syntax/Syntax.in

    From c548e690a6bde99d905d80c9960ef3209f664ac7 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Mon, 25 May 2015 17:51:23 +0300
    Subject: [PATCH] Improve Lua syntax highlighting.
    
    * Support for "long" strings/comments.
    * Fixed Syntax.in to recognize both "#!/path/to/lua"
      and "#!/usr/bin/env lua".
    * Fixed langauge name (it's "Lua", not "LUA").
    ---
     misc/syntax/Syntax.in  |  2 +-
     misc/syntax/lua.syntax | 63 ++++++++++++++++++++++++++++++++++++++++++++------
     2 files changed, 57 insertions(+), 8 deletions(-)
    
    diff --git a/misc/syntax/Syntax.in b/misc/syntax/Syntax.in
    index 849afe6..014d08a 100644
    a b include povray.syntax 
    178178file .\*\\.(ebuild|eclass)$ Gentoo\sEbuild 
    179179include ebuild.syntax 
    180180 
    181 file ..\*\\.([lL][uU][aA])$ LUA\sProgram ^#!.*/lua 
     181file ..\*\\.([lL][uU][aA])$ Lua\sProgram ^#!.\*[\s/]lua 
    182182include lua.syntax 
    183183 
    184184file ..\*\\.([iI][dD][lL])$ CORBA\sIDL 
  • misc/syntax/lua.syntax

    diff --git a/misc/syntax/lua.syntax b/misc/syntax/lua.syntax
    index 97f8417..0d1b816 100644
    a b  
    11# 
    2 # LUA Scripting Language syntax highlight 
    3 # // Mike Gorchak <lestat@i.com.ua> 
     2# Lua syntax highlighting 
    43# 
     4# History: 
     5# 
     6# - 2015: Support for long strings and long comments. 
     7# - 2011: String-literal fixes. 
     8# - 2005: Started by Mike Gorchak <lestat@i.com.ua> 
    59 
    610context default lightgray 
    711 
    context default lightgray 
    2832    keyword whole until white 
    2933    keyword whole while white 
    3034 
    31 # Comments 
     35# Comment and string delimiters 
    3236    keyword -- brown 
    33     keyword ]] brown 
     37    keyword ]\[=\]] brown 
     38    # The following colorizes the start delimiter of "long" strings. 
     39    # The start delimiter of "long" comments isn't affected by the following 
     40    # directive but gets its color from the "--" above (gods know why). 
     41    keyword [\[=\][ brown 
    3442 
    3543# Operators 
    3644    keyword ( white 
    context default lightgray 
    6068 
    6169 
    6270# Library Functions 
     71 
    6372    # basiclib 
    6473    keyword whole error yellow 
    6574    keyword whole getmetatable yellow 
    context default lightgray 
    7483    keyword whole tostring yellow 
    7584    keyword whole type yellow 
    7685    keyword whole assert yellow 
    77     keyword whole unpack yellow 
     86    #keyword whole unpack yellow    # modern code should use table.unpack() 
    7887    keyword whole rawequal yellow 
    7988    keyword whole rawget yellow 
    8089    keyword whole rawset yellow 
    context default lightgray 
    115124    keyword whole table.sort yellow 
    116125    keyword whole table.insert yellow 
    117126    keyword whole table.remove yellow 
     127    keyword whole table.unpack yellow 
    118128 
    119129    # mathlib 
    120130    keyword whole math.abs yellow 
    context default lightgray 
    194204    keyword whole _VERSION brightmagenta 
    195205    keyword whole _G brightmagenta 
    196206 
     207# 
     208# Long comments 
     209# 
    197210 
    198 # Comments 
    199211context exclusive --[[ ]] brown 
     212    # hightlights ldoc tags: "@todo", "@param", "@function" etc. 
     213    keyword @\[abcdefghijklmnopqrstuvwxyz\] brightred base 
     214    spellcheck 
     215context exclusive --[=[ ]=] brown 
     216    keyword @\[abcdefghijklmnopqrstuvwxyz\] brightred base 
     217    spellcheck 
     218context exclusive --[==[ ]==] brown 
     219    keyword @\[abcdefghijklmnopqrstuvwxyz\] brightred base 
     220    spellcheck 
     221context exclusive --[===[ ]===] brown 
     222    keyword @\[abcdefghijklmnopqrstuvwxyz\] brightred base 
     223    spellcheck 
     224# 4 equals and up (the number of ='s doesn't have to match, but that's the best we can do): 
     225context exclusive --[====\[=\][ ]====\[=\]] brown 
     226    keyword @\[abcdefghijklmnopqrstuvwxyz\] brightred base 
     227    spellcheck 
     228 
     229# 
     230# Long strings 
     231# 
     232 
     233context exclusive [[ ]] brightmagenta 
     234    spellcheck 
     235context exclusive [=[ ]=] brightmagenta 
    200236    spellcheck 
     237context exclusive [==[ ]==] brightmagenta 
     238    spellcheck 
     239context exclusive [===[ ]===] brightmagenta 
     240    spellcheck 
     241# 4 equals and up (the number of ='s doesn't have to match, but that's the best we can do): 
     242context exclusive [====\[=\][ ]====\[=\]] brightmagenta 
     243    spellcheck 
     244 
    201245 
     246# Simple comments 
    202247context exclusive -- \n brown 
     248    keyword @\[abcdefghijklmnopqrstuvwxyz\] brightred base 
    203249    spellcheck 
    204250 
    205 context linestart # \n brown 
     251# Shebang line 
     252context linestart #! \n brown 
    206253 
    207254# Strings 
    208255context " " green 
    context " " green 
    211258    keyword %d brightgreen 
    212259    keyword %l brightgreen 
    213260    keyword %p brightgreen 
     261    keyword %q brightgreen 
    214262    keyword %s brightgreen 
    215263    keyword %u brightgreen 
    216264    keyword %w brightgreen 
    context ' ' green 
    231279    keyword %d brightgreen 
    232280    keyword %l brightgreen 
    233281    keyword %p brightgreen 
     282    keyword %q brightgreen 
    234283    keyword %s brightgreen 
    235284    keyword %u brightgreen 
    236285    keyword %w brightgreen