StanAngeloff / php.vim

An up-to-date Vim syntax for PHP (7.x supported)
477 stars 69 forks source link

Differentiate between class properties and functions #47

Closed msjyoo closed 8 years ago

msjyoo commented 8 years ago

Hello,

I think it would be a good idea to differentiate between class methods and class properties (variables). This is how it works in PHPStorm and it really helps to visually identify.

Maybe the presence of a bracket afterwards could serve as an indicator?

$this->var // property
$this->function( // function
StanAngeloff commented 8 years ago

I've taken a stab at this on a few occasions, but cannot get anything as reliable as PHPStorm :( Leaving open for others to pitch in.

msjyoo commented 8 years ago

@StanAngeloff What's wrong with simply detecting if a bracket exists?

StanAngeloff commented 8 years ago

Try appending this line after syn match phpMethodsVar:

syn match phpMethodsVar     "\%(->\|::\%($\)\@!\)\s*\h\w*\s*("me=e-1 skipwhite skipempty contained contains=phpMemberSelector,phpFunction display containedin=phpStringDouble

This is the best I've gotten so far. It doesn't work well if the opening bracket ( is on a new line.

Run with your modified syntax/php.vim for a while and report back if you've hit any edge cases. Hopefully the regexp is precise enough to not affect the rest of highlighting.

To customise function highlighting, override phpFunction. This is temporary and I reckon we'll add a new highlight group later on.

EDIT: You should append, not prepend the line.