From 543284e00053292ba414d1ab44b091e641dbacec Mon Sep 17 00:00:00 2001 From: Kyle Travis Date: Sat, 17 Jan 2026 18:39:42 -0500 Subject: [PATCH 1/3] new post about tree-sitter --- src/blog/custom-syntax-highlighting.md | 89 ++++++++++++++++++ src/blog/top-albums-2025.md | 8 +- .../custom-syntax-highlighting/markdown.png | Bin 0 -> 76237 bytes .../custom-syntax-highlighting/success.png | Bin 0 -> 105558 bytes 4 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 src/blog/custom-syntax-highlighting.md create mode 100644 static/images/blog/custom-syntax-highlighting/markdown.png create mode 100644 static/images/blog/custom-syntax-highlighting/success.png diff --git a/src/blog/custom-syntax-highlighting.md b/src/blog/custom-syntax-highlighting.md new file mode 100644 index 0000000..86290a3 --- /dev/null +++ b/src/blog/custom-syntax-highlighting.md @@ -0,0 +1,89 @@ +--- +name: Customizing Rust Syntax Highlighting in (Neo)Vim +slug: custom-syntax-highlighting +published: 2026-01-17 +previewLines: 5 +labels: +- vim +- rust +--- + +*Hopefully this post can be found by someone trying to answer the same questions I was, and maybe save some time.* + +Recently while working on closer integration between [Rust and WGSL shader code](/generating-shader-code-1), I looked into what it would take to get syntax highlighting working seamlessly. With a snippet like this: + +```rust +fn do_something() -> Option<()> { + // something + None +} + +const SHADER_SOURCE: &'static Shader = wgsl!(r#" + struct VertexOutput { + @builtin(position) clip_position: vec4, + } + + @vertex + fn vs_main( + vertex: ModelVertexData, + instance: InstanceDataWithNormalMatrix, + ) -> VertexOutput { + // ... + } +"); +``` + +...we want to be able to edit the "embedded" shader code as seamlessly as possible - it should look like this: + +```wgsl +struct VertexOutput { + @builtin(position) clip_position: vec4, +} + +@vertex +fn vs_main( + vertex: ModelVertexData, + instance: InstanceDataWithNormalMatrix, +) -> VertexOutput { + // ... +} +``` + +You may have seen this (multiple syntax highlighting languages used in the same file) for things like JSX or HTML with `