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

Add support for XML heredoc and nowdoc #86

Merged
merged 5 commits into from
Oct 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions syntax/php.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
" php_sql_nowdoc = 1 for SQL syntax highlighting inside nowdocs (default: 1)
" b:sql_type_override = 'postgresql' for PostgreSQL syntax highlighting in current buffer (default: 'mysql')
" g:sql_type_default = 'postgresql' to set global SQL syntax highlighting language default (default: 'mysql')"
" php_xml_heredoc = 1 for XML syntax highlighting inside heredocs (default: 0)
" php_xml_nowdoc = 1 for XML syntax highlighting inside nowdocs (default: 0)
" php_html_in_strings = 1 for HTML syntax highlighting inside strings (default: 0)
" php_html_in_heredoc = 1 for HTML syntax highlighting inside heredocs (default: 1)
" php_html_in_nowdoc = 1 for HTML syntax highlighting inside nowdocs (default: 1)
Expand Down Expand Up @@ -158,6 +160,21 @@ if ((exists("php_sql_query") && php_sql_query) || (exists("php_sql_heredoc") &&
endif
endif

if !exists("php_xml_heredoc")
let php_xml_heredoc=0
endif

if !exists("php_xml_nowdoc")
let php_xml_nowdoc=0
endif

if ((exists("php_xml_heredoc") && php_xml_heredoc) || (exists("php_xml_nowdoc") && php_xml_nowdoc))
syn include @xmlTop syntax/xml.vim

syn sync clear
unlet! b:current_syntax
endif

" set default for php_folding so we don't have to keep checking its existence.
if !exists("php_folding")
let php_folding = 0
Expand Down Expand Up @@ -665,6 +682,9 @@ if version >= 704
if (exists("php_sql_heredoc") && php_sql_heredoc)
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
endif
if (exists("php_xml_heredoc") && php_xml_heredoc)
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
endif
" @end phpHereDoc
else
" @copy phpHereDoc strip_maximum_size
Expand All @@ -678,6 +698,9 @@ else
if (exists("php_sql_heredoc") && php_sql_heredoc)
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
endif
if (exists("php_xml_heredoc") && php_xml_heredoc)
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
endif
" @end phpHereDoc
endif

Expand All @@ -693,6 +716,9 @@ if version >= 704
if (exists("php_sql_nowdoc") && php_sql_nowdoc)
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
endif
if (exists("php_xml_nowdoc") && php_xml_nowdoc)
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
endif
" @end phpNowDoc
else
" @copy phpHereDoc strip_maximum_size
Expand All @@ -706,6 +732,9 @@ else
if (exists("php_sql_heredoc") && php_sql_heredoc)
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
endif
if (exists("php_xml_heredoc") && php_xml_heredoc)
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
endif
" @end phpNowDoc
endif

Expand Down