StanAngeloff / php.vim

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

Only match first identifier in doc tag #24

Closed commonquail closed 10 years ago

commonquail commented 10 years ago

Well. That took a lot longer to find time for than anticipated.

This follows up on #19 by matching only the first identifier, and only if it occurs as the first or second argument and is preceded by at least one whitespace character.

I could not get the \@<= construct to work in the syntax file even though it worked in manual searches. I would have preferred to use that for the preceding \s in lines 585 and 586.

screenshot from 2014-07-18 12 32 44

StanAngeloff commented 10 years ago

Thanks for the pull! I'll try and review tonight/tomorrow morning. :clock1030:

StanAngeloff commented 10 years ago

Awesome & merged.

I could not get the \@<= construct to work in the syntax file even though it worked in manual searches. I would have preferred to use that for the preceding \s in lines 585 and 586.

What is the expression you tried, perhaps I can help? What don't you like about the \s?

commonquail commented 10 years ago

I think it was

syn match phpDocIdentifier "\s\@<=$\h\w*"

with some variations, including the character limit, which seemed to perform as expected in manual searches. The only reason is that it would not include \s in the capture but that's not terribly important.

StanAngeloff commented 10 years ago

I don't think it's working because you are resetting the match start. E.g., Vim expects ____$varName to match entirely as a phpDocIdentifier. When using \@<= this resets the match start to the first non-whitespace character and the matched string is just $varName. This is not what Vim expected.

To tell Vim it's OK if whitespace wasn't matched, adding skipwhite after nextgroup does the trick.

commonquail commented 10 years ago

Cheers.