swiftlang / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages
Apache License 2.0
3.2k stars 264 forks source link

Parameter label as `function` token #1540

Open GrayJack opened 2 days ago

GrayJack commented 2 days ago

Swift version

swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-22-a

Platform

macOS 14.0

Editor

Visual Studio Code

Does the issue reproduce with Swift 6?

Yes

Description

The parameter label of the function is being tokenized as a function semantic token. I expected this token to be something different than function, maybe label or parameter with modifier label?

For me, this is happening with 5.10 and swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-22-a

Screenshot 2024-06-29 at 23 36 05

Steps to Reproduce

Logging

No response

ahoppen commented 2 days ago

Synced to Apple’s issue tracker as rdar://130831950

ahoppen commented 19 hours ago

The argument label is deliberately marked as function because

https://github.com/swiftlang/sourcekit-lsp/pull/983 has some discussion around this same issue. I’m closing this issue because I think it behaves correctly based on these considerations. If you disagree, please re-open it.

GrayJack commented 15 hours ago

@ahoppen After reading the previous discussion, I agree that the token should be function, but I think it deserves some kind of modifier if someone would like to do some styling or coloring in that particular token.

My particular niche for this feature is that I help create themes for neurodivergent people, some of them have a better time reading and writing code when coloring+styling are unique to certain tokens.

Although that is my niche, I also saw people wanting to colorize code differently for other reasons as well, as some forms of visual synesthesia for example, but also people that just prefer to add something more for their head context

ahoppen commented 15 hours ago

Adding a modifier seems reasonable. Let’s re-open it for that. If you’re interested in opening a PR for this change, that would also be welcome. It should be a fairly easy change.

GrayJack commented 13 hours ago

Yes, I'm interested!

Do you think there is any modifier that would fit this use case? At first glance, I think no existing modifier fits 100%, so I'm thinking of adding a new one, parameterLabel, or something similar

ahoppen commented 11 hours ago

I think adding a new modifier would be the way to go