You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 1, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 1, 2020. It is now read-only.
Is it possible to highlight a namespace?
I've been using this to highlight backslashes: syn match phpParent "\\" contained .. but that's not too smart.
Thank you for the examples! I wouldn't necessarily say it's difficult to accomplish, however I'm not sold on the alternative highlighting. I'm going to leave this issue open for more people to weigh in with their opinions.
One caveat, though, is example 2 where use Acme\CoreBundle\App can be importing a class named App or a directory App (e.g., so later on you can say $instance = new App\Awesomeness()).
I'm inclined to agree with @StanAngeloff, mostly. There's really only two instances you can be sure that the last item is a class vs. namespace:
When extending or implementing, the last item must be a class or interface, e.g. class foo implements \Bar\Baz
When calling a static function, e.g. \Bar\Baz::foo()
One of these situations (2) is already covered by existing highlight rules, the keyword before :: is always highlighted differently (at least for my color scheme). I could see merit highlighting case 1, but I don't have strong feelings about it.
I do think it could be nice to highlight the \ separator, though. That would make longer namespaces easier to read.
As part of #45 and once merged you should be able to specify different highlighting for the class/namespace following use. If anyone is interested to refactor the code to add support for namespace as well, please send over a pull request and I'll gladly review & accept.
Activity
StanAngeloff commentedon Aug 19, 2014
Can you give an example? Are you after highlighting just the
\operator or the entire namespace?rafi commentedon Aug 20, 2014
Well, it'll be nice highlighting the entire namespace on lines with
useornamespace. And the namespace up-until-the class name in function calls.Examples:
namespace Acme\CoreBundle;use Acme\CoreBundle\App;\Acme\System::init();echo \Acme::foo()Highlights:
Acme\CoreBundleAcme\CoreBundle\App\Acme\Class:SystemMethod:init()\Class:AcmeMethod:foo()I started learning Vimscript, but syntax files are still Chinese to me. Would this namespace highlight be hard to accomplish?
StanAngeloff commentedon Aug 20, 2014
Thank you for the examples! I wouldn't necessarily say it's difficult to accomplish, however I'm not sold on the alternative highlighting. I'm going to leave this issue open for more people to weigh in with their opinions.
One caveat, though, is example 2 where
use Acme\CoreBundle\Appcan be importing a class namedAppor a directoryApp(e.g., so later on you can say$instance = new App\Awesomeness()).swekaj commentedon Aug 21, 2014
I'm inclined to agree with @StanAngeloff, mostly. There's really only two instances you can be sure that the last item is a class vs. namespace:
class foo implements \Bar\Baz\Bar\Baz::foo()One of these situations (2) is already covered by existing highlight rules, the keyword before
::is always highlighted differently (at least for my color scheme). I could see merit highlighting case 1, but I don't have strong feelings about it.I do think it could be nice to highlight the
\separator, though. That would make longer namespaces easier to read.StanAngeloff commentedon Nov 11, 2015
As part of #45 and once merged you should be able to specify different highlighting for the class/namespace following
use. If anyone is interested to refactor the code to add support fornamespaceas well, please send over a pull request and I'll gladly review & accept.Archiving discussion.
tam5 commentedon Dec 3, 2017
@StanAngeloff I agree with:
@swekaj 's
Is there a way to accomplish this currently?
Btw thanks for all your work!
Add php{Doc,Class,Use}NamespaceSeparator.
Add php{Doc,Class,Use}NamespaceSeparator.