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

Don't use @definition.* caputere groups #482

Open
stsewd opened this issue Sep 17, 2020 · 3 comments
Open

Don't use @definition.* caputere groups #482

stsewd opened this issue Sep 17, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@stsewd
Copy link
Member

stsewd commented Sep 17, 2020

Currently, we have @definition.{type} queries, this doesn't make it easy/obvious to get a list of all definitions (or navigate them). We could use the #set! directive instead to set the type of the definition.

Instead of

((function_definition
  name: (identifier) @definition.function) @scope
 (#set! definition.function.scope "parent"))

We will write it like:

((function_definition
  name: (identifier) @definition) @scope
 (#set! definition.scope "parent")
 (#set! definition.type "function"))
@stsewd stsewd added the enhancement New feature or request label Sep 17, 2020
@vigoux
Copy link
Member

vigoux commented Sep 17, 2020

Not sure, I wanted to use @definition.type for actual type inference purpose, to enhance things like completion and so on.

@steelsojka
Copy link
Contributor

There should be a function for this in utils that gets all nodes and their type recursively. Take a look at this https://github.com/nvim-treesitter/nvim-treesitter/blob/master/lua/nvim-treesitter/locals.lua#L108

@stsewd
Copy link
Member Author

stsewd commented Sep 18, 2020

There should be a function for this in utils that gets all nodes and their type recursively. Take a look at this https://github.com/nvim-treesitter/nvim-treesitter/blob/master/lua/nvim-treesitter/locals.lua#L108

yeah, I saw that, but it feels weird that definitions are the only ones using that.

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

No branches or pull requests

3 participants