zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
39.1k stars 2.02k forks source link

More customizable syntax highlighting #12720

Open TeamPuzel opened 3 weeks ago

TeamPuzel commented 3 weeks ago

Check for existing issues

Describe the feature

I would like my syntax highlighting theme to reflect the type system similar to Xcode (but ideally less broken 🙂). I think it's very helpful for more complex languages like Swift to distinguish types based on reference/value/move semantics at a glance.

This issue is similar to https://github.com/zed-industries/zed/issues/7450, but I don't think it's the same exactly, as that depends on the language server to expose enough information about the tokens — something I did not find to be the case most of the time, some languages handling it better or worse but none enough to achieve what I am going for.

Ideally this feature wouldn't depend on that.

If applicable, add mockups / screenshots to help present your vision of the feature

Here's a class which uses reference types and value types, their names highlighted in different shades of green.

image
maxdeviant commented 3 weeks ago

How would we be able to know which types are reference and value types without information from the language server?

This doesn't seem like something that is determinable just by looking at the syntax tree in a given file.

maxdeviant commented 3 weeks ago

This does seem like it is indeed a dupe of

TeamPuzel commented 3 weeks ago

How would we be able to know which types are reference and value types without information from the language server?

That I do not know, maybe it is not easily possible, but like I said language servers don't provide enough information anyway.

I don't think it has to be accurate, it actually isn't in Xcode either - it doesn't actually know what the declaration is, I'm pretty sure it loses the correct color on a typealias for example. It shouldn't be too hard to guess this information with simple regular expressions on a language by language case.

I do not think it is a duplicate, this is referring to completely custom rules not tokens, although the tokens could help.