Skip to content

Commit ab1699b

Browse files
authored
Merge pull request #31 from pyx/master
Update to hy 1.0.0 and hyrule 0.6.0
2 parents 0a881c3 + 13294a9 commit ab1699b

File tree

2 files changed

+50
-42
lines changed

2 files changed

+50
-42
lines changed

ftplugin/hy.vim

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,21 @@ endif
1111
runtime! ftplugin/clojure.vim
1212
setlocal iskeyword-=.
1313

14-
" Add some hy-specific lispwords
15-
setlocal lispwords+=match,except,unless,lfor,dfor,gfor,cfor
14+
" Hy specific lispwords:
15+
" All core macros in https://hylang.org/hy/doc/v1.0.0/api
16+
" with a simple rule: it should be indented specially (as lispwords) only if
17+
" its first argument is special.
18+
setlocal lispwords=let,if,when,while,for,lfor,dfor,gfor,sfor,with,match,try,
19+
\defn,fn,defmacro,defreader,defclass,except,except*
20+
"
21+
" Hyrule lispwords:
22+
" http://hylang.org/hyrule/doc/v0.6.0
23+
" same rule as above
24+
setlocal lispwords+=ap-if,ap-each,ap-each-while,ap-dotimes,ap-when,ap-with,
25+
\->,->>,as->,some->,doto,block,branch,case,cfor,
26+
\defmain,do-n,ebranch,ecase,list-n,loop,unless,defn+,
27+
\defn/a+,fn+,fn/a+,let+,defmacro-kwargs,defmacro!,
28+
\with-gensyms,seq,defseq,smacrolet
1629

1730
" Use two semicolons: The Hy style guide recommends a single semicolon for
1831
" margin comments only.

syntax/hy.vim

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,25 @@ endif
1414
let b:current_syntax = "hy"
1515

1616
syntax keyword hyAnaphoric ap-if ap-each ap-each-while ap-map ap-map-when
17-
\ ap-filter ap-reject ap-dotimes ap-first ap-last ap-reduce ap-pipe
18-
\ ap-compose
17+
\ ap-filter ap-reject ap-dotimes ap-first ap-last ap-reduce
18+
\ ap-when ap-with
1919

20+
" as of hy 1.0.0
2021
syntax keyword hyBuiltin
21-
\ and assoc block block-ret butlast chain chainc coll? constantly
22-
\ count cut dec del doc distinct doto drop-last filter flatten get
23-
\ is is-not is_not islice let list-n map of or quasiquote quote
24-
\ range reduce rest setv setx slice tee unquote unquote-splice xor zip
22+
\ annotate as-model chainc del dfor gensym get-macro gfor let lfor
23+
\ local-macros macroexpand macroexpand-1 mangle py pys quasiquote
24+
\ quote read read-many repr repr-register setv setx sfor unmangle
25+
\ unpack-iterable unpack-mapping unquote unquote-splice
26+
27+
" as of hyrule 0.6.0
28+
syntax keyword hyHyruleBuiltin
29+
\ ameth assoc block butlast cfor coll? comment constantly dec
30+
\ defmacro! defmacro-kwargs defmain defn+ defn/a+ defseq dict=:
31+
\ distinct do-n doto drop-last end-sequence flatten fn+ fn/a+
32+
\ import-path inc let+ list-n macroexpand-all map-model
33+
\ match-fn-params meth ncut parse-args pformat postwalk pp pprint
34+
\ prewalk profile/calls profile/cpu readable? recursive? rest
35+
\ saferepr seq setv+ sign smacrolet thru walk with-gensyms xor
2536
2637
" Derived from vim's python syntax file
2738
syntax keyword hyPythonBuiltin
@@ -35,6 +46,8 @@ syntax keyword hyPythonBuiltin
3546
\ --import-- __import__ --all-- __all__ --doc-- __doc__ --name--
3647
\ __name__
3748
49+
syntax keyword hyAsync await
50+
3851
syntax keyword hyBoolean True False
3952

4053
syntax keyword hyConstant None Ellipsis NotImplemented Inf NaN
@@ -54,39 +67,20 @@ syntax keyword hyException ArithmeticError AssertionError AttributeError
5467
\ BytesWarning IndentationError ResourceWarning TabError
5568

5669
syntax keyword hyStatement
57-
\ return
58-
\ break continue
59-
\ do progn
60-
\ print
61-
\ yield yield-from
62-
\ with with* with/a
63-
\ with-gensyms
64-
\ global nonlocal
65-
\ not
66-
\ in not-in
67-
\ lambda fn
68-
69-
syntax keyword hyRepeat
70-
\ loop recur for for*
71-
\ while
70+
\ break continue do fn global nonlocal return with yield
71+
72+
syntax keyword hyRepeat loop for while
7273

