Skip to content

Commit 97aaeb3

Browse files
committed
Add php{Doc,Class,Use}NamespaceSeparator.
Closes StanAngeloff#31 (and more specifically StanAngeloff#31 (comment)) The new highlighting groups are linked to their parents to avoid breaking existing syntax colouring.
1 parent f24a2bc commit 97aaeb3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

syntax/php.vim

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,9 @@ if !exists("php_ignore_phpdoc") || !php_ignore_phpdoc
619619

620620
syn region phpDocTags start="{@\(example\|id\|internal\|inheritdoc\|link\|source\|toc\|tutorial\)" end="}" containedin=phpDocComment
621621
syn match phpDocTags "@\%(abstract\|access\|api\|author\|brief\|bug\|category\|class\|copyright\|created\|date\|deprecated\|details\|example\|exception\|file\|filesource\|final\|global\|id\|ignore\|inheritdoc\|internal\|license\|link\|magic\|method\|name\|package\|param\|property\|return\|see\|since\|source\|static\|staticvar\|struct\|subpackage\|throws\|toc\|todo\|tutorial\|type\|uses\|var\|version\|warning\)" containedin=phpDocComment nextgroup=phpDocParam,phpDocIdentifier skipwhite contained
622-
syn match phpDocParam "\s\+\zs\(|\|\\\|\h\w*\)*\h\w*" nextgroup=phpDocIdentifier skipwhite contained
622+
syn match phpDocParam "\s\+\zs\(|\|\\\|\h\w*\)*\h\w*" nextgroup=phpDocIdentifier skipwhite contained contains=phpDocNamespaceSeparator
623623
syn match phpDocIdentifier "\s\+\zs$\h\w*" contained
624+
syn match phpDocNamespaceSeparator "\\" contained display
624625

625626
syn case match
626627
endif
@@ -693,25 +694,28 @@ syn keyword phpKeyword class contained
693694
\ nextgroup=phpClass skipwhite skipempty
694695
syn match phpClass /\h\w*/ contained
695696

697+
syn match phpClassNamespaceSeparator "\\" contained display
698+
696699
" Class extends
697700
syn keyword phpKeyword extends contained
698701
\ nextgroup=phpClassExtends skipwhite skipempty
699-
syn match phpClassExtends /\(\\\|\h\w*\)*\h\w*/ contained
702+
syn match phpClassExtends /\(\\\|\h\w*\)*\h\w*/ contained contains=phpClassNamespaceSeparator
700703

701704
" Class implements
702705
syntax keyword phpKeyword implements contained
703706
\ nextgroup=phpClassImplements skipwhite skipempty
704-
syntax match phpClassImplements contained
707+
syntax match phpClassImplements contained contains=phpClassNamespaceSeparator
705708
\ nextgroup=phpClassDelimiter skipwhite skipempty /\(\\\|\h\w*\)*\h\w*/
706709
syntax match phpClassDelimiter contained
707710
\ nextgroup=phpClassImplements skipwhite skipempty /,/
708711

709712
" use statement
713+
syn match phpUseNamespaceSeparator "\\" contained display
710714
syn keyword phpInclude use contained
711715
\ nextgroup=phpUseFunction,phpUseClass skipwhite skipempty
712716
syn match phpUseFunction /function\_s\+\(\\\|\h\w*\)*\h\w*/ contained contains=phpUseKeyword
713717
\ nextgroup=phpUseAlias skipwhite skipempty
714-
syn match phpUseClass /\(function\_s\+\)\@!\(\\\|\h\w*\)*\h\w*/ contained
718+
syn match phpUseClass /\(function\_s\+\)\@!\(\\\|\h\w*\)*\h\w*/ contained contains=phpUseNamespaceSeparator
715719
\ nextgroup=phpUseAlias skipwhite skipempty
716720
syn match phpUseAlias /as\_s\+\h\w*/ contained contains=phpUseKeyword
717721
syn match phpUseKeyword /\(function\|as\)\_s\+/ contained contains=phpKeyword
@@ -863,6 +867,10 @@ if !exists("did_php_syn_inits")
863867
hi def link phpClassImplements phpClass
864868
hi def link phpClassDelimiter phpRegion
865869

870+
hi def link phpDocNamespaceSeparator phpComment
871+
hi def link phpClassNamespaceSeparator phpClass
872+
hi def link phpUseNamespaceSeparator phpRegion
873+
866874
endif
867875

868876
" Cleanup: {{{

0 commit comments

Comments
 (0)