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

Namespace highlight #31

Closed
Closed

Description

@rafi

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 very much for your work.

Activity

  1. StanAngeloff commented on Aug 19, 2014

    @StanAngeloff
    Owner

    Can you give an example? Are you after highlighting just the \ operator or the entire namespace?

  2. rafi commented on Aug 20, 2014

    @rafi
    Author

    Well, it'll be nice highlighting the entire namespace on lines with use or namespace. And the namespace up-until-the class name in function calls.

    Examples:

    1. namespace Acme\CoreBundle;
    2. use Acme\CoreBundle\App;
    3. \Acme\System::init();
    4. echo \Acme::foo()

    Highlights:

    1. Namespace: Acme\CoreBundle
    2. Namespace: Acme\CoreBundle\App
    3. Namespace: \Acme\ Class: System Method: init()
    4. Namespace: \ Class: Acme Method: foo()

    I started learning Vimscript, but syntax files are still Chinese to me. Would this namespace highlight be hard to accomplish?

  3. StanAngeloff commented on Aug 20, 2014

    @StanAngeloff
    Owner

    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()).

  4. swekaj commented on Aug 21, 2014

    @swekaj

    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:

    1. When extending or implementing, the last item must be a class or interface, e.g. class foo implements \Bar\Baz
    2. 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.

  5. StanAngeloff commented on Nov 11, 2015

    @StanAngeloff
    Owner

    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.

    Archiving discussion.

  6. tam5 commented on Dec 3, 2017

    @tam5

    @StanAngeloff I agree with:

    @swekaj 's

    I do think it could be nice to highlight the \ separator, though. That would make longer namespaces easier to read.

    Is there a way to accomplish this currently?

    Btw thanks for all your work!

  7. added a commit that references this issue on Dec 4, 2017
    97aaeb3
  8. added a commit that references this issue on Apr 16, 2018
    9483b12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions