Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/djlint/djlint-vscode
VS Code extension for formatting and linting HTML templates (Django, Jinja, Nunjucks, Twig, Handlebars, Mustache).
https://github.com/djlint/djlint-vscode
studio visual
Last synced: 2 months ago
JSON representation
VS Code extension for formatting and linting HTML templates (Django, Jinja, Nunjucks, Twig, Handlebars, Mustache).
- Host: GitHub
- URL: https://github.com/djlint/djlint-vscode
- Owner: djlint
- License: mit
- Created: 2022-02-05T21:32:26.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T09:32:57.000Z (4 months ago)
- Last Synced: 2024-10-29T11:44:02.649Z (4 months ago)
- Topics: studio, visual
- Language: TypeScript
- Homepage: https://marketplace.visualstudio.com/items?itemName=monosans.djlint
- Size: 2.29 MB
- Stars: 53
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# djlint-vscode
[](https://github.com/djlint/djlint-vscode/actions/workflows/ci.yml)
[](https://marketplace.visualstudio.com/items?itemName=monosans.djlint)
[](https://open-vsx.org/extension/monosans/djlint)Visual Studio Code extension for formatting and linting HTML templates (Django, Jinja, Nunjucks, Twig, Handlebars, Mustache) using [djLint](https://djlint.com).
## Installation
1. Install djLint itself with the `pip install -U djlint` command.
1. Install djLint VS Code extension from [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=monosans.djlint) or [Open VSX](https://open-vsx.org/extension/monosans/djlint).## Usage
If you have the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) installed, `djlint-vscode` will use the `djLint` installed in the currently activated Python environment, unless you have the `djlint.useVenv` extension setting disabled.
The extension can be configured through the settings in VS Code. Some options can be configured through the [djLint configuration file](https://djlint.com/docs/configuration/).
Add this to your `settings.json` to format the default enabled languages with `djLint`:
```json
"[html][django-html][handlebars][hbs][mustache][jinja][jinja-html][nj][njk][nunjucks][twig]": {
"editor.defaultFormatter": "monosans.djlint"
}
```### Usage with djLint installed with pipx
[pipx](https://pypi.org/project/pipx/) creates a separate venv for each application. You can see where it creates the venv with the `pipx environment --value PIPX_LOCAL_VENVS` command. For me it is `/home/user/.local/share/pipx/venvs`. This way I can set these settings:
```json
"djlint.useVenv": false,
"djlint.pythonPath": "/home/user/.local/share/pipx/venvs/djlint/bin/python",
```### Usage with djLint installed with uv
[uv](https://pypi.org/project/uv/) creates a separate venv for each application. You can see where it creates the venv with the `uv tool dir` command. For me it is `/home/user/.local/share/share/uv/tools`. This way I can set these settings:
```json
"djlint.useVenv": false,
"djlint.pythonPath": "/home/user/.local/share/share/uv/tools/djlint/bin/python",
```## Known issues
- Non-ASCII characters turn into `?` on Windows after formatting. To fix this, update `djLint` to v1.1.1 or higher.
- Linting does not work on Windows if the file contains non-ASCII characters. To fix this, update `djLint` to v1.1.1 or higher.
- File contents are duplicated after formatting. This is a bug in `djLint` v1.12.1, install another version.
- The config file is ignored on some versions of Python if it is in the root of the project. To fix this, update `djLint` to v1.19.2 or higher.
## License
[MIT](https://github.com/djlint/djlint-vscode/blob/main/LICENSE)