You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
20 KiB
174 lines
20 KiB
9 years ago
|
" Vim syntax file
|
||
|
" Language: hy
|
||
|
" License: Same as VIM
|
||
|
" Authors: Morten Linderud <mcfoxax@gmail.com>
|
||
|
" Alejandro Gómez <alejandro@dialelo.com>
|
||
|
" URL: http://github.com/hylang/vim-hy
|
||
|
"
|
||
|
" Modified version of the clojure syntax file: https://github.com/guns/vim-clojure-static/blob/master/syntax/clojure.vim
|
||
|
if exists("b:current_syntax")
|
||
|
finish
|
||
|
endif
|
||
|
|
||
|
|
||
|
" hy version 0.10.0
|
||
|
syntax keyword hyConstant null nil
|
||
|
syntax keyword hyBoolean false true
|
||
|
syntax keyword hySpecial macro-error defmacro-alias let if-python2 def setv fn lambda
|
||
|
syntax keyword hyException throw raise try except catch
|
||
|
syntax keyword hyCond cond if-not lisp-if lif when unless
|
||
|
syntax keyword hyRepeat loop for* while
|
||
|
syntax keyword hyDefine defmacro/g! defmain defn-alias defun-alias defmulti defnc defclass defmacro defreader defn defun
|
||
|
syntax keyword hyMacro for with car cdr -> ->> with-gensyms ap-if ap-each ap-each-while ap-map ap-map-when ap-filter ap-reject ap-dotimes ap-first ap-last ap-reduce defnc fnc fnr route-with-methods route post-route put-route delete-route profile/calls profile/cpu walk postwalk prewalk macroexpand-all
|
||
|
syntax keyword hyFunc curry --trampoline-- recursive-replace _numeric-check coll? cons cons? keyword? dec disassemble distinct drop empty? even? every? fake-source-positions flatten _flatten float? gensym calling-module-name first identity inc instance? integer integer? integer-char? iterable? iterate iterator? list* macroexpand macroexpand-1 neg? none? nil? numeric? nth odd? pos? remove rest repeatedly second some string string? take take-nth zero? list quote quasiquote unquote unquote-splicing eval do progn if break print continue assert global yield yield-from from import get . del slice assoc with-decorator with* , list-comp set-comp dict-comp genexpr apply not ~ require and or = != < <= > >= is in is-not not-in % / // ** << >> ^ & + * - += /= //= *= -= %= **= <<= >>= ^= &= HyExpression HyList dispatch-reader-macro eval-and-compile eval-when-compile HyCons HyInteger HyFloat HyComplex HySymbol HyString HyKeyword
|
||
|
" Not used at this moment
|
||
|
"syntax keyword hyVariable
|
||
|
|
||
|
|
||
|
" Keywords are symbols:
|
||
|
" static Pattern symbolPat = Pattern.compile("[:]?([\\D&&[^/]].*/)?([\\D&&[^/]][^/]*)");
|
||
|
" But they:
|
||
|
" * Must not end in a : or /
|
||
|
" * Must not have two adjacent colons except at the beginning
|
||
|
" * Must not contain any reader metacharacters except for ' and #
|
||
|
syntax match hyKeyword "\v<:{1,2}%([^ \n\r\t()\[\]{}";@^`~\\%/]+/)*[^ \n\r\t()\[\]{}";@^`~\\%/]+:@<!>"
|
||
|
|
||
|
syntax match hyStringEscape "\v\\%([\\btnfr"]|u\x{4}|[0-3]\o{2}|\o{1,2})" contained
|
||
|
|
||
|
syntax region hyString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=hyStringEscape
|
||
|
|
||
|
syntax match hyCharacter "\\."
|
||
|
syntax match hyCharacter "\\o\%([0-3]\o\{2\}\|\o\{1,2\}\)"
|
||
|
syntax match hyCharacter "\\u\x\{4\}"
|
||
|
syntax match hyCharacter "\\space"
|
||
|
syntax match hyCharacter "\\tab"
|
||
|
syntax match hyCharacter "\\newline"
|
||
|
syntax match hyCharacter "\\return"
|
||
|
syntax match hyCharacter "\\backspace"
|
||
|
syntax match hyCharacter "\\formfeed"
|
||
|
|
||
|
syntax match hySymbol "\v%([a-zA-Z!$&*_+=|<.>?-]|[^\x00-\x7F])+%(:?%([a-zA-Z0-9!#$%&*_+=|'<.>/?-]|[^\x00-\x7F]))*[#:]@<!"
|
||
|
|
||
|
let s:radix_chars = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||
|
for s:radix in range(2, 36)
|
||
|
execute 'syntax match hyNumber "\v\c<[-+]?' . s:radix . 'r[' . strpart(s:radix_chars, 0, s:radix) . ']+>"'
|
||
|
endfor
|
||
|
unlet! s:radix_chars s:radix
|
||
|
|
||
|
syntax match hyNumber "\v<[-+]?%(0\o*|0x\x+|[1-9]\d*)N?>"
|
||
|
syntax match hyNumber "\v<[-+]?%(0|[1-9]\d*|%(0|[1-9]\d*)\.\d*)%(M|[eE][-+]?\d+)?>"
|
||
|
syntax match hyNumber "\v<[-+]?%(0|[1-9]\d*)/%(0|[1-9]\d*)>"
|
||
|
|
||
|
syntax match hyVarArg "&"
|
||
|
|
||
|
syntax match hyQuote "'"
|
||
|
syntax match hyQuote "`"
|
||
|
syntax match hyUnquote "\~"
|
||
|
syntax match hyUnquote "\~@"
|
||
|
syntax match hyMeta "\^"
|
||
|
syntax match hyDeref "@"
|
||
|
syntax match hyDispatch "\v#[\^'=<_]?"
|
||
|
|
||
|
" hy permits no more than 20 params.
|
||
|
syntax match hyAnonArg "%\(20\|1\d\|[1-9]\|&\)\?"
|
||
|
|
||
|
syntax match hyRegexpEscape "\v\\%(\\|[tnrfae]|c\u|0[0-3]?\o{1,2}|x%(\x{2}|\{\x{1,6}\})|u\x{4})" contained display
|
||
|
syntax region hyRegexpQuoted start=/\v\<@!\\Q/ms=e+1 skip=/\v\\\\|\\"/ end=/\\E/me=s-1 end=/"/me=s-1 contained
|
||
|
syntax region hyRegexpQuote start=/\v\<@!\\Q/ skip=/\v\\\\|\\"/ end=/\\E/ end=/"/me=s-1 contains=hyRegexpQuoted keepend contained
|
||
|
syntax cluster hyRegexpEscapes contains=hyRegexpEscape,hyRegexpQuote
|
||
|
|
||
|
syntax match hyRegexpPosixCharClass "\v\\[pP]\{%(ASCII|Alnum|Alpha|Blank|Cntrl|Digit|Graph|Lower|Print|Punct|Space|Upper|XDigit)\}" contained display
|
||
|
syntax match hyRegexpJavaCharClass "\v\\[pP]\{java%(Alphabetic|Defined|Digit|ISOControl|IdentifierIgnorable|Ideographic|JavaIdentifierPart|JavaIdentifierStart|Letter|LetterOrDigit|LowerCase|Mirrored|SpaceChar|TitleCase|UnicodeIdentifierPart|UnicodeIdentifierStart|UpperCase|Whitespace)\}" contained display
|
||
|
syntax match hyRegexpUnicodeCharClass "\v\\[pP]\{\cIs%(alnum|alphabetic|assigned|blank|control|digit|graph|hex_digit|hexdigit|ideographic|letter|lowercase|noncharacter_code_point|noncharactercodepoint|print|punctuation|titlecase|uppercase|white_space|whitespace|word)\}" contained display
|
||
|
syntax match hyRegexpUnicodeCharClass "\v\\[pP]%(C|L|M|N|P|S|Z)" contained display
|
||
|
syntax match hyRegexpUnicodeCharClass "\v\\[pP]\{%(Is|gc\=|general_category\=)?%(C[cfnos]|L[CDlmotu]|M[cen]|N[dlo]|P[cdefios]|S[ckmo]|Z[lps])\}" contained display
|
||
|
syntax match hyRegexpUnicodeCharClass "\v\\[pP]\{\c%(Is|sc\=|script\=)%(arab|arabic|armenian|armi|armn|avestan|avst|bali|balinese|bamu|bamum|batak|batk|beng|bengali|bopo|bopomofo|brah|brahmi|brai|braille|bugi|buginese|buhd|buhid|canadian_aboriginal|cans|cari|carian|cham|cher|cherokee|common|copt|coptic|cprt|cuneiform|cypriot|cyrillic|cyrl|deseret|deva|devanagari|dsrt|egyp|egyptian_hieroglyphs|ethi|ethiopic|geor|georgian|glag|glagolitic|goth|gothic|greek|grek|gujarati|gujr|gurmukhi|guru|han|hang|hangul|hani|hano|hanunoo|hebr|hebrew|hira|hiragana|imperial_aramaic|inherited|inscriptional_pahlavi|inscriptional_parthian|ital|java|javanese|kaithi|kali|kana|kannada|katakana|kayah_li|khar|kharoshthi|khmer|khmr|knda|kthi|lana|lao|laoo|latin|latn|lepc|lepcha|limb|limbu|linb|linear_b|lisu|lyci|lycian|lydi|lydian|malayalam|mand|mandaic|meetei_mayek|mlym|mong|mongolian|mtei|myanmar|mymr|new_tai_lue|nko|nkoo|ogam|ogham|ol_chiki|olck|old_italic|old_persian|old_south_arabian|old_turkic|oriya|orkh|orya|osma|osmanya|phag|phags_pa|phli|phnx|phoenician|prti|rejang|rjng|runic|runr|samaritan|samr|sarb|saur|saurashtra|shavian|shaw|sinh|sinhala|sund|sundanese|sylo|syloti_nagri|syrc|syriac|tagalog|tagb|tagbanwa|tai_le|tai_tham|tai_viet|tale|talu|tamil|taml|tavt|telu|telugu|tfng|tglg|thaa|thaana|thai|tibetan|tibt|tifinagh|ugar|ugaritic|unknown|vai|vaii|xpeo|xsux|yi|yiii|zinh|zyyy|zzzz)\}" contained display
|
||
|
syntax match hyRegexpUnicodeCharClass "\v\\[pP]\{\c%(In|blk\=|block\=)%(aegean numbers|aegean_numbers|aegeannumbers|alchemical symbols|alchemical_symbols|alchemicalsymbols|alphabetic presentation forms|alphabetic_presentation_forms|alphabeticpresentationforms|ancient greek musical notation|ancient greek numbers|ancient symbols|ancient_greek_musical_notation|ancient_greek_numbers|ancient_symbols|ancientgreekmusicalnotation|ancientgreeknumbers|ancientsymbols|arabic|arabic presentation forms-a|arabic presentation forms-b|arabic supplement|arabic_presentation_forms_a|arabic_presentation_forms_b|arabic_supplement|arabicpresentationforms-a|arabicpresentationforms-b|arabicsupplement|armenian|arrows|avestan|balinese|bamum|bamum supplement|bamum_supplement|bamumsupplement|basic latin|basic_latin|basiclatin|batak|bengali|block elements|block_elements|blockelements|bopomofo|bopomofo extended|bopomofo_extended|bopomofoextended|box drawing|box_drawing|boxdrawing|brahmi|braille patterns|braille_patterns|braillepatterns|buginese|buhid|byzantine musical symbols|byzantine_musical_symbols|byzantinemusicalsymbols|carian|cham|cherokee|cjk compatibility|cjk compatibility forms|cjk compatibility ideographs|cjk compatibility ideographs supplement|cjk radicals supplement|cjk strokes|cjk symbols and punctuation|cjk unified ideographs|cjk unified ideographs extension a|cjk unified ideographs extension b|cjk unified ideographs extension c|cjk unified ideographs extension d|cjk_compatibility|cjk_compatibility_forms|cjk_compatibility_ideographs|cjk_compatibility_ideographs_supplement|cjk_radicals_supplement|cjk_strokes|cjk_symbols_and_punctuation|cjk_unified_ideographs|cjk_unified_ideographs_extension_a|cjk_unified_ideographs_extension_b|cjk_unified_ideographs_extension_c|cjk_unified_ideographs_extension_d|cjkcompatibility|cjkcompatibilityforms|cjkcompatibilityideographs|cjkcompatibilityideographssupplement|cjkradicalssupplement|cjkstrokes|cjksymbolsandpunctuation|cjkunifiedideographs|cjkunifiedideographsextensiona|cjkunifiedideographsextensionb|cjkunifiedideographsextensionc|cjkunifiedideographsextensiond|combining diacritical marks|combining diacritical marks for symbols|combining diacritical marks supplement|combining half marks|combining marks for symbols|combining_diacritical_marks|combining_diacritical_marks_supplement|combining_half_marks|combining_marks_for_symbols|combiningdiacriticalmarks|combiningdiacriticalmarksforsymbols|combiningdiacriticalmarkssupplement|combininghalfmarks|combiningmarksforsymbols|common indic number forms|common_indic_number_forms|commonindicnumberforms|control pictures|control_pictures|controlpictures|coptic|counting rod numerals|counting_rod_numerals|countingrodnumerals|cuneiform|cuneiform numbers and punctuation|cuneiform_numbers_and_punctuation|cuneiformnumbersandpunctuation|currency symbols|currency_symbols|currencysymbols|cypriot syllabary|cypriot_syllabary|cypriotsyllabary|cyrillic|cyrillic extended-a|cyrillic extended-b|cyrillic supplement|cyrillic supplementary|cyrillic_extended_a|cyrillic_extended_b|cyrillic_supplementary|cyrillicextended-a|cyrillicextended-b|cyrillicsupplement|cyrillicsupplementary|deseret|devanagari|devanagari extended|devanagari_extended|devanagariextended|dingbats|domino tiles|domino_tiles|dominotiles|egyptian hieroglyphs|egyptian_hieroglyphs|egyptianhieroglyphs|emoticons|enclosed alphanumeric supplement|enclosed alphanumerics|enclosed cjk letters and months|enclosed ideographic supplement|enclosed_alphanumeric_supplement|enclosed_alphanumerics|enclosed_cjk_letters_and_months|enclosed_ideographic_supplement|enclosedalphanumerics|enclosedalphanumericsupplement|enclosedcjklettersandmonths|enclosedideographicsupplement|ethiopic|ethiopic extended|ethiopic extended-a|ethiopic supplement|ethiopic_extended|ethiopic_extended_a|ethiopic_supplement|ethiopicextended|ethiopicextended-a|ethiopicsupplement|general punctuation|general_punctuation|generalpunctuation|geometric shapes|geometric_shapes|geometricshapes|georgian|georgian supplement|georgian_supplement|georgiansupplement|glagolitic|gothic|g
|
||
|
|
||
|
syntax match hyRegexpPredefinedCharClass "\v%(\\[dDsSwW]|\.)" contained display
|
||
|
syntax cluster hyRegexpCharPropertyClasses contains=hyRegexpPosixCharClass,hyRegexpJavaCharClass,hyRegexpUnicodeCharClass
|
||
|
syntax cluster hyRegexpCharClasses contains=hyRegexpPredefinedCharClass,hyRegexpCharClass,@hyRegexpCharPropertyClasses
|
||
|
syntax region hyRegexpCharClass start="\\\@<!\[" end="\\\@<!\]" contained contains=hyRegexpPredefinedCharClass,@hyRegexpCharPropertyClasses
|
||
|
syntax match hyRegexpBoundary "\\[bBAGZz]" contained display
|
||
|
syntax match hyRegexpBoundary "[$^]" contained display
|
||
|
syntax match hyRegexpQuantifier "[?*+][?+]\=" contained display
|
||
|
syntax match hyRegexpQuantifier "\v\{\d+%(,|,\d+)?}\??" contained display
|
||
|
syntax match hyRegexpOr "|" contained display
|
||
|
syntax match hyRegexpBackRef "\v\\%([1-9]\d*|k\<[a-zA-z]+\>)" contained display
|
||
|
|
||
|
" Mode modifiers, mode-modified spans, lookaround, regular and atomic
|
||
|
" grouping, and named-capturing.
|
||
|
syntax match hyRegexpMod "\v\(@<=\?:" contained display
|
||
|
syntax match hyRegexpMod "\v\(@<=\?[xdsmiuU]*-?[xdsmiuU]+:?" contained display
|
||
|
syntax match hyRegexpMod "\v\(@<=\?%(\<?[=!]|\>)" contained display
|
||
|
syntax match hyRegexpMod "\v\(@<=\?\<[a-zA-Z]+\>" contained display
|
||
|
|
||
|
syntax region hyRegexpGroup start="\\\@<!(" matchgroup=hyRegexpGroup end="\\\@<!)" contained contains=hyRegexpMod,hyRegexpQuantifier,hyRegexpBoundary,hyRegexpEscape,@hyRegexpCharClasses
|
||
|
syntax region hyRegexp start=/\#"/ skip=/\\\\\|\\"/ end=/"/ contains=@hyRegexpCharClasses,hyRegexpEscape,hyRegexpQuote,hyRegexpBoundary,hyRegexpQuantifier,hyRegexpOr,hyRegexpBackRef,hyRegexpGroup keepend
|
||
|
|
||
|
syntax keyword hyCommentTodo contained FIXME XXX TODO FIXME: XXX: TODO:
|
||
|
|
||
|
syntax match hyComment ";.*$" contains=hyCommentTodo,@Spell
|
||
|
syntax match hyComment "\%^#!.*$"
|
||
|
|
||
|
syntax region hySexp matchgroup=hyParen start="(" matchgroup=hyParen end=")" contains=TOP,@Spell
|
||
|
syntax region hyVector matchgroup=hyParen start="\[" matchgroup=hyParen end="\]" contains=TOP,@Spell
|
||
|
syntax region hyMap matchgroup=hyParen start="{" matchgroup=hyParen end="}" contains=TOP,@Spell
|
||
|
|
||
|
" Highlight superfluous closing parens, brackets and braces.
|
||
|
syntax match hyError "]\|}\|)"
|
||
|
|
||
|
syntax sync fromstart
|
||
|
|
||
|
highlight default link hyConstant Constant
|
||
|
highlight default link hyBoolean Boolean
|
||
|
highlight default link hyCharacter Character
|
||
|
highlight default link hyKeyword Keyword
|
||
|
highlight default link hyNumber Number
|
||
|
highlight default link hyString String
|
||
|
highlight default link hyStringEscape Character
|
||
|
|
||
|
highlight default link hyRegexp Constant
|
||
|
highlight default link hyRegexpEscape Character
|
||
|
highlight default link hyRegexpCharClass SpecialChar
|
||
|
highlight default link hyRegexpPosixCharClass hyRegexpCharClass
|
||
|
highlight default link hyRegexpJavaCharClass hyRegexpCharClass
|
||
|
highlight default link hyRegexpUnicodeCharClass hyRegexpCharClass
|
||
|
highlight default link hyRegexpPredefinedCharClass hyRegexpCharClass
|
||
|
highlight default link hyRegexpBoundary SpecialChar
|
||
|
highlight default link hyRegexpQuantifier SpecialChar
|
||
|
highlight default link hyRegexpMod SpecialChar
|
||
|
highlight default link hyRegexpOr SpecialChar
|
||
|
highlight default link hyRegexpBackRef SpecialChar
|
||
|
highlight default link hyRegexpGroup hyRegexp
|
||
|
highlight default link hyRegexpQuoted hyString
|
||
|
highlight default link hyRegexpQuote hyRegexpBoundary
|
||
|
|
||
|
highlight default link hyVariable Identifier
|
||
|
highlight default link hyCond Conditional
|
||
|
highlight default link hyDefine Define
|
||
|
highlight default link hyException Exception
|
||
|
highlight default link hyFunc Function
|
||
|
highlight default link hyMacro Macro
|
||
|
highlight default link hyRepeat Repeat
|
||
|
|
||
|
highlight default link hySpecial Special
|
||
|
highlight default link hyVarArg Special
|
||
|
highlight default link hyQuote SpecialChar
|
||
|
highlight default link hyUnquote SpecialChar
|
||
|
highlight default link hyMeta SpecialChar
|
||
|
highlight default link hyDeref SpecialChar
|
||
|
highlight default link hyAnonArg SpecialChar
|
||
|
highlight default link hyDispatch SpecialChar
|
||
|
|
||
|
highlight default link hyComment Comment
|
||
|
highlight default link hyCommentTodo Todo
|
||
|
|
||
|
highlight default link hyError Error
|
||
|
|
||
|
highlight default link hyParen Delimiter
|
||
|
|
||
|
let b:current_syntax = "hy"
|
||
|
|
||
|
" vim:sts=4:sw=4:ts=4:et:smc=20000
|