7374
syntax keyword hyConditional
74-
\ if lif else
75-
\ unless when
76-
\ cond branch ebranch case ecase
77-
\ match
75+
\ branch case cond ebranch ecase else if lif match unless when
7876

79-
syntax keyword hySpecial
80-
\ self
77+
syntax keyword hySpecial self
8178

82-
syntax keyword hyMisc
83-
\ eval
84-
\ eval-and-compile eval-when-compile do-mac
85-
\ apply kwapply
79+
syntax keyword hyMisc do-mac eval eval-and-compile eval-when-compile pragma
8680

87-
syntax keyword hyErrorHandling except try throw raise catch finally assert
81+
syntax keyword hyErrorHandling assert except except* finally raise try
8882

89-
syntax keyword hyInclude import require export
83+
syntax keyword hyInclude export import require
9084

9185
" Not used at this moment
9286
"syntax keyword hyVariable
@@ -120,8 +114,8 @@ syntax match hySymbol "\v%([a-zA-Z!$&*_+=|<.>?-]|[^\x00-\x7F])+%(:?%([a-zA-Z0-9!
120114
" for any custom def-* macros
121115
syntax match hyDefine /\v[(]@<=def(ault)@!\S+/
122116

123-
syntax match hyOpNoInplace "\M\<\(=\|!=\|.\|,\|->\|->>\|as->\)\>"
124-
syntax match hyOpInplace "\M\<\(!\|%\|&\|*\|**\|+\|-\|/\|//\|<\|<<\|>\|>>\|^\||\)=\?\>"
117+
syntax match hyOpNoInplace "\M\<\(=\|!=\|.\|,\|->\|->>\|as->\|some->\)\>"
118+
syntax match hyOpInplace "\M\<\(!\|%\|&\|*\|**\|+\|-\|/\|//\|<\|<<\|>\|>>\|^\||\|and\|bnot\|cut\|get\|in\|is\|is-not\|not\|not-in\|or\|of\)=\?\>"
125119

126120
" Number highlighting taken from vim's syntax/python.vim,
127121
" but modified to allow leading 0
@@ -140,7 +134,7 @@ syntax match hyQuote "'"
140134
syntax match hyQuote "`"
141135
syntax match hyUnquote "\~"
142136
syntax match hyUnquote "\~@"
143-
syntax match hyTagMacro "\v#[^:[][[:keyword:].]*"
137+
syntax match hyReaderMacro "\v#[^:[][[:keyword:].]*"
144138
syntax match hyDispatch "\v#[\^/]"
145139
syntax match hyDispatch "\v#_>"
146140
syntax match hyUnpack "\v#\*{1,2}"
@@ -230,9 +224,10 @@ highlight default link hyAsync Define
230224
highlight default link hyErrorHandling Exception
231225
highlight default link hyException Type
232226
highlight default link hyBuiltin Function
227+
highlight default link hyHyruleBuiltin Function
233228
highlight default link hyPythonBuiltin Function
234229
highlight default link hyAnaphoric Macro
235-
highlight default link hyTagMacro Macro
230+
highlight default link hyReaderMacro Macro
236231
highlight default link hyKeywordMacro Macro
237232
highlight default link hyKeywordMacroKeyword Identifier
238233
highlight default link hyRepeat Repeat
@@ -327,12 +322,12 @@ endfor
327322
if get(g:, "hy_conceal_fancy", 0) == 1
328323
syntax match hyAnonVar "\<x[0-9]\+\>" contains=hyAnonVarName,hyAnonVarIndex
329324
syntax keyword hyAnonVar xi conceal cchar=ξ
330-
syntax match hyTagMacro "#%" conceal cchar=ξ
325+
syntax match hyReaderMacro "#%" conceal cchar=ξ
331326
else
332327
syntax match hyAnonVarIndex "i" conceal cchar=¡ contained
333-
syntax match hyTagMacro contained "#" conceal cchar=x
328+
syntax match hyReaderMacro contained "#" conceal cchar=x
334329
syntax match hyAnonArg contained "%" conceal cchar=¡
335-
syntax match hyTagMacro "#%" contains=hyTagMacro,hyAnonArg
330+
syntax match hyReaderMacro "#%" contains=hyReaderMacro,hyAnonArg
336331
syntax match hyAnonVar "\<x[0-9i]\+\>" contains=hyAnonVarName,hyAnonVarIndex
337332
endif
338333

0 commit comments

Comments
 (0)