Jinja2 HTML extension with highlighting, LSP, and more for Zed editor
  • Rust 84.8%
  • Tree-sitter Query 15.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-07-14 22:29:24 +03:00
languages/jinja2 refactor: derive Default, drop serde_json dep, add outline.scm, fix highlight wildcards, add config options 2026-07-13 21:12:00 +03:00
src refactor: derive Default, drop serde_json dep, add outline.scm, fix highlight wildcards, add config options 2026-07-13 21:12:00 +03:00
.gitignore feat: scaffold bluejinja extension with jinja2 grammar and language config 2026-07-13 19:00:00 +03:00
AGENTS.md docs: add AGENTS.md with architecture, build instructions, and query gotchas 2026-07-13 21:25:00 +03:00
Cargo.lock chore: track Cargo.lock for reproducible builds 2026-07-13 21:15:00 +03:00
Cargo.toml updated version 2026-07-14 22:29:24 +03:00
extension.toml fix: use languages array in extension.toml and add debug tracing for LSP dispatch 2026-07-13 20:05:00 +03:00
LICENSE feat: scaffold bluejinja extension with jinja2 grammar and language config 2026-07-13 19:00:00 +03:00
README.md docs: add README with installation, configuration, and building instructions 2026-07-13 21:23:00 +03:00

BlueJinja

Warning

This project is heavily AI assisted. I do not recommend using it in production. Reports of issues that are reproducible are welcome, and the project will be maintained for the forseeable future.

A Zed extension that adds support for Jinja2 templates with syntax highlighting, embedded HTML language server, and jinja-lsp.

Features

  • Syntax highlighting for Jinja2 tags, expressions, and inline HTML content
  • Code outline (blocks, macros, extends, includes, imports)
  • Bracket matching, auto-indentation, and comment toggling
  • HTML language server — completions, hover, formatting for HTML content
  • jinja-lsp — autocomplete, goto-definition, diagnostics, hover for Jinja
  • Per-project configuration via .jinja-lsp.json
  • Custom binary path overrides for both language servers

Installation

Install from the Zed Extensions marketplace, or manually as a dev extension:

  1. Clone this repository
  2. In Zed: Extensions → Install Dev Extension → select the repository folder

File Associations

BlueJinja associates with the following file suffixes by default:

Suffix Typical use
.jinja Generic Jinja templates
.jinja2 Jinja2 templates
.j2 Short suffix
.html.j2 HTML-then-Jinja order

To use Jinja2 highlighting for plain .html files as well, add this to your Zed settings.json:

{
  "file_types": {
    "Jinja2": ["*.html", "*.htm"]
  }
}

Note: This overrides the built-in HTML language for .html files. The built-in HTML extension must remain installed — BlueJinja injects HTML via tree-sitter, which requires the HTML grammar to be available.

Configuration

Project-level config (.jinja-lsp.json)

Place a .jinja-lsp.json file at your project root. The extension reads it automatically and forwards the contents as initialization options to jinja-lsp:

{
  "templates": "./templates",
  "backend": ["./src"],
  "lang": "rust",
  "template_extensions": ["j2", "tex"],
  "filters": ["./custom-filters"]
}

All fields are optional. See the jinja-lsp README for all available options.

Global/project settings (settings.json)

Use Zed's LSP settings to pass initialization options directly. These take priority over .jinja-lsp.json:

{
  "lsp": {
    "jinja-lsp": {
      "initialization_options": {
        "templates": "./templates",
        "backend": ["./src"],
        "lang": "rust"
      }
    }
  }
}

Custom binary paths

Override the language server binary locations and control download behavior:

{
  "lsp": {
    "jinja-lsp": {
      "settings": {
        "ext": {
          "html_server": {
            "path": "/usr/local/bin/custom-html-server"
          },
          "jinja_lsp": {
            "path": "/usr/local/bin/custom-jinja-lsp",
            "ignore_system_version": false
          }
        }
      }
    }
  }
}
Field Type Description
html_server.path string or null Absolute path to the HTML language server binary.
jinja_lsp.path string or null Absolute path to the jinja-lsp binary.
jinja_lsp.ignore_system_version boolean If true, skip the PATH lookup and always download from GitHub.

Language Servers

Server Provides Source
vscode-html-language-server HTML completions, hover, diagnostics, formatting Auto-installed via npm
jinja-lsp Jinja autocomplete, goto-definition, hover, diagnostics, code actions PATH lookup or GitHub release download

Both servers start automatically when you open a Jinja2 file.

Requirements

  • Node.js — required for the HTML language server (install it separately)
  • jinja-lsp — optional; if not found on $PATH, the extension downloads a prebuilt binary from GitHub releases, or using cargo cargo install jinja-lsp.

Building

BlueJinja includes Rust code for language server orchestration. Zed compiles extension Rust code to WebAssembly — this is required by Zed's extension architecture (docs).

# Install the WASM target
rustup target add wasm32-wasip1

# Build
cargo build --release --target wasm32-wasip1

Then install as a dev extension in Zed.

License

MIT