Compare commits

...

57 commits
1.1 ... master

Author SHA1 Message Date
Josh Sherman
17b8b86a36 Updated against 5.5.17 and cleaned up README a bit 2014-09-20 10:37:17 -04:00
Josh Sherman
b8fe9db5ff Updated README 2014-08-24 16:52:24 -04:00
Josh Sherman
6bc797f1b1 Updated to PHP 5.5.16
Also dropped test_helpers in favor of uopz.
2014-08-24 16:52:00 -04:00
Josh Sherman
6d41bb8ebd Updated against PHP 5.5.15
Got varnish worked out and added to the syntax.
2014-07-29 22:10:16 -04:00
Josh Sherman
a3d9a0622e Updated against PHP 5.5.14
Bunch of new stuff in 5.5.14, I also had to disable the varnish extension as I
couldn't get it working locally. Starting to think that perhaps I should build
out a Linux VM to run the updates against as doing so on OS X has been a bit of
a pain with a handful of packages.
2014-06-30 18:44:50 -04:00
Josh Sherman
5da9e87d89 Built against 5.5.13, no change O_o 2014-06-08 10:35:01 -04:00
Joshua Sherman
351c49dbd7 Updated against PHP 5.5.12 2014-05-07 13:50:13 -04:00
Joshua Sherman
faa13514fe PHP 5.5.11 and added tokyotyrant and varnish 2014-04-11 11:36:06 -04:00
Josh Sherman
cc2285a67e Updated against PHP 5.5.10
Added some logic to strip out the null character APC stuff, added some more extensions and added some logic to attempt to install via `brew` when the argument "brew" is passed to the update script
2014-03-11 18:18:00 -04:00
Josh Sherman
87ee790293 Merge pull request #6 from webgefrickel/fixhidden
fixed wrong hidden char
2014-02-24 11:19:30 -05:00
Steffen Rademacker
074b943910 fixed wrong hidden char 2014-02-24 14:43:57 +01:00
Joshua Sherman
f3748eb7ec Updated against 5.5.9 and added more extensions 2014-02-10 13:43:26 -05:00
Joshua Sherman
d30ecd69f8 Added @license as well
Pretty much adding @tags as I'm running into them in projects.
2014-01-14 01:01:14 -05:00
Joshua Sherman
dfe51a3864 Merge remote-tracking branch 'upstream/master'
Conflicts:
	syntax/php.template
	syntax/php.vim

Attempted to merge in upstream changes as they claimed to have fixed an issue
that broke spell checking presumably introduced by my branch. I was unable to
get spell checking working with the syntax file that was part of my original
fork: 36ccde5296

Because of this I left my script as is in favor of highlighting just the
@attribute part of the docblock and not highlighting the entire comment string
which appeared visually awkward to me. Ideally I'd love to get spell checking
working in all the places that it should be working but that seems to be a
bigger issue all together.

Also added support for the @usage attribute as it's something that is fairly
common albeit not standard docblocking
2014-01-14 00:23:14 -05:00
Joshua Sherman
4d3a14f74b Enabling more modules
I don't see the need in selectively including syntax for modules when I can
just install the modules and include them all. Expanded to include all of the
modules I could that were in the list already and updated. Going to look into
getting a more up to date module list for PHP 5.5+ and expanding further.
2014-01-13 23:32:12 -05:00
Joshua Sherman
9de06afeb4 Updated against PHP 5.5.8
Updated README and updated against the latest PHP version.
2014-01-13 23:10:35 -05:00
Joshua Sherman
3369a28954 Added test_helpers functions
For all of my friends that are good about unit testing and use the test_helpers
2014-01-13 22:55:31 -05:00
Joshua Sherman
40a8adb7f3 Fixed issue with static classes with numbers
Inadvertently also resolved issues with static classes with underscores as
well. Thanks to @kris89 for giving me a head's up where to look. Closes #2
2014-01-13 22:47:02 -05:00
Stan Angeloff
22c7308fdb Restore spell-checking in docblock comments. 2014-01-13 16:38:15 +02:00
Stan Angeloff
b6c2b2937d Merge remote-tracking branch 'boxofrox/fix/php-tag-recognition' 2014-01-09 09:22:06 +02:00
Justin Charette
65e2b0ae85 Stop phpDocParam highlight leakage
Problem:  The new Java-like syntax highligting added phpDocComment, et
al.  However phpDocParams highlighted indented html tags in a file with
no doc comments.

Fix: Mark phpDocParams as contained, so phpDocParams must reside in
phpDocComments to receive vim highlights.

Signed-off-by: Justin Charette <charetjc@gmail.com>
2014-01-08 23:48:50 -05:00
Joshua Sherman
e6ea831193 Merge branch 'master' of https://github.com/kris89/php.vim
Conflicts:
	syntax/php.template
2014-01-07 10:54:41 -05:00
Husak Kristijan
a3a40f7585 adds dockblock update 2014-01-07 09:13:03 +01:00
Joshua Sherman
e747364d65 Added improvement to the README 2014-01-06 09:50:14 -05:00
Joshua Sherman
45af33ff74 Added Static class and docblock highlighting
This is actually a rework of the patch @kris89 sent in that adds the syntax to the php.template file so they won't be lost when regenerating the php.vim file. Thanks @kris89 !!
2014-01-06 09:35:58 -05:00
Joshua Sherman
249550d2c2 Merge branch 'master' of https://github.com/StanAngeloff/php.vim
Conflicts:
	syntax/php.template
	syntax/php.vim
