Skip to content

Commit 4ec46a3

Browse files
committed
Do not match #(…) and #{…} separately
Closes #11 External rainbow parentheses scripts, like rainbow_parentheses.vim, work by overriding the paren regions in syntax files. In order to remain compatible with such scripts, any attempts to differentiate between the different paren regions for `contains` scoping should be avoided. Creation of non-standard paren regions also conflicts with such scripts. Thus we remove the clojureAnonFn and clojureSet regions and allow the & and % reader symbols in […] and (…) regions respectively, as well as the top scope. It should be mentioned that the putative reason for creating the clojureAnonFn region was to more accurately contain % args, which is only treated specially by the reader within a reader #() function literal. However, the previous implementation didn't work correctly, causing % args to be matched only when in the top form of the #() literal.
1 parent 2d0d267 commit 4ec46a3

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

syntax/clojure.vim

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ syntax keyword clojureFunc * *' + +' - -' ->ArrayChunk ->Vec ->VecNode ->VecSeq
3434
syntax keyword clojureVariable *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* *command-line-args* *compile-files* *compile-path* *compiler-options* *data-readers* *default-data-reader-fn* *e *err* *file* *flush-on-newline* *fn-loader* *in* *math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* *source-path* *unchecked-math* *use-context-classloader* *verbose-defrecords* *warn-on-reflection* EMPTY-NODE char-escape-string char-name-string clojure.core/*1 clojure.core/*2 clojure.core/*3 clojure.core/*agent* clojure.core/*allow-unresolved-vars* clojure.core/*assert* clojure.core/*clojure-version* clojure.core/*command-line-args* clojure.core/*compile-files* clojure.core/*compile-path* clojure.core/*compiler-options* clojure.core/*data-readers* clojure.core/*default-data-reader-fn* clojure.core/*e clojure.core/*err* clojure.core/*file* clojure.core/*flush-on-newline* clojure.core/*fn-loader* clojure.core/*in* clojure.core/*math-context* clojure.core/*ns* clojure.core/*out* clojure.core/*print-dup* clojure.core/*print-length* clojure.core/*print-level* clojure.core/*print-meta* clojure.core/*print-readably* clojure.core/*read-eval* clojure.core/*source-path* clojure.core/*unchecked-math* clojure.core/*use-context-classloader* clojure.core/*verbose-defrecords* clojure.core/*warn-on-reflection* clojure.core/EMPTY-NODE clojure.core/char-escape-string clojure.core/char-name-string clojure.core/default-data-readers clojure.core/primitives-classnames clojure.core/print-dup clojure.core/print-method clojure.core/unquote clojure.core/unquote-splicing default-data-readers primitives-classnames print-dup print-method unquote unquote-splicing
3535

3636
syntax cluster clojureAtomCluster contains=clojureError,clojureFunc,clojureMacro,clojureCond,clojureDefine,clojureRepeat,clojureException,clojureConstant,clojureVariable,clojureSpecial,clojureKeyword,clojureString,clojureCharacter,clojureNumber,clojureBoolean,clojureQuote,clojureUnquote,clojureDispatch,clojureRegexp
37-
syntax cluster clojureTopCluster contains=@NoSpell,@clojureAtomCluster,clojureComment,clojureSexp,clojureAnonFn,clojureVector,clojureMap,clojureSet
37+
syntax cluster clojureTopCluster contains=@NoSpell,@clojureAtomCluster,clojureComment,clojureSexp,clojureVector,clojureMap
3838

3939
syntax match clojureKeyword "\c:\{1,2}[a-z0-9?!\-_+*.=<>#$]\+\(/[a-z0-9?!\-_+*.=<>#$]\+\)\?"
4040

@@ -66,14 +66,12 @@ syntax match clojureUnquote "\(\~@\|\~\)"
6666
syntax match clojureDispatch "\(#^\|#'\)"
6767
syntax match clojureDispatch "\^"
6868

69-
syntax match clojureAnonArg contained "%\(\d\|&\)\?"
69+
syntax match clojureAnonArg "%\(\d\|&\)\?"
7070
syntax match clojureVarArg "&"
7171

72-
syntax region clojureSexp matchgroup=clojureParen start="(" matchgroup=clojureParen end=")" contains=@clojureTopCluster
73-
syntax region clojureAnonFn matchgroup=clojureParen start="#(" matchgroup=clojureParen end=")" contains=@clojureTopCluster,clojureAnonArg,clojureSexp
74-
syntax region clojureVector matchgroup=clojureParen start="\[" matchgroup=clojureParen end="\]" contains=@clojureTopCluster,clojureVarArg,clojureSexp
75-
syntax region clojureMap matchgroup=clojureParen start="{" matchgroup=clojureParen end="}" contains=@clojureTopCluster,clojureSexp
76-
syntax region clojureSet matchgroup=clojureParen start="#{" matchgroup=clojureParen end="}" contains=@clojureTopCluster,clojureSexp
72+
syntax region clojureSexp matchgroup=clojureParen start="(" matchgroup=clojureParen end=")" contains=@clojureTopCluster,clojureAnonArg
73+
syntax region clojureVector matchgroup=clojureParen start="\[" matchgroup=clojureParen end="\]" contains=@clojureTopCluster,clojureVarArg
74+
syntax region clojureMap matchgroup=clojureParen start="{" matchgroup=clojureParen end="}" contains=@clojureTopCluster
7775

7876
syntax region clojureRegexp start=/L\=\#"/ skip=/\\\\\|\\"/ end=/"/
7977

0 commit comments

Comments
 (0)