Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree-sitter doesn't apply some other scopes #241001

Closed
usernamehw opened this issue Feb 17, 2025 · 6 comments · Fixed by #241208
Closed

tree-sitter doesn't apply some other scopes #241001

usernamehw opened this issue Feb 17, 2025 · 6 comments · Fixed by #241208
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders tree-sitter
Milestone

Comments

@usernamehw
Copy link
Contributor

usernamehw commented Feb 17, 2025

1. Spread operator color bleeds into variable name (obj1)

const obj1 = {};
const obj2 = {
    ...obj1,
}
function foo(param: string, ...rest) {}
TM tree-sitter
spread_old spread

2. Parameter variable.parameter (param)

function foo(param: string) {}
TM tree-sitter
param_old param

3. Language constants constant.language.nan constant.language.infinity constant.language.undefined constant.language.null

undefined 
null
NaN
Infinity
TM tree-sitter
languageConstant_old languageConstant

4. entity.name.type (One)

type One = 'zcxvf';
TM tree-sitter
entityNameType_old entityNameType

5. keyword.operator.type (&, |)

type One = 'one' | 'two' & 'three';
TM tree-sitter
typePipe_old typePipe

6. keyword.operator.optional applied where it shouldn't (object property, not type) (:)

const obj = {
    one: 1
};
TM tree-sitter
optional_old optional

7 variable.language.this works

### 7. `variable.language.this` ```ts class Foo { constructor() { this } } ```

8. punctuation.definition.typeparameters (<>)

type Rec = Record<string, string>;
TM tree-sitter
typeParam_old typeParam

9. new.expr entity.name.type (URL)

new URL('./../../renderer/dist/index.html', import.meta.url);
TM tree-sitter
newExpr_old newExpr

10. support.type.primitive (unknown)

function foo(arg: unknown) {}
TM tree-sitter
unknown_old unknown
@usernamehw
Copy link
Contributor Author

usernamehw commented Feb 17, 2025

11. storage.type & variable for TSDoc comments

export class Statistics {
  /**
   * Returns the average of two numbers.
   *
   * @remarks
   * This method is part of the {@link core-library#Statistics | Statistics subsystem}.
   *
   * @param x - The first input number
   * @param y - The second input number
   * @returns The arithmetic mean of `x` and `y`
   *
   * @beta
   */
  public static getAverage(x: number, y: number): number {
    return (x + y) / 2.0;
  }
}
TM tree-sitter
tsdoc_old tsdoc

@usernamehw
Copy link
Contributor Author

12. entity.other.inherited-class (CodeLensProvider)

export class ErrorLensCodeLens implements CodeLensProvider {}
TM tree-sitter
inherited_old inherited

@usernamehw
Copy link
Contributor Author

13. constant.character doesn't apply "bold" font-style

'\n \t';
TM tree-sitter
constantCharacter_old constantCharacter

@usernamehw
Copy link
Contributor Author

usernamehw commented Feb 17, 2025

#7 variable.language.this works actually, VSCode just doesn't update colors automatically for tree-sitter from "editor.tokenColorCustomizations" setting.

@alexr00
Copy link
Member

alexr00 commented Feb 19, 2025

Fixed spread earlier this month: #239790

We can fudge NaN and Infinity, but they need support in the grammar: tree-sitter/tree-sitter-typescript#326

new.expr

Adding, but I think your theme has multiple scopes listed for this one, and targetting it still won't work correctly with tree sitter. I'll try to address this in a later PR.

support.type.primitive (unknown)

This seems to be working already.

storage.type & variable for TSDoc comments

Requires injected languages, which I'm planning to start working on this week (won't be ready for the Feb release though).

PR incoming for all the others!

@alexr00 alexr00 added bug Issue identified by VS Code Team member as probable bug tree-sitter labels Feb 19, 2025
@alexr00 alexr00 added this to the February 2025 milestone Feb 19, 2025
@vs-code-engineering vs-code-engineering bot added the unreleased Patch has not yet been released in VS Code Insiders label Feb 19, 2025
@vs-code-engineering vs-code-engineering bot added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Feb 20, 2025
@usernamehw
Copy link
Contributor Author

Tried it latest Insiders: f238618 . Most of the issues seems to be fixed.

null & undefined & true & false types look like values now:

const n = null;
const u = undefined;
const a = true || false;
type T = null | unknown | undefined | true | false;
TM tree-sitter
typeLit_old typeLit_new

Object property colon is fixed but punctuation on types not colorized now:

function bar(a?: string): string { return '' }// ?✅ :🟥 :🟥
interface A {
    b?: 2;// ?🟥 :🟥
    a: 1;// :🟥
}
const obj = {
    a: 1,// ✅
};
TM tree-sitter
typePunct_old type_punct_new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders tree-sitter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants