fourdigits / django-template-lsp

GNU General Public License v3.0
18 stars 0 forks source link

Django Template Language Server (LSP)

The Django Template Language Server (LSP) enhances your Django development experience with powerful features for navigating and editing template files. This LSP supports:

Completions

Go to Definitions

Hover Documentation

Support (tested)

Install

pip install django-template-lsp

Options

Type hints

Due to the highly dynamic nature of Python and Django, it can be challenging to identify the available context data within templates. To address this, basic type hint support is provided directly in the template files:

{# type blog: blogs.models.Blog #}

Editors

Helix

In your global or project languages.toml add the following

[language-server.djlsp]
command = "djlsp"

[[language]]
name = "html"
language-servers = [ "vscode-html-language-server", "djlsp" ]

Project settings .helix/languages.toml:

[language-server.djlsp.config]
django_settings_modules="<your.settings.module>"

Neovim

In your lspconfig add the following

require'lspconfig'.djlsp.setup{
    cmd = { "<path-to-djlsp>" },
    init_options = {
        djlsp = {
            django_settings_module = "<your.settings.module>"
            docker_compose_file = "docker-compose.yml",
            docker_compose_service = "django"
        }
    }
}

VSCode

To use the Django template LSP with VSCode read the following readme