-
Notifications
You must be signed in to change notification settings - Fork 69
Allow Whitespace Before Heredoc / Nowdoc Block Endings #95
Allow Whitespace Before Heredoc / Nowdoc Block Endings #95
Conversation
Because: - In PHP >= 7.3 Whitespace is allowed before the ending/closing tag of a herdoc/nowdoc - https://www.php.net/manual/en/migration73.new-features.php#migration73.new-features.core.heredoc - Currently `php.vim` only catches closing tags without whitespace before This commit: - Changes the end tag delimeter, per @weirdan fix
Fixes #89 |
Where you have |
syntax/php.vim
Outdated
@@ -670,7 +670,23 @@ endif | |||
syn case match | |||
|
|||
" HereDoc | |||
if version >= 704 | |||
if version >= 730 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will check against Vim's version, try :echo version<CR>
to confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, i just guessed really. I don't have any idea really how to add this. Is there a way to check for the PHP version or should I just update the end search?
So I removed the newest version check and updated the end tag in both versions. |
Maybe adding a variable config to activate or disable this would be the way to go ? As it's done for the html and sql in strings. (this is a hidden ping :D) |
Thanks, GitHub notifications are pretty bad on mobile, looks like an overlook on my part. Yes, a configurable flag would be ideal with defaults to current behaviour? |
I'd like to adhere but I don't understand which feature would be configurable. Would it enable/disable the ability to include whitespace in HEREDOC/NOWDOC's? Something along the lines of |
How about we add a buffer/global variable that specifies the PHP version? Features can then be on/off based on that variable? |
We could work on the PHP_VERSION_ID then ( |
That seems like a great idea. I believe I initially thought that was how it worked. :) |
If I go ahead and add |
In line with the rest of the variables in the syntax, this should be all lowercase |
The idea to enable this feature based on PHP is a great idea, unfortunately I think this is beyond my abilities to use vim script. If someone else found some time to finish this feature it would be greatly appreciated. |
@eknowlton I am also not too familiar with vim script. But I believe you can achieve it with the following code
The above code allows setting a global and buffer level php version. The global PHP version can be set using As I mentioned above my knowledge of vimscript is very limited. I was able to turn on/off the flexible heredoc support by changing the variable Update: It was indeed an issue with my understanding of buffer. The code is working as intended. |
Thanks for the help @JoyceBabu, you're the best. |
@eknowlton I have one more suggestion. You can remove most of the code duplication, by using a variable for the end pattern. Since we cannot use the variable, directly, you will have to build a string with the
|
Thank you all for participating in this pull request! I've now merged this to the Thanks @eknowlton for contributing! 🎆 |
@eknowlton @StanAngeloff Thanks for seeing some progress here. One thing: There's a new config setting now, right? Could you also add this to the docs please? |
I've added a commit to update the README. I'm not sure what to do with the header in the Vim file itself, it's pretty out of date now. |
Because:
php.vim
only catches closing tags without whitespacebefore
This commit: