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

Insuficient Capture Groups for keywords. #6455

Closed
EnochMtzR opened this issue Apr 16, 2024 · 1 comment
Closed

Insuficient Capture Groups for keywords. #6455

EnochMtzR opened this issue Apr 16, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@EnochMtzR
Copy link

I believe the @Keyword capture groups may be lacking expressiveness.

we currently have the following capture groups for keywords:

@keyword                   ; keywords not fitting into specific categories
@keyword.coroutine         ; keywords related to coroutines (e.g. `go` in Go, `async/await` in Python)
@keyword.function          ; keywords that define a function (e.g. `func` in Go, `def` in Python)
@keyword.operator          ; operators that are English words (e.g. `and` / `or`)
@keyword.import            ; keywords for including modules (e.g. `import` / `from` in Python)
@keyword.type              ; keywords describing composite types (e.g. `struct`, `enum`)
@keyword.modifier          ; keywords modifying other constructs (e.g. `const`, `static`, `public`)
@keyword.repeat            ; keywords related to loops (e.g. `for` / `while`)
@keyword.return            ; keywords like `return` and `yield`
@keyword.debug             ; keywords related to debugging
@keyword.exception         ; keywords related to exceptions (e.g. `throw` / `catch`)

@keyword.conditional         ; keywords related to conditionals (e.g. `if` / `else`)
@keyword.conditional.ternary ; ternary operator (e.g. `?` / `:`)

@keyword.directive         ; various preprocessor directives & shebangs
@keyword.directive.define  ; preprocessor definition directives

The way they are grouped leaves certain keywords in very awkward placement and (in my opinion) lacks descriptiveness of the code's intention.

For example:

The break keyword in C-like languages is related to repeat (to break out of a loop) and conditional (to skip switch statements). This leaves this keyword in a very awkward "just a keyword" group, which leaves Theme library developers without the necessary tools to express different styles. Multiple other keywords also sit in this awkward "catchall" category, again constraining "theme" developers in how they want to express the colours of a certain language.

I believe having a capture for @keyword.control would be more expressive. This helps us express the keyword's intent. Then, we could have subgroups like @keyword.control.conditional, for example. That way, we can group all keywords that affect the control flow and differentiate them while still having a specific group for the ones that affect the flow conditionally rather than repeatably.

Also, it would be really interesting to have a @keyword.declaration capture for languages that have multiple declaration keywords like javascript where you may have let, const, or var to declare variables.

In general, I believe there is a discussion to be had to improve the way we currently categorize all keywords to prevent ending with a "catchall" group and improve expressiveness for theme library developers.

@EnochMtzR EnochMtzR added the enhancement New feature or request label Apr 16, 2024
@clason
Copy link
Contributor

clason commented Apr 16, 2024

Sorry; we are threading the needle between a) expressiveness b) manageability and c) flat hierarchy. That ship has sailed since these groups are documented and standardized upstream.

@clason clason closed this as not planned Won't fix, can't repro, duplicate, stale Apr 16, 2024
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

2 participants