# New: Better Syntax Highlighting, Including shellHook Code, With VS Code Extension

**URL:** https://discourse.nixosstag.fcio.net/t/new-better-syntax-highlighting-including-shellhook-code-with-vs-code-extension/67519
**Category:** Announcements
**Created:** [August 2, 2025, 5:04pm UTC](https://discourse.nixosstag.fcio.net/t/new-better-syntax-highlighting-including-shellhook-code-with-vs-code-extension/67519 "2025-08-02T17:04:30Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jeff-hykin](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/jeff-hykin/32/2827_2.png) [@jeff-hykin](https://discourse.nixosstag.fcio.net/u/jeff-hykin)
#### Post date: [August 2, 2025, 5:04pm UTC](https://discourse.nixosstag.fcio.net/t/new-better-syntax-highlighting-including-shellhook-code-with-vs-code-extension/67519/1 "2025-08-02T17:04:30Z")

</div>

# What is this?

Its [a VS Code extension (Better Nix Syntax)](https://github.com/jeff-hykin/better-nix-syntax) that makes `shellHook` have shell highlighting, as well as improved Nix highlighting in general!

## Let Me Show You!

### Bearded Theme (Stained Blue)

#### Before &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;After

![before_after_pt1](https://github.com/user-attachments/assets/77eeb240-af2a-44b4-955b-c2bbbeda226e) ![before_after 2](https://github.com/user-attachments/assets/bb069750-cfd3-42c0-923c-aa40744c4b40)

### Atom One Dark

| Before | After |
| --- | --- |
| ![code_atom_theirs](https://github.com/user-attachments/assets/83035afd-ec1a-413c-9b13-ee3292be6d07) | ![code_atom_mine](https://github.com/user-attachments/assets/4208f0dd-b410-452a-966a-684a08acfcbd) |

### Bearded Theme (Stained Blue)

| Before | After |
| --- | --- |
| ![code_beard_theirs](https://github.com/user-attachments/assets/c794b3fe-892f-450f-920e-37ef0f3ec5e2) | ![code_beard_mine](https://github.com/user-attachments/assets/004022dd-6d26-4965-8405-2bf99b186a32) |

### Cobalt Next

| Before | After |
| --- | --- |
| ![code_cobalt_theirs](https://github.com/user-attachments/assets/f70c84f2-f5df-48c2-826e-92c6f9046ff1) | ![code_cobalt_mine](https://github.com/user-attachments/assets/c47be3fe-bbd7-4104-bf5d-3b7b63d56d37) |

I started this project 3 years ago, I just finally got around to finishing it! I maintain the Shell syntax and C++ syntax for VS Code (I also have a Better Docker Syntax, Better Perl Syntax, Better Prolog Syntax, etc)

NOTE: most themes (including the terrible default VS Code theme) don’t take advantage of the better token-tags provided by this extension. I can’t make your theme do anything, I only give it the opportunity to do better.

---

<div class="post-metadata">

### Author: ![taciturnaxolotl](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/taciturnaxolotl/32/33228_2.png) [@taciturnaxolotl](https://discourse.nixosstag.fcio.net/u/taciturnaxolotl)
#### Post date: [August 2, 2025, 8:55pm UTC](https://discourse.nixosstag.fcio.net/t/new-better-syntax-highlighting-including-shellhook-code-with-vs-code-extension/67519/2 "2025-08-02T20:55:26Z")

</div>

oooh thank you! i wonder if a port to zed would be too hard; i can take a look at that soon

---

<div class="post-metadata">

### Author: ![Salsa9](https://discourse.nixosstag.fcio.net/letter_avatar_proxy/v4/letter/s/47e85d/32.png) [@Salsa9](https://discourse.nixosstag.fcio.net/u/Salsa9)
#### Post date: [August 3, 2025, 8:40am UTC](https://discourse.nixosstag.fcio.net/t/new-better-syntax-highlighting-including-shellhook-code-with-vs-code-extension/67519/3 "2025-08-03T08:40:28Z")

</div>

Zed uses tree-sitter which is the SOTA tool for parsing programming languages. VSCode is working on tree-sitter support too, it’s the “real solution”.

Try pasting this into zed

```nix
{
  hello-script = # bash
    ''
      #!${pkgs.bash}/bin/bash
      set -euo pipefail
      
      echo "Hello, world!"
      echo "Current directory: $(pwd)"
    '';
} 

```

(AI slop example, but try removing # bash and it should change colors in Zed)

Good work to author though, I’ll use this while waiting for tree-sitter 😄

---

<div class="post-metadata">

### Author: ![taciturnaxolotl](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/taciturnaxolotl/32/33228_2.png) [@taciturnaxolotl](https://discourse.nixosstag.fcio.net/u/taciturnaxolotl)
#### Post date: [August 3, 2025, 9:17pm UTC](https://discourse.nixosstag.fcio.net/t/new-better-syntax-highlighting-including-shellhook-code-with-vs-code-extension/67519/4 "2025-08-03T21:17:45Z")

</div>

oh sweet! i didn’t realize zed did it that way; moved all my scripts to their own files and started home.fileing because the syntax was annoying me when I used vscode and never thought to check again when i switched.

---

<div class="post-metadata">

### Author: ![jeff-hykin](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/jeff-hykin/32/2827_2.png) [@jeff-hykin](https://discourse.nixosstag.fcio.net/u/jeff-hykin)
#### Post date: [August 4, 2025, 11:17am UTC](https://discourse.nixosstag.fcio.net/t/new-better-syntax-highlighting-including-shellhook-code-with-vs-code-extension/67519/5 "2025-08-04T11:17:59Z")

</div>

> [@Salsa9](#):
>
> Zed uses tree-sitter which is the SOTA tool for parsing programming languages. VSCode is working on tree-sitter support too, it’s the “real solution”.

Nailed it 👌, thanks for answering that for me. The tree sitter is so good it’s practically cheating haha. Ive been trying to get VS code to switch for half a decade. That said, I’m not sure how editors like Zed handle nested languages. I didnt know about that # bash trick in Zed, thats fantastic

And on that note, I should mention it is provably impossible to parse nix correctly with the TextMate parser. I have to use a ton of cheats to make it look correct, and there are going to be bugs I just can’t fix. For example, the textmate parser can’t “go back” to a previous line. So if I see a {\n I don’t know if its an attr-set or the start of a function.

---

<div class="post-metadata">

### Author: ![Salsa9](https://discourse.nixosstag.fcio.net/letter_avatar_proxy/v4/letter/s/47e85d/32.png) [@Salsa9](https://discourse.nixosstag.fcio.net/u/Salsa9)
#### Post date: [August 4, 2025, 12:01pm UTC](https://discourse.nixosstag.fcio.net/t/new-better-syntax-highlighting-including-shellhook-code-with-vs-code-extension/67519/6 "2025-08-04T12:01:07Z")

</div>

My understanding is that TextMate is inadequate for most parsing. The # bash trick is called “language injection” and is defined here: [tree-sitter-nix/queries/injections.scm at ea1d87f7996be1329ef6555dcacfa63a69bd55c6 · nix-community/tree-sitter-nix · GitHub](https://github.com/nix-community/tree-sitter-nix/blob/ea1d87f7996be1329ef6555dcacfa63a69bd55c6/queries/injections.scm) but I don’t speak tree-sitter, i just know it works in Nix 😄

There’s also [tree-sitter-vscode - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=AlecGhost.tree-sitter-vscode) but it requires you to build tree-sitter parsers as wasm which I couldn’t figure out in nixpkgs when I looked at it.

Edit: I think Zed is developed by the people who wrote tree-sitter, which are the same people who worked on the Github Atom editor 😄
