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

A bunch of new matches #27

Closed
rszabo opened this issue Aug 4, 2014 · 12 comments
Closed

A bunch of new matches #27

rszabo opened this issue Aug 4, 2014 · 12 comments

Comments

@rszabo
Copy link

rszabo commented Aug 4, 2014

Hello.

I'm not accustomed to the way pull requests are made here so I'm sharing some changes I made locally.

These changes add proper handling of class constants and static methods and -variables, makes null/array/boolean separate types and more.

Remember to add the keywords to "syn cluster" or else they aren't exported properly.

syn match phpStaticSelector "::" contained display

syn match phpClassConstant "::\h\w_[^(]\w" contained contains=phpMethods,phpStaticSelector display
syn match phpStaticMethods "::\h\w_(" contained contains=phpMethods,phpStaticSelector display
syn match phpStaticClasses "\v\h\w+(::)@=" contained display
syn keyword phpException DomainException BadFunctionCallException BadMethodCallException InvalidArgumentException OutOfBoundsException OutOfRangeException OverflowException UnderflowException UnexpectedValueException UserException RuntimeException LogicException ErrorException DOMException ReflectionException Exception contained

syn keyword phpArray array contained
syn keyword phpBoolean true false TRUE FALSE contained
syn keyword phpNull null NULL contained

" Default links
hi def link phpBoolean Boolean
hi def link phpNull Null
hi def link phpArray Array

Furthermore, I strongly suggest adding file|class|brief|details|author|created|date|todo|bug|warning| to the list of phpDocTags.

@StanAngeloff
Copy link
Owner

Hey @rszabo! Thanks for sharing your changes. The best way to review those set against the full source file is to upload your version of syntax/php.vim to gist.github.com. I can then download it and diff against the Git version to see the places where you've made those modifications.

@StanAngeloff
Copy link
Owner

As for the phpDocTags enhancements, I've opened a new issue in #28 to track that update separately.

@rszabo
Copy link
Author

rszabo commented Aug 4, 2014

Sure!
https://gist.github.com/rszabo/ae010537711ba0a25027

I left a comment on row 475 which really shouldn't be disabled but it's self-explanatory why I did it.

@rszabo
Copy link
Author

rszabo commented Aug 4, 2014

You don't happen to know the correct syntax for phpClassConstant and phpStaticMethods? It bugs me that phpParentError believes that one parenthesis is off.

@StanAngeloff
Copy link
Owner

I've reviewed your code and have commented below on the proposed changes:

  • SQL is disabled using Vimscript comments. You can use configuration options instead:

    let php_sql_query=0
    let php_sql_heredoc=0
  • I'm not sold on using a separate highlighting group for arrays. As of PHP 5.4 those can be defined as ['array'] which defeats the purpose of having array highlighted differently. If we also make an exception for array, we can soon decide to have all other keywords highlighted differently. I'm not ready to do that.

  • The :: static selector is a nice addition and I can see the benefits. There is already a case for -> methods. The reason parenthesis are not balanced is likely due to the fact you've consumed the ( as part of the match. You can backtrack using :help syn-pattern-offset. See phpCommentStar and phpCommentTitle where me=e-X is used to exclude several characters at the end from matching. If you come up with a working solution, please send it over so it can be merged 👍

  • TRUE, FALSE and NULL were considered constants. Thank you for pointing this out, a commit is coming to address this.

@rszabo
Copy link
Author

rszabo commented Aug 26, 2014

Sorry for the serious delay in replying. Glad I could help, and thanks for pointing out me=e-n, really good stuff.

@StanAngeloff
Copy link
Owner

Hey, I am archiving this discussion as it has gotten quite old now and hasn't seen any updated in over an year. If you have anything new to report, please feel free to reopen with more information. Thanks!

@rszabo
Copy link
Author

rszabo commented Nov 12, 2015

Hi there!

Have you tried this with nvim, any recent version? I.e. NVIM 0.1.0 (compiled Nov 5 2015 00:37:23) / Commit: v0.1.0

Several of these matches that existed while we were working on this are no longer usable, i.e. phpStaticClasses, phpStaticClassVariable, phpStaticMethods.

syn match phpClassConstant  "::\h\w*[^(]\w" contained contains=phpMethods,phpStaticSelector display
syn match phpStaticMethods  "::\(\h\w\+\)("me=e-1 contained contains=phpStaticSelector display
syn match phpStaticClassVariable  "::\$\(\h\w\+\)" contained contains=phpStaticSelector display

Thank you

@StanAngeloff
Copy link
Owner

Hey @rszabo, the functionality in question wasn't merged in this repository. I had left you some feedback in my earlier post.

@rszabo
Copy link
Author

rszabo commented Nov 12, 2015

@StanAngeloff Yes, sorry about being away. I implemented many of those as I wrote, but failed to go upstream. Either way, they were working fine but somewhere along the neovim updates they broke, and figured maybe you saw any immediate errors.

@StanAngeloff
Copy link
Owner

Mm, interesting, other than a line for the missing syn match phpStaticSelector I can't see anything wrong with those matches. The syntax should be compatible with Neovim (albeit I don't use it very often and not an expert).

@rszabo
Copy link
Author

rszabo commented Nov 12, 2015

syn match phpStaticSelector "::" contained display

I'd love to provide a pull request of some changes in the near future.

You should check out neovim, it's much faster and instead of using Bundle you can use Plug which supports threads and more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants