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
49.65k stars 3.04k forks source link

Allow for syntax highlight customizability. #4859

Open krstp opened 1 year ago

krstp commented 1 year ago

Check for existing issues

Describe the feature

Allow for custom syntax highlighting definitions; this is essentially and option to allow user to create their own syntax highlighting themes. This is somewhat related and extends on zed-industries/zed#4986 , but I feel this ticket is more general and to the point.

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

One of good example is ability to change:

For example: yellow font background with black letters, etc. This allows/helps enhance visibility of those find instances to stand out. I can see a similar highlight is already available in ZED, but currently we lack customizability.

Sample screenshot: custom_syntax_highlighting

iamnbutler commented 1 year ago

Internally we already have this: CleanShot 2023-04-06 at 12 08 59

Externally, we will eventually publish a package that allows people to create their own themes. You can read a bit more about our plans here: https://docs.zed.dev/configuration/themes

We have some work to do before the theme system is stable enough to provide others access to writing their own themes.

jansol commented 9 months ago

I don't think the two issues overlap that much. #4986 is specifically about having a wider variety of attributes (namely font family, style, weight) available to syntax themes to change on a per element basis while this seems to be more about user overrides for individual syntax theme rules?

hk0i commented 6 months ago

Is it still not possible to create custom syntax highlighting? Couldn't find anything about it on the web.

Was hoping to use Zed to work on Server Side Swift using Vapor, but there's no .leaf syntax file support -- without this the editor is pretty much a no-go for me since pretty much every other editor has this out of the box.

HTML will get 90% of the highlighting minus the swifty leaf stuff but then I have to set the highlighting every time I open a file, which is very much the antithesis of coding at the speed of thought :|

jansol commented 6 months ago

@hkoi What do you mean by "custom"? You can now create extensions to add whatever tree-sitter parser you like. You can also define arbitrary highlights in extensions and (re)style them in your theme. Take a look at... well, pretty much any language extension in the extension store or in this repo.

zebp commented 4 months ago

It'd be nice to be able to edit the highlight captures for including languages without having to maintain a fork of Zed or a custom extension, even if it's just to iterate on changes to the included highlights.scm. I'm currently in the process of trying to improve the highlights for Rust and the workflow has proven to be quite painful, and as far as I can tell if my changes don't get upstream I'd have to maintain a fork of Zed (because I can't redefine the highlights via extension I think) with just a different highlights.scm.

claire-west commented 3 months ago

Agreed. Really all I want is to make a few changes in the highlights.scm mapping for HTML and JavaScript.

It probably wouldn't be difficult to copy the default HTML extension and install my modified version, but it seems the JS highlighting is implemented natively rather than as a default extension, so the overhead to make a couple small changes would be quite large.

edit: I found that the default JS highlighting is from the tree-sitter-javascript repo, and was able to make my own extension as a temporary fix with my adjusted syntax highlighting. This is really not an ideal solution though, because I now have a whole separate language for just a couple things to be a different color and italicized.

viluMatilda commented 2 weeks ago

the low granularity of highlights.scm is preventing me from moving from VS Code to Zed unfortunately. I just feel lost when looking at the same piece of code when the syntax highlighting is different.

for example differentiation of component and function declarations from types, and differentiation among keywords. VSCode Dark + theme isn't possible to mimic in Zed because of these restrictions in highlights.scm, even though the Typescript tree-sitter is capably of differentiating them.