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

token type is member #20

Open
I-Want-ToBelieve opened this issue Sep 24, 2022 · 9 comments
Open

token type is member #20

I-Want-ToBelieve opened this issue Sep 24, 2022 · 9 comments

Comments

@I-Want-ToBelieve
Copy link

I-Want-ToBelieve commented Sep 24, 2022

image

There is no such token type in the spec
image

vscode:

image

@kmoschcau
Copy link

@backtolife2021 Hi just a quick question since I am trying to debug my own theme with this plugin: How did you extract the name of the token type at cursor position?

@theHamsta
Copy link
Owner

I'm not sure whether this still works: nvim-treesitter/playground#57 probably not since a lot of things have changed since then (also the tree-sitter part has updated in this PR)

@theHamsta
Copy link
Owner

There is no such token type in the spec

The language servers can themselves decide what they return. They return mostly the standardized types but sometimes they return multiple tokens for the same thing. E.g. rust-analyzer has a dedicated token type for lifetimes. How did you print the token type with Neovim?

@I-Want-ToBelieve
Copy link
Author

I-Want-ToBelieve commented Oct 19, 2022

There is no such token type in the spec

The language servers can themselves decide what they return. They return mostly the standardized types but sometimes they return multiple tokens for the same thing. E.g. rust-analyzer has a dedicated token type for lifetimes. How did you print the token type with Neovim?

I use the method mentioned in this comment to print the token type
#15 (comment)

@kmoschcau
Copy link

Sadly that only works with servers that support range tokens.

@qRoC
Copy link

qRoC commented Nov 3, 2022

@I-Want-ToBelieve in vscode "member" is deprecated and refers to "method". So you see "method" in vscode.

https://github.com/microsoft/vscode/blob/1.73.0/src/vs/platform/theme/common/tokenClassificationRegistry.ts#L560

@qRoC
Copy link

qRoC commented Nov 3, 2022

VsCode classification for nvim:

semantic_tokens.token_map.comment = "@comment"
semantic_tokens.token_map.string = "@string"
semantic_tokens.token_map.keyword = "@keyword"
semantic_tokens.token_map.number = "@number"
semantic_tokens.token_map.regexp = "@string.regex"
semantic_tokens.token_map.operator = "@keyword.operator"
semantic_tokens.token_map.namespace = "@namespace"
semantic_tokens.token_map.type = "@type"
semantic_tokens.token_map.class = "@type"
semantic_tokens.token_map.interface = "@type"
semantic_tokens.token_map.enum = "@type"
semantic_tokens.token_map.struct = "@structure"
semantic_tokens.token_map.typeParameter = "@type"
semantic_tokens.token_map["function"] = "@function"
semantic_tokens.token_map.member = "@method"
semantic_tokens.token_map.method = "@method"
semantic_tokens.token_map.macro = "@function.macro"
semantic_tokens.token_map.variable = "@variable"
semantic_tokens.token_map.parameter = "@parameter"
semantic_tokens.token_map.property = "@property"
semantic_tokens.token_map.enumMember = "@constant"
semantic_tokens.token_map.event = "@variable"
semantic_tokens.token_map.label = "@label"
semantic_tokens.token_map.decorator = "@attribute"
semantic_tokens.token_map.attribute = "@attribute"

semantic_tokens.modifiers_map.readonly = {
  variable = "@constant",
  property = "@constant",
}
semantic_tokens.modifiers_map.constant = {
  variable = "@constant",
  property = "@constant",
}

semantic_tokens.modifiers_map.defaultLibrary = {
  typeAlias = "@type.builtin",
  type = "@type.builtin",
  class = "@type.builtin",
  interface = "@type.builtin",
  variable = "@type.builtin",
  property = "@type.builtin",
  enum = "@type.builtin",
  ["function"] = "@type.builtin",
  method = "@type.builtin",
  member = "@type.builtin",
}

Rust extension:

-- Rust: Style for builtin attributes
semantic_tokens.token_map.builtinAttribute = "@attribute"
-- Rust: Style for builtin types
semantic_tokens.token_map.builtinType = "@type.builtin"
-- Rust: Style for char escapes in strings
semantic_tokens.token_map.escapeSequence = "@string.escape"
-- Rust: Style for {} placeholders in format strings
semantic_tokens.token_map.formatSpecifier = "@operator"
-- Rust: Style for the self keyword
semantic_tokens.token_map.selfKeyword = "@keyword"
-- Rust: Style for the self type keyword
semantic_tokens.token_map.selfTypeKeyword = "@keyword"

-- Rust: Style for mutable locals and statics as well as functions
--       taking `&mut self`
semantic_tokens.modifiers_map.mutable = "@text.underline"

@qRoC
Copy link

qRoC commented Feb 10, 2023

Same for nvim 0.9 (without this plugin)

https://gist.github.com/qRoC/288727caed4aa361ef5f15fa7852ca3e

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

No branches or pull requests

4 participants