2014-01-06 09:31:41 -05:00
Husak Kristijan
0fc1176724 adds Static class highlight and docblock highlighting 2014-01-06 15:00:30 +01:00
Stan Angeloff
356f296e56 Extend PHP to use Java-like syntaxing highlighting (via @tetsuo13).
This commit merges parts of:

9d1e381f03
2014-01-03 11:20:39 +02:00
Stan Angeloff
bbe3272c39 Merge @paulyg commits.
This commit merges parts of:

b9b2b2daaa
e3333be231
2014-01-03 10:50:52 +02:00
Stan Angeloff
fc99f30264 Highlight booleans as 'Boolean'. 2014-01-02 17:31:36 +02:00
Stan Angeloff
dface50c42 Add 'yield' to the list of keywords (as of PHP 5.5). 2014-01-02 17:28:18 +02:00
Stan Angeloff
c85155b2c2 Update template file and re-generate using PHP 5.5.7
$ php -v

PHP 5.5.7-1+sury.org~saucy+1 (cli) (built: Dec 12 2013 21:54:59)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
2014-01-02 17:25:35 +02:00
Stan Angeloff
200921f568 Merge @joshtronic commit.
This commit merges parts of:

e9c5d0f6be

The 'finally' keyword was added to the list of recognised keywords.
2014-01-02 17:19:09 +02:00
Stan Angeloff
8adb70b636 Merge @pixelastic commit.
This commit merges parts of:

8b4b165bab
2014-01-02 17:17:09 +02:00
Stan Angeloff
4cd4f224ec Merge @aantonello commits.
This commit merges parts of:

9d24eab4ea
63c93d8825

The syntax file is more closely aligned with the generic syntax highlighting
groups in Vim.

This didn't change highlighting for my custom syntax colours, hopefully it
will not affect others as well.
2014-01-02 17:13:53 +02:00
Joshua John Sherman
d1ac476e0b Update README.md 2014-01-01 12:31:38 -05:00
Joshua Sherman
e9c5d0f6be Updated header and added support for finally 2014-01-01 12:30:11 -05:00
Joshua Sherman
db528cd03c Fixed link in README 2014-01-01 09:53:29 -05:00
Joshua Sherman
4477d204f1 Joshed it up, no joshin’
Updated to PHP 5.5.4 and added some modules I enjoy, specifically memcache, memcached, redis and xdebug.
2014-01-01 09:48:51 -05:00
Stan Angeloff
36ccde5296 Auto-generate Vim syntax with PHP 5.5.0RC1.
This commit does not add support for the new 5.5 keywords or language
constructs.
2013-05-14 14:43:13 +03:00
Stan Angeloff
f398d9a5e8 Auto-generate Vim syntax with PHP 5.5.0alpha5 (cli) (built: Feb 25 2013). 2013-02-25 09:41:59 +02:00
Stan Angeloff
6e695b0557 Use MySQL as the default buffer SQL syntax. 2013-02-25 09:05:40 +02:00
Stan Angeloff
48d2f7bb77 Merge remote-tracking branch 'jaywilliams/mysql'
> Use MySQL for Syntax Highlighting.
>
> Rather than use the limited SQL syntax, why not use the full MySQL syntax?
2013-02-25 08:58:24 +02:00
Stan Angeloff
e231676f34 Clean up syntax file, no functional changes. 2013-02-25 08:56:48 +02:00
Jay Williams
54cce0565c Use Mysql for SQL Syntax 2013-02-22 16:42:22 -06:00
Jay Williams
e6c311fdc9 Use Mysql for SQL Syntax 2013-02-22 16:42:00 -06:00
Stan Angeloff
fcfbb12a68 Auto-generate Vim syntax with PHP 5.4.6-1ubuntu1.1. 2012-11-29 13:57:34 +02:00
Stan Angeloff
c9ff5be35c Update README (switch to Markdown too). 2012-06-01 10:50:53 +03:00
Stan Angeloff
eae050302e Basic PHP 5.4 support.
This commit adds support for:

- New Core constants,
- New language keywords: trait, insteadof,
- New types, e.g., calleable and binary numbers.
2012-04-16 17:04:21 +03:00
Stan Angeloff
c74b98e131 Update template script to be smarter about missing extensions. 2012-04-16 16:52:50 +03:00
Stan Angeloff
aaf3338e6f Update template and get rid of whitespace at EOL. 2012-04-16 16:46:37 +03:00
Stan Angeloff
14823f4b05 Get rid of some extensions and rebuild with latest PHP 5.3.x on Ubuntu.
This commit introduces a new template file which will be used when
re-generating the syntax from within PHP.

In addition, several less commonly used extensions are turned off to speed up
loading of the php.vim file on start up.
2012-04-16 16:43:38 +03:00
Stan Angeloff
02a3410864 Silent call to unlet! + spellcheck updates.
Conflicts:

	syntax/php.vim

These were borrowed from paulyg/Vim-PHP-Stuff.
2012-04-16 16:11:40 +03:00
Stan Angeloff
845c961137 Add compatibility with recent html5.vim changes.
See aa0f693e7d
2012-03-06 14:47:39 +02:00
Stan Angeloff
2580adff32 Add spelling support in heredocs. 2011-11-17 15:32:01 +02:00
Stan Angeloff
993e31272d Update PHP functions list.
Rebuilt on PHP 5.3.6/Ubuntu with most extensions installed from main repo.
2011-11-17 15:22:30 +02:00
Stan Angeloff
00a9a651af Add spell-checking to strings and comments. 2011-11-17 15:06:24 +02:00
6 changed files with 1165 additions and 294 deletions

3
README
View file

@ -1,3 +0,0 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2874
This is an updated version of the php.vim syntax file distributed with VIM. The list of PHP constants, functions, and classes was updated to be current with PHP 5.3. Many new classes were added in the 5.2 branch and the distributed version only covers up to 5.1.4. In addition I simplified the file, removing several sections that are not often used (at least by me) such as automatic folding of all control structures and ASP tags support. I also removed several switches designed for b/c with VIM 5.X and 6.X. As an addition I have included the PHP file I used to generate the constant, function, class list. It uses reflection to mine out these items from your PHP installation and generate part of the php.vim script. Before running open up the file and adjust the output file location and the list of extensions to generate syntax for. Then run "php php_vimgen.php" from your shell.

56
README.md Normal file
View file

@ -0,0 +1,56 @@
# php.vim
This project is a fork of [php.vim][StanAngeloff] which is an improved version
of [php.vim--Garvin][garvin] which in turn is an update of the
[php.vim][php-vim] script which in turn is an updated version of the php.vim
syntax file distributed with Vim.
The point of this fork is to embrace the latest and greatest PHP has to offer
and constantly update against the latest PHP release.
Last updated against **5.5.17**
## Improvements
- Spell checking was enabled in strings and comments (both single and
multi-line).
- Spell checking was enabled in heredocs, e.g., `<<<EOD`.
- The PHP built-in and extension-provided functions list was updated for
PHP 5.3.
- Compatibility with [html5.vim][html5].
- Support for not-so-common extensions was turned off, e.g., `mssql_*`.
- Basic support for PHP 5.4 syntax was added.
- Support was added for PHP 5.5.7
- New modules added: memcache, memcached, redis, test_helpers and xdebug
- Support for static classes and docblock parameters (patched by @kris89)
## Customising
A script `update_syntax.php` is provided to re-generate the syntax file.
A single variable `$allowed_extensions` can be customised to
[turn on/off][defaults] certain extensions.
When re-generating the syntax file, you must have allowed extensions
installed.
### Original README
> This is an updated version of the php.vim syntax file distributed with VIM.
> The list of PHP constants, functions, and classes was updated to be current
> with PHP 5.3. Many new classes were added in the 5.2 branch and the
> distributed version only covers up to 5.1.4. In addition I simplified the
> file, removing several sections that are not often used (at least by me)
> such as automatic folding of all control structures and ASP tags support. I
> also removed several switches designed for b/c with VIM 5.X and 6.X. As an
> addition I have included the PHP file I used to generate the constant,
> function, class list. It uses reflection to mine out these items from your
> PHP installation and generate part of the php.vim script. Before running
> open up the file and adjust the output file location and the list of
> extensions to generate syntax for. Then run "php php_vimgen.php" from your
> shell.
[defaults]: https://github.com/StanAngeloff/php.vim/blob/master/update_syntax.php#L29-L101
[garvin]: https://github.com/vim-scripts/php.vim--Garvin
[html5]: https://github.com/othree/html5.vim
[php-vim]: http://www.vim.org/scripts/script.php?script_id=2874
[StanAngeloff]: https://github.com/StanAngeloff/php.vim

View file

