Skip to content
This repository was archived by the owner on Dec 1, 2020. It is now read-only.

Commit 7671a5a

Browse files
authored
Merge pull request #86 from akrabat/xml-heredoc
Add support for XML heredoc and nowdoc
2 parents 9f2d8fb + ea8d6a5 commit 7671a5a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

syntax/php.vim

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
" php_sql_nowdoc = 1 for SQL syntax highlighting inside nowdocs (default: 1)
3838
" b:sql_type_override = 'postgresql' for PostgreSQL syntax highlighting in current buffer (default: 'mysql')
3939
" g:sql_type_default = 'postgresql' to set global SQL syntax highlighting language default (default: 'mysql')"
40+
" php_xml_heredoc = 1 for XML syntax highlighting inside heredocs (default: 0)
41+
" php_xml_nowdoc = 1 for XML syntax highlighting inside nowdocs (default: 0)
4042
" php_html_in_strings = 1 for HTML syntax highlighting inside strings (default: 0)
4143
" php_html_in_heredoc = 1 for HTML syntax highlighting inside heredocs (default: 1)
4244
" php_html_in_nowdoc = 1 for HTML syntax highlighting inside nowdocs (default: 1)
@@ -158,6 +160,21 @@ if ((exists("php_sql_query") && php_sql_query) || (exists("php_sql_heredoc") &&
158160
endif
159161
endif
160162

163+
if !exists("php_xml_heredoc")
164+
let php_xml_heredoc=0
165+
endif
166+
167+
if !exists("php_xml_nowdoc")
168+
let php_xml_nowdoc=0
169+
endif
170+
171+
if ((exists("php_xml_heredoc") && php_xml_heredoc) || (exists("php_xml_nowdoc") && php_xml_nowdoc))
172+
syn include @xmlTop syntax/xml.vim
173+
174+
syn sync clear
175+
unlet! b:current_syntax
176+
endif
177+
161178
" set default for php_folding so we don't have to keep checking its existence.
162179
if !exists("php_folding")
163180
let php_folding = 0
@@ -665,6 +682,9 @@ if version >= 704
665682
if (exists("php_sql_heredoc") && php_sql_heredoc)
666683
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@3<=\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
667684
endif
685+
if (exists("php_xml_heredoc") && php_xml_heredoc)
686+
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@3<=\z(\(\I\i*\)\=\(xml\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@xmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
687+
endif
668688
" @end phpHereDoc
669689
else
670690
" @copy phpHereDoc strip_maximum_size
@@ -678,6 +698,9 @@ else
678698
if (exists("php_sql_heredoc") && php_sql_heredoc)
679699
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
680700
endif
701+
if (exists("php_xml_heredoc") && php_xml_heredoc)
702+
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\(\I\i*\)\=\(xml\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@xmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
703+
endif
681704
" @end phpHereDoc
682705
endif
683706

@@ -693,6 +716,9 @@ if version >= 704
693716
if (exists("php_sql_nowdoc") && php_sql_nowdoc)
694717
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@3<='\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)'$+ end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
695718
endif
719+
if (exists("php_xml_nowdoc") && php_xml_nowdoc)
720+
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@3<='\z(\(\I\i*\)\=\(xml\)\c\(\i*\)\)'$+ end="^\z1\(;\=$\)\@=" contained contains=@xmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
721+
endif
696722
" @end phpNowDoc
697723
else
698724
" @copy phpHereDoc strip_maximum_size
@@ -706,6 +732,9 @@ else
706732
if (exists("php_sql_heredoc") && php_sql_heredoc)
707733
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
708734
endif
735+
if (exists("php_xml_heredoc") && php_xml_heredoc)
736+
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\(\I\i*\)\=\(xml\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@xmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
737+
endif
709738
" @end phpNowDoc
710739
endif
711740

0 commit comments

Comments
 (0)