zed icon indicating copy to clipboard operation
zed copied to clipboard

Allow for syntax highlight customizability.

Open krstp opened this issue 2 years ago • 4 comments

Check for existing issues

  • [X] Completed

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:

  • CODE SELECTION
  • or SELECT ALL FIND INSTANCES

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

krstp avatar Mar 30 '23 03:03 krstp

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.

iamnbutler avatar Apr 06 '23 16:04 iamnbutler

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?

jansol avatar Jan 26 '24 18:01 jansol

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 :|

hk0i avatar Apr 18 '24 14:04 hk0i

@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.

jansol avatar Apr 18 '24 14:04 jansol

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.

zebp avatar Jul 11 '24 02:07 zebp

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.

claire-west avatar Jul 30 '24 22:07 claire-west