@ -1,114 +0,0 @@
<?php
/**
* Script to gather up all native functions, classes, and interfaces from any release of
* PHP for the purposes of updating the VIM syntax file.
*
* @author Paul Garvin <paul@paulgarvin.net>
* @copyright Copyright 2009 Paul Garvin
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* This script works by loading up PHP extensions and using reflection to pull
* the functions, classes, and constants out of those extesions. The list of extensions
* below are ones included with PHP 5.3 source code. The ones commented out depend on
* an external library being installed, are Unix specific, or just not commonly used.
*
* Add, comment, or uncomment to fit your needs or particular PHP installation.
* Remember that some of these extensions are likely shared extensions and must be
* enabled in your php.ini file.
*
* NOTE: mysqlnd is not included because it exposes no functions, classes, or constants.
* The pdo_* extensions are not included in the list because they do not expose any
* functions, classes, or constants themselves. The constants and methods specific
* to that driver are exposed though the PDO extension itself. The pdo_* extensions
* must still be enabled (compiled in or loaded as shared) for these constants to show up.
*/
$extensions = array(
'core', 'bcmath', 'bz2', 'calendar', 'com_dotnet',
'ctype', 'curl', 'date', /*'dba',*/ 'dom',
'enchant', 'ereg', 'exif', 'fileinfo', 'filter',
'ftp', 'gd', 'gettext', 'gmp', 'hash',
'iconv', 'imap', /*'interbase',*/ 'intl', 'json',
'ldap', 'libxml', 'mbstring', 'mcrypt', 'mhash',
/*'mssql',*/ 'mysql', 'mysqli', /*'oci8', 'oci8_11g',*/
'odbc', 'openssl', 'pcntl', 'pcre', 'pdo',
'pgsql', 'phar', /*'posix', 'pspell', 'readline',*/
/*'recode',*/ 'reflection', 'session', 'shmop', 'simplexml',
/*'snmp',*/ 'soap', 'sockets', 'spl', 'standard',
'sqlite', 'sqlite3', /*'sybase_ct', 'sysvmsg', 'sysvsem', 'sysvshm',*/
'tidy', 'tokenizer', 'xml', 'xmlreader', 'xmlwriter',
'xmlrpc', 'xsl', /*'wddx',*/ 'zip', 'zlib'
);
$out_file = '~/php_vimgen_out.vim'; // Pick your output file & location.
$out_str = '';
$store = array();
$errors = array();
foreach ($extensions as $ext) {
echo "Processing extension '$ext'." . PHP_EOL;
try {
$extension = new ReflectionExtension($ext);
$ext_info = array();
$ext_info['name'] = $extension->getName();
$ext_functions = array_keys($extension->getFunctions());
$ext_constants = array_keys($extension->getConstants());
$classes = $extension->getClasses();
$ext_classes = array();
foreach ($classes as $class) {
$ext_classes[] = $class->getName();
$ext_constants = array_merge($ext_constants, array_keys($class->getConstants()));
}
$ext_constants = array_unique($ext_constants);
if (count($ext_functions)) {
$ext_info['functions'] = implode(' ', $ext_functions);
}
if (count($ext_constants)) {
$ext_info['constants'] = implode(' ', $ext_constants);
}
if (count($ext_classes)) {
$ext_info['classes'] = implode(' ', $ext_classes);
}
} catch (Exception $e) {
$errors[] = "\"Error: '$ext' " . $e->getMessage() . "\n";
echo 'Error Encountered.' . PHP_EOL;
}
$store[$ext] = $ext_info;
}
$out_str .= "syn case match\n\n";
foreach ($store as $ext) {
if (isset($ext['constants'])) {
$out_str .= '" ' . $ext['name'] . "\n";
$out_str .= 'syn keyword phpConstants ' . $ext['constants'] . " contained\n\n";
}
}
$out_str .= "syn case ignore\n\n";
foreach ($store as $ext) {
$out_str .= '" ' . $ext['name'] . "\n";
if (isset($ext['functions'])) {
$out_str .= 'syn keyword phpFunctions ' . $ext['functions'] . " contained\n";
}
if (isset($ext['classes'])) {
$out_str .= 'syn keyword phpClasses ' . $ext['classes'] . " contained\n\n";
}
}
foreach ($errors as $error) {
$out_str .= "$error\n";
}
file_put_contents($out_file, $out_str);
?>

366
syntax/php.template Normal file
View file

