A lightweight Python type system for Jinja2 templates with LSP features.
Prerequisites
The Python package typedjinja must be installed in your Python environment:
pip install typedjinja
Features
Syntax highlighting for .jinja files
Go to Definition for macros and includes
Hover for types and documentation
Installation
Download the latest .vsix from the releases or build it yourself:
pnpm install
pnpm run package
pnpm dlx vsce package
In VSCode, open the Extensions view, click the three dots, and select 'Install from VSIX...'
Usage
Open any .jinja or .html file to activate the extension.
Configuration
By default, the extension scans for Jinja2 templates in the templates directory at the workspace root. To customize this location, add a [tool.typedjinja] section to your project's pyproject.toml:
[tool.typedjinja]
templateRoot = "templates" # path relative to workspace root
This setting tells the extension (and underlying language server) where to resolve template includes, macros, and imports.
Development Workflow
To set up and work on the extension locally:
Clone the repository and navigate to the extension folder:
git clone https://github.com/dakixr/TypedJinja.git
cd TypedJinja/typedjinja-vscode
Install Node.js dependencies:
pnpm install
Compile or watch the TypeScript source:
For a one-time compile:
pnpm run compile
For continuous compilation (recommended):
pnpm run watch
Open the folder in VSCode and start the Extension Development Host (press F5).
After development, build and package the VSIX:
pnpm run package
pnpm dlx vsce package
Contributing
Contributions are welcome! Please open issues or pull requests on GitHub.