Skip to content

Commit 418beea

Browse files
committed
Keyword and Symbol prefix matching
1 parent b21188c commit 418beea

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Diff for: syntax/clojure.vim

+13-3
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,26 @@ endif
6262
unlet! s:key
6363
delfunction s:syntax_keyword
6464

65+
syntax match clojureKeywordNs contained "\v[^/ :']+\ze/"
66+
syntax match clojureKeywordNsSeparator contained "/"
67+
syntax match clojureKeywordNsColon contained "\v<:{1,2}"
6568
" Keywords are symbols:
6669
" static Pattern symbolPat = Pattern.compile("[:]?([\\D&&[^/]].*/)?([\\D&&[^/]][^/]*)");
6770
" But they:
6871
" * Must not end in a : or /
6972
" * Must not have two adjacent colons except at the beginning
7073
" * Must not contain any reader metacharacters except for ' and #
71-
syntax match clojureKeyword "\v<:{1,2}([^ \n\r\t()\[\]{}";@^`~\\/]+/)*[^ \n\r\t()\[\]{}";@^`~\\/]+:@1<!>"
74+
syntax match clojureKeyword "\v<:{1,2}([^ \n\r\t()\[\]{}";@^`~\\/]+/)*[^ \n\r\t()\[\]{}";@^`~\\/]+:@1<!>" contains=clojureKeywordNs,clojureKeywordNsSeparator,clojureKeywordNsColon
7275

7376
syntax match clojureStringEscape "\v\\%([\\btnfr"]|u\x{4}|[0-3]\o{2}|\o{1,2})" contained
7477

7578
syntax region clojureString matchgroup=clojureStringDelimiter start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=clojureStringEscape,@Spell
7679

7780
syntax match clojureCharacter "\v\\%(o%([0-3]\o{2}|\o{1,2})|u\x{4}|newline|tab|space|return|backspace|formfeed|.)"
7881

79-
syntax match clojureSymbol "\v%([a-zA-Z!$&*_+=|<.>?-]|[^\x00-\x7F])+%(:?%([a-zA-Z0-9!#$%&*_+=|'<.>/?-]|[^\x00-\x7F]))*[#:]@1<!"
82+
syntax match clojureSymbolNs contained "\v[^/ :']+\ze/"
83+
syntax match clojureSymbolNsSeparator contained "/"
84+
syntax match clojureSymbol "\v%([a-zA-Z!$&*_+=|<.>?-]|[^\x00-\x7F])+%(:?%([a-zA-Z0-9!#$%&*_+=|'<.>/?-]|[^\x00-\x7F]))*[#:]@1<!" contains=clojureSymbolNs,clojureSymbolNsSeparator
8085

8186
" NB. Correct matching of radix literals was removed for better performance.
8287
syntax match clojureNumber "\v<[-+]?%(%([2-9]|[12]\d|3[0-6])[rR][[:alnum:]]+|%(0\o*|0x\x+|[1-9]\d*)N?|%(0|[1-9]\d*|%(0|[1-9]\d*)\.\d*)%(M|[eE][-+]?\d+)?|%(0|[1-9]\d*)/%(0|[1-9]\d*))>"
@@ -162,12 +167,17 @@ syntax sync fromstart
162167
highlight default link clojureConstant Constant
163168
highlight default link clojureBoolean Boolean
164169
highlight default link clojureCharacter Character
165-
highlight default link clojureKeyword Keyword
166170
highlight default link clojureNumber Number
167171
highlight default link clojureString String
168172
highlight default link clojureStringDelimiter String
169173
highlight default link clojureStringEscape Character
170174

175+
highlight default link clojureKeyword Keyword
176+
highlight default link clojureKeywordNsColon clojureKeyword
177+
highlight default link clojureKeywordNs clojureKeyword
178+
179+
highlight default link clojureSymbolNs clojureSymbol
180+
171181
highlight default link clojureRegexp Constant
172182
highlight default link clojureRegexpDelimiter Constant
173183
highlight default link clojureRegexpEscape Character

0 commit comments

Comments
 (0)