@ -0,0 +1,366 @@
" Vim syntax file
" Language: PHP 5.3 & up
"
" Maintainer: Paul Garvin <paul@paulgarvin.net>
"
" Contributor: Stan Angeloff <stanimir@angeloff.name>
" URL: https://github.com/StanAngeloff/php.vim
"
" Contributor: Alessandro Antonello <aleantonello@hotmail.com>
" URL: https://github.com/aantonello/php.vim
"
" Contributor: Tim Carry <tim@pixelastic.com>
" URL: https://github.com/pixelastic/php.vim
"
" Contributor: Joshua Sherman <josh@gravityblvd.com>
" URL: https://github.com/joshtronic/php.vim
"
" Contributor: Kristijan Husak
" URL: https://github.com/kris89/php.vim
"
" Former Maintainer: Peter Hodge <toomuchphp-vim@yahoo.com>
" Former URL: http://www.vim.org/scripts/script.php?script_id=1571
"
" Note: All of the switches for VIM 5.X and 6.X compatability were removed.
" DO NOT USE THIS FILE WITH A VERSION OF VIM < 7.0.
"
" Note: If you are using a colour terminal with dark background, you will probably find
" the 'elflord' colorscheme is much better for PHP's syntax than the default
" colourscheme, because elflord's colours will better highlight the break-points
" (Statements) in your code.
"
" Options: php_sql_query = 1 for SQL syntax highlighting inside strings
" php_html_in_strings = 1 for HTML syntax highlighting inside strings
" php_parent_error_close = 1 for highlighting parent error ] or )
" php_parent_error_open = 1 for skipping an php end tag,
" if there exists an open ( or [ without a closing one
" php_no_shorttags = 1 don't sync <? ?> as php
" php_folding = 1 for folding classes and functions
" php_sync_method = x
" x=-1 to sync by search ( default )
" x>0 to sync at least x lines backwards
" x=0 to sync from start
"
" Note:
" Setting php_folding=1 will match a closing } by comparing the indent
" before the class or function keyword with the indent of a matching }.
" Setting php_folding=2 will match all of pairs of {,} ( see known
" bugs ii )
"
" Known Bugs:
" - setting php_parent_error_close on and php_parent_error_open off
" has these two leaks:
" i) A closing ) or ] inside a string match to the last open ( or [
" before the string, when the the closing ) or ] is on the same line
" where the string started. In this case a following ) or ] after
" the string would be highlighted as an error, what is incorrect.
" ii) Same problem if you are setting php_folding = 2 with a closing
" } inside an string on the first line of this string.
"
" - A double-quoted string like this:
" "$foo->someVar->someOtherVar->bar"
" will highight '->someOtherVar->bar' as though they will be parsed
" as object member variables, but PHP only recognizes the first
" object member variable ($foo->someVar).
if exists("b:current_syntax")
finish
endif
if !exists("main_syntax")
let main_syntax = 'php'
endif
runtime! syntax/html.vim
unlet! b:current_syntax
" HTML syntax file turns on spelling for all top level words, we attempt to turn off
syntax spell default
" Set sync method if none declared
if !exists("php_sync_method")
if exists("php_minlines")
let php_sync_method=php_minlines
else
let php_sync_method=-1
endif
endif
syn cluster htmlPreproc add=phpRegion
" Use MySQL as the default SQL syntax file.
" See https://github.com/StanAngeloff/php.vim/pull/1
if !exists('b:sql_type_override') && !exists('g:sql_type_default')
let b:sql_type_override='mysql'
endif
syn include @sqlTop syntax/sql.vim
syn sync clear
unlet! b:current_syntax
syn cluster sqlTop remove=sqlString,sqlComment
if exists("php_sql_query")
syn cluster phpAddStrings contains=@sqlTop
endif
if exists("php_html_in_strings")
syn cluster phpAddStrings add=@htmlTop
endif
syn case match
" Superglobals
syn keyword phpSuperglobals GLOBALS _GET _POST _REQUEST _FILES _COOKIE _SERVER _SESSION _ENV HTTP_RAW_POST_DATA php_errormsg http_response_header argc argv contained
" Magic Constants
syn keyword phpMagicConstants __LINE__ __FILE__ __DIR__ __FUNCTION__ __CLASS__ __METHOD__ __NAMESPACE__ contained
" $_SERVER Variables
syn keyword phpServerVars GATEWAY_INTERFACE SERVER_NAME SERVER_SOFTWARE SERVER_PROTOCOL REQUEST_METHOD QUERY_STRING DOCUMENT_ROOT HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ENCODING HTTP_ACCEPT_LANGUAGE HTTP_CONNECTION HTTP_HOST HTTP_REFERER HTTP_USER_AGENT REMOTE_ADDR REMOTE_PORT SCRIPT_FILENAME SERVER_ADMIN SERVER_PORT SERVER_SIGNATURE PATH_TRANSLATED SCRIPT_NAME REQUEST_URI PHP_SELF contained
" === BEGIN BUILTIN FUNCTIONS, CLASSES, AND CONSTANTS ===================================
${code}
" === END BUILTIN FUNCTIONS, CLASSES, AND CONSTANTS =====================================
" The following is needed afterall it seems.
syntax keyword phpClasses containedin=ALLBUT,phpComment,phpDocComment,phpStringDouble,phpStringSingle,phpIdentifier,phpMethodsVar
" Control Structures
syn keyword phpKeyword if echo else elseif while do for foreach function break switch case default continue return goto as endif endwhile endfor endforeach endswitch declare endeclare print new clone yield contained
" Exception Keywords
syn keyword phpKeyword try catch finally throw contained
" Class Keywords
syn keyword phpType class abstract extends interface implements static final var public private protected const trait contained
" Magic Methods
syn keyword phpStatement __construct __destruct __call __callStatic __get __set __isset __unset __sleep __wakeup __toString __invoke __set_state __clone contained
" Language Constructs
syn keyword phpKeyword die exit eval empty isset unset list instanceof insteadof contained
" Include & friends
syn keyword phpInclude include include_once require require_once namespace use contained
" Types
syn keyword phpType bool[ean] int[eger] real double float string array object null self parent global this stdClass callable contained
" Operator
syn match phpOperator "[-=+%^&|*!.~?:]" contained display
syn match phpOperator "[-+*/%^&|.]=" contained display
syn match phpOperator "/[^*/]"me=e-1 contained display
syn match phpOperator "\$" contained display
syn match phpOperator "&&\|\<and\>" contained display
syn match phpOperator "||\|\<x\=or\>" contained display
syn match phpOperator "[!=<>]=" contained display
syn match phpOperator "[<>]" contained display
syn match phpMemberSelector "->" contained display
syn match phpVarSelector "\$" contained display
" highlight object variables inside strings
syn match phpMethodsVar "->\h\w*" contained contains=phpMethods,phpMemberSelector display containedin=phpStringDouble
syn match phpClasses "\v\h\w+(::)@=" contained display
" Identifier
syn match phpIdentifier "$\h\w*" contained contains=phpSuperglobals,phpVarSelector display
syn match phpIdentifierSimply "${\h\w*}" contains=phpOperator,phpParent contained display
syn region phpIdentifierComplex matchgroup=phpParent start="{\$"rs=e-1 end="}" contains=phpIdentifier,phpMemberSelector,phpVarSelector,phpIdentifierArray contained extend
syn region phpIdentifierArray matchgroup=phpParent start="\[" end="]" contains=@phpClInside contained
" Boolean
syn keyword phpBoolean true false contained
" Number
syn match phpNumber "-\=\<\d\+\>" contained display
syn match phpNumber "\<0x\x\{1,8}\>" contained display
syn match phpNumber "\<0b[01]\+\>" contained display
" Float
syn match phpNumber "\(-\=\<\d+\|-\=\)\.\d\+\>" contained display
" SpecialChar
syn match phpSpecialChar "\\[fnrtv\\]" contained display
syn match phpSpecialChar "\\\d\{3}" contained contains=phpOctalError display
syn match phpSpecialChar "\\x\x\{2}" contained display
" corrected highlighting for an escaped '\$' inside a double-quoted string
syn match phpSpecialChar "\\\$" contained display
syn match phpSpecialChar +\\"+ contained display
syn match phpStrEsc "\\\\" contained display
syn match phpStrEsc "\\'" contained display
" Format specifiers (printf)
" See https://github.com/aantonello/php.vim/commit/9d24eab4ea4b3752a54aebf14d3491b6d8edb6d8
syn match phpSpecialChar display contained /%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([aAbBdiouxXDOUfFeEgGcCsSpnmMyYhH]\|\[\^\=.[^]]*\]\)/ containedin=phpStringSingle,phpStringDouble,phpHereDoc
syn match phpSpecialChar display contained /%%/ containedin=phpStringSingle,phpStringDouble,phpHereDoc
" Error
syn match phpOctalError "[89]" contained display
if exists("php_parent_error_close")
syn match phpParentError "[)\]}]" contained display
endif
" Todo
syn keyword phpTodo todo fixme xxx note contained
syn match phpCommentSelector "\v\@(return|var|param|abstract|access|author|copyright|deprecated|example|global|ignore|internal|link|name|magic|package|see|since|static|staticvar|subpackage|todo|version|usage|license)" contained
" Comment
if exists("php_parent_error_open")
syn region phpComment start="/\*" end="\*/" contained contains=phpTodo,phpCommentSelector,@Spell
else
syn region phpComment start="/\*" end="\*/" contained contains=phpTodo,phpCommentSelector,@Spell extend
endif
if version >= 600
syn match phpComment "#.\{-}\(?>\|$\)\@=" contained contains=phpTodo,@Spell
syn match phpComment "//.\{-}\(?>\|$\)\@=" contained contains=phpTodo,@Spell
else
syn match phpComment "#.\{-}$" contained contains=phpTodo,@Spell
syn match phpComment "#.\{-}?>"me=e-2 contained contains=phpTodo,@Spell
syn match phpComment "//.\{-}$" contained contains=phpTodo,@Spell
syn match phpComment "//.\{-}?>"me=e-2 contained contains=phpTodo,@Spell
endif
" String
if exists("php_parent_error_open")
syn region phpStringDouble matchgroup=phpStringDelimiter start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell,@phpAddStrings,phpIdentifier,phpSpecialChar,phpIdentifierSimply,phpIdentifierComplex,phpStrEsc contained keepend
syn region phpBacktick matchgroup=phpStringDelimiter start=+`+ skip=+\\\\\|\\"+ end=+`+ contains=@Spell,@phpAddStrings,phpIdentifier,phpSpecialChar,phpIdentifierSimply,phpIdentifierComplex,phpStrEsc contained keepend
syn region phpStringSingle matchgroup=phpStringDelimiter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@Spell,@phpAddStrings,phpStrEsc contained keepend
else
syn region phpStringDouble matchgroup=phpStringDelimiter start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell,@phpAddStrings,phpIdentifier,phpSpecialChar,phpIdentifierSimply,phpIdentifierComplex,phpStrEsc contained extend keepend
syn region phpBacktick matchgroup=phpStringDelimiter start=+`+ skip=+\\\\\|\\"+ end=+`+ contains=@Spell,@phpAddStrings,phpIdentifier,phpSpecialChar,phpIdentifierSimply,phpIdentifierComplex,phpStrEsc contained extend keepend
syn region phpStringSingle matchgroup=phpStringDelimiter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@Spell,@phpAddStrings,phpStrEsc contained keepend extend
endif
" HereDoc
syn case match
syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\I\i*\)$" end="^\z1\(;\=$\)\@=" contained contains=@Spell,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
syn region phpHereDoc matchgroup=Delimiter start=+\(<<<\)\@<="\z(\I\i*\)"$+ end="^\z1\(;\=$\)\@=" contained contains=@Spell,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
" including HTML,JavaScript,SQL even if not enabled via options
syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\(\I\i*\)\=\(html\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@htmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
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
syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@htmlJavascript,phpIdentifierSimply,phpIdentifier,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
syn case ignore
" NowDoc
syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@<='\z(\I\i*\)'$+ end="^\z1\(;\=$\)\@=" contained keepend extend
" Parent
if exists("php_parent_error_close") || exists("php_parent_error_open")
syn match phpParent "[{}]" contained
syn region phpParent matchgroup=Delimiter start="(" end=")" contained contains=@phpClFunction transparent
syn region phpParent matchgroup=Delimiter start="\[" end="\]" contained contains=@phpClInside transparent
if !exists("php_parent_error_close")
syn match phpParent "[\])]" contained
endif
else
syn match phpParent "[({[\]})]" contained
endif
" Clusters
syn cluster phpClConst contains=phpFunctions,phpClasses,phpIdentifier,phpStatement,phpKeyword,phpOperator,phpStringSingle,phpStringDouble,phpBacktick,phpNumber,phpType,phpBoolean,phpStructure,phpMethodsVar,phpConstants,phpException,phpSuperglobals,phpMagicConstants,phpServerVars
syn cluster phpClInside contains=@phpClConst,phpComment,phpDocComment,phpParent,phpParentError,phpInclude,phpHereDoc,phpNowDoc
syn cluster phpClFunction contains=@phpClInside,phpDefine,phpParentError,phpStorageClass,phpKeyword
syn cluster phpClTop contains=@phpClFunction,phpFoldFunction,phpFoldClass,phpFoldInterface,phpFoldTry,phpFoldCatch
" Php Region
if exists("php_parent_error_open")
syn region phpRegion matchgroup=Delimiter start="<?\(php\)\=" end="?>" contains=@phpClTop
else
syn region phpRegion matchgroup=Delimiter start="<?\(php\)\=" end="?>" contains=@phpClTop keepend
endif
" Fold
if exists("php_folding") && php_folding==1
" match one line constructs here and skip them at folding
syn keyword phpSCKeyword abstract final private protected public static contained
syn keyword phpFCKeyword function contained
syn match phpDefine "\(\s\|^\)\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function\(\s\+.*[;}]\)\@=" contained contains=phpSCKeyword
syn match phpStructure "\(\s\|^\)\(abstract\s\+\|final\s\+\)*class\(\s\+.*}\)\@=" contained
syn match phpStructure "\(\s\|^\)interface\(\s\+.*}\)\@=" contained
syn match phpException "\(\s\|^\)try\(\s\+.*}\)\@=" contained
syn match phpException "\(\s\|^\)catch\(\s\+.*}\)\@=" contained
set foldmethod=syntax
syn region phpFoldHtmlInside matchgroup=Delimiter start="?>" end="<?\(php\)\=" contained transparent contains=@htmlTop
syn region phpFoldFunction matchgroup=Storageclass start="^\z(\s*\)\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function\s\([^};]*$\)\@="rs=e-9 matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldHtmlInside,phpFCKeyword contained transparent fold extend
syn region phpFoldFunction matchgroup=Define start="^function\s\([^};]*$\)\@=" matchgroup=Delimiter end="^}" contains=@phpClFunction,phpFoldHtmlInside contained transparent fold extend
syn region phpFoldClass matchgroup=Structure start="^\z(\s*\)\(abstract\s\+\|final\s\+\)*class\s\+\([^}]*$\)\@=" matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldFunction,phpSCKeyword contained transparent fold extend
syn region phpFoldInterface matchgroup=Structure start="^\z(\s*\)interface\s\+\([^}]*$\)\@=" matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldFunction contained transparent fold extend
syn region phpFoldCatch matchgroup=Exception start="^\z(\s*\)catch\s\+\([^}]*$\)\@=" matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldFunction contained transparent fold extend
syn region phpFoldTry matchgroup=Exception start="^\z(\s*\)try\s\+\([^}]*$\)\@=" matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldFunction contained transparent fold extend
elseif exists("php_folding") && php_folding==2
set foldmethod=syntax
syn region phpFoldHtmlInside matchgroup=Delimiter start="?>" end="<?\(php\)\=" contained transparent contains=@htmlTop
syn region phpParent matchgroup=Delimiter start="{" end="}" contained contains=@phpClFunction,phpFoldHtmlInside transparent fold
endif
" Sync
if php_sync_method==-1
syn sync match phpRegionSync grouphere phpRegion "^\s*<?\(php\)\=\s*$"
syn sync match phpRegionSync grouphere NONE "^\s*?>\s*$"
syn sync match phpRegionSync grouphere NONE "^\s*%>\s*$"
syn sync match phpRegionSync grouphere phpRegion "function\s.*(.*\$"
elseif php_sync_method>0
exec "syn sync minlines=" . php_sync_method
else
exec "syn sync fromstart"
endif
" Define the default highlighting.
" For version 5.8 and later: only when an item doesn't have highlighting yet
if !exists("did_php_syn_inits")
hi def link phpCommentTitle SpecialComment
hi def link phpComment Comment
hi def link phpDocComment Comment
hi def link phpCommentStar Comment
hi def link phpMagicConstants Constant
hi def link phpServerVars Constant
hi def link phpConstants Constant
hi def link phpBoolean Boolean
hi def link phpNumber Number
hi def link phpStringSingle String
hi def link phpStringDouble String
hi def link phpBacktick String
hi def link phpStringDelimiter String
hi def link phpHereDoc String
hi def link phpNowDoc String
hi def link phpFunctions Function
hi def link phpMethods Function
hi def link phpClasses StorageClass
hi def link phpException StorageClass
hi def link phpIdentifier Identifier
hi def link phpIdentifierSimply Identifier
hi def link phpDocIdentifier Identifier
hi def link phpStatement Statement
hi def link phpStructure Statement
hi def link phpOperator Operator
hi def link phpVarSelector Operator
hi def link phpCommentSelector PreProc
hi def link phpInclude PreProc
hi def link phpDefine PreProc
hi def link phpKeyword Keyword
hi def link phpFCKeyword Keyword
hi def link phpSCKeyword Keyword
hi def link phpSuperglobals Type
hi def link phpType Type
hi def link phpDocParam Type
hi def link phpMemberSelector Operator
hi def link phpDocTags Special
hi def link phpParent Special
hi def link phpSpecialChar SpecialChar
hi def link phpStrEsc SpecialChar
hi def link phpParentError Error
hi def link phpOctalError Error
hi def link phpTodo Todo
endif
let b:current_syntax = "php"
if main_syntax == 'php'
unlet main_syntax
endif
" vim: ts=8 sts=2 sw=2 expandtab

File diff suppressed because one or more lines are too long

258
update_syntax.php Normal file
View file

@ -0,0 +1,258 @@
<?php
/**
* Script to gather up all native functions, classes, and interfaces from any
* release of PHP for the purposes of updating the VIM syntax file.
*
* @author Paul Garvin <paul@paulgarvin.net>
* @copyright Copyright 2009 Paul Garvin
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*
* @author Stan Angeloff <stanimir@angeloff.name>
* @author Josh Sherman <josh@gravityblvd.com>
*/
/**
* This script works by loading up PHP extensions and using reflection to pull
* the functions, classes, and constants out of those extesions. The list of
* extensions below are ones included with PHP 5.3 source code. The ones
* commented out depend on an external library being installed, are Unix
* specific, or just not commonly used.
*
* Add, comment, or uncomment to fit your needs or particular PHP installation.
* Remember that some of these extensions are likely shared extensions and must
* be enabled in your php.ini file.
*
* NOTE: mysqlnd is not included because it exposes no functions, classes, or
* constants. The pdo_* extensions are not included in the list because they do
* not expose any functions, classes, or constants themselves. The constants
* and methods specific to that driver are exposed though the PDO extension
* itself. The pdo_* extensions must still be enabled (compiled in or loaded as
* shared) for these constants to show up.
*/
$allowed_extensions = [
'amqp',
'apcu',
'bcmath',
'blitz',
'boxwood',
'bz2',
'calendar',
'chdb',
#'com_dotnet',
'core',
'couchbase',
'crypto',
'ctype',
'curl',
'date',
'dba',
'dbase',
'dmtx',
'dom',
#'enchant',
'ereg',
'ev',
'exif',
'fileinfo',
'filter',
'ftp',
'gearman',
'gd',
'geoip',
'gettext',
'gmagick',
#'gmp',
'graphdat',
'hash',
'http',
'iconv',
'igbinary',
'imagick',
#'imap',
#'interbase',
'intl',
'jsmin',
'json',
'judy',
'ldap',
'leveldb',
'libevent',
'libvirt',
'libxml',
'lzf',
'mailparse',
'mbstring',
'mcrypt',
'memcache',
'memcached',
'mhash',
'mongo',
'mosquitto',
'msgpack',
#'mssql',
'mysql',
'mysqli',
'mysqlnd_ms',
'oauth',
#'oci8',
#'oci8_11g',
'odbc',
'openssl',
'pcre',
'pdo',
'pdo_pgsql',
'phar',
'pcntl',
'phalcon',
'posix',
'proctitle',
'propro',
'pspell',
'raphf',
'readline',
#'recode',
'redis',
'redland',
'reflection',
'riak',
'runkit',
'session',
'shmop',
'simplexml',
'snappy',
'snmp',
'soap',
'sockets',
'solr',
'sphinx',
'spl',
#'sqlite',
'sqlite3',
'ssh2',
'standard',
'stats',
'sundown',
'swoole',
#'sybase_ct',
'sysvmsg',
'sysvsem',
'sysvshm',
'tidy',
'timezonedb',
'tokenizer',
'tokyo_tyrant',
'uploadprogress',
'uuid',
'uopz',
'varnish',
'wbxml',
'wddx',
'xcache',
'xdebug',
'xml',
'xmldiff',
'xmlreader',
'xmlrpc',
'xmlwriter',
'xsl',
'yaf',
'yaml',
'yar',
'yaz',
'zip',
'zlib',
'zookeeper',
];
$processed = [];
foreach ($allowed_extensions as $extension)
{
try
{
$details = [];
$options = new ReflectionExtension($extension);
$classes = [];
$functions = array_keys($options->getFunctions());
$constants = array_keys($options->getConstants());
foreach ($options->getClasses() as $class)
{
$classes[] = $class->getName();
$constants = array_merge($constants, array_keys($class->getConstants()));
}
$constants = array_unique($constants);
$details['name'] = $options->getName();
if (sizeof($functions))
{
$details['functions'] = implode(' ', $functions);
}
if (sizeof($constants))
{
$details['constants'] = implode(' ', $constants);
}
if (sizeof($classes))
{
$details['classes'] = implode(' ', $classes);
}
$processed[$extension] = $details;
}
catch (Exception $e)
{
echo 'ERROR: "' . $extension . '" -- ' . $e->getMessage() . "\n";
if ($argc == 2 && $argv[1] == 'brew')
{
passthru('brew install php55-' . $extension);
}
}
}
$code = "syn case match\n\n";
foreach ($processed as $extension)
{
if (isset($extension['constants']))
{
if ($extension['name'] == 'apcu')
{
$extension['constants'] = str_replace("\0apc_register_serializer-0 ", '', $extension['constants']);
}
$code = $code . '" ' . $extension['name'] . "\n";
$code = $code . 'syn keyword phpConstants ' . $extension['constants'] . " contained\n\n";
}
}
$code = $code . "syn case ignore\n\n";
foreach ($processed as $extension)
{
$code = $code . '" ' . $extension['name'] . "\n";
if (isset($extension['functions']))
{
$code = $code . 'syn keyword phpFunctions ' . $extension['functions'] . " contained\n";
}
if (isset($extension['classes']))
{
$code = $code . 'syn keyword phpClasses ' . $extension['classes'] . " contained\n\n";
}
}
file_put_contents(
__DIR__ . '/syntax/php.vim',
str_replace('${code}', $code, file_get_contents(__DIR__ . '/syntax/php.template')),
LOCK_EX
);
?>