Skip to content

Allow void to be coloured like a type #3308

Closed

Description

@tjx666

image

Activity

  1. UmairJibran commented on May 2, 2021

    @UmairJibran

    according to the latest version of the file, void and var are categorized as preemptive type, const has been moved to modifier and the String is highlighted as a normal class.

  2. UmairJibran commented on May 2, 2021

    @UmairJibran

    However, I have created a pull request with the requested changes, let's see if they accept it or not.

  3. DanTup commented on May 3, 2021

    @DanTup
    Member

    Sorry for the delay! I think void is is a little different to a normal type (for example there are places where you cannot put void but could put a type). I'm not sure if colouring it like a type is more correct than as a keyword, and some people may prefer it as is (I do - I like being able to see void at a glance and know whether a function is returning a value or not).

    If there's demand for being able to colour it like a type, perhaps it would be better to add a modifier to the semantic token so that it can be customised?

    @UmairJibran I'll comment on the PR about your change - I'm not sure I entirely understand the goal - although I will note that if we do make changes here, they should also be reflected in LSP semantic tokens, otherwise you'll see them load as one colour, and then change to another colour once the semantic tokens arrive.

  4. nbros commented on May 4, 2021

    @nbros

    I know void is a type in Dart but I still see it as the absence of a type, so I like it colored this way too (like a keyword).

  5. tjx666 commented on May 6, 2021

    @tjx666
    Author

    I see that void is colorized as type in typescript file.

    image

  6. DanTup commented on May 7, 2021

    @DanTup
    Member

    @tjx666 I think there are valid arguments for colouring it both ways. Given at least some people prefer it to be coloured like a keyword and that's what people are already used to, I think any change should be opt-in.

    Adding a semantic token modifier will allow anyone who wants it to be coloured like a type to change its colour, and the default would remain as-is.

  7. added this to the v3.23.0 milestone on May 7, 2021
  8. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    and removed on May 7, 2021
  9. changed the title [-]void is a type but syntax highlight is colorized like a keyword[/-] [+]Allow void to be coloured like a type[/+] on May 7, 2021
  10. modified the milestones: v3.23.0, On Deck on May 7, 2021
  11. modified the milestones: On Deck, v3.24.0 on May 24, 2021
  12. DanTup commented on Jun 10, 2021

    @DanTup
    Member

    I landed a change in the SDK in dart-lang/sdk@3690f54 that adds a void modifier to the keyword token, so it's now possible to customise the colour of the void keyword in your VS Code settings:

    "editor.semanticTokenColorCustomizations": {
    	"rules": {
    		"keyword.void": {
    			"foreground": "#ffff99",
    			"fontStyle": "underline"
    		}
    	}
    },

    Screenshot 2021-06-10 at 09 52 11

    By default void will remain coloured as a keyword, but you're now able to reliably customise it. Unfortunately I don't know a way with VS Code's customisations to map it to another colour so you'll have to put the colour in explicitly. You can find out what your class colour is with the Inspect Editor Tokens and Scopes command and then selected an existing class name and it should show the hex value:

    Screenshot 2021-06-10 at 09 53 26

    Note: This change is in the SDK, so you may not see it until a future Dart/SDK update (although for testing, it's already in the bleeding-edge Dart builds - ofc they're not recommended for production).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions