Language Server Protocol implementation for hx-requests Django library
Project description
hx-requests-lsp
Language Server Protocol implementation for the hx-requests Django library.
Features
- Autocomplete: Get suggestions for hx_request names in Django templates (prioritizes current app, works with or without quotes)
- Go-to-Definition: Jump from template usage to the Python class definition
- Find References: Find all template usages of an hx_request
- Diagnostics: Warnings for undefined hx_request names
- Hover Information: View details about an hx_request on hover
Installation
VS Code (Recommended)
Install the hx-requests-lsp extension from the VS Code Marketplace. The extension bundles the language server - no additional setup required.
Other Editors
Install the language server via pip/pipx:
pip install hx-requests-lsp
# or
pipx install hx-requests-lsp
Neovim Configuration
Note:
hx-requests-lspis not yet in nvim-lspconfig's built-in server list, so you need to define it as a custom server.
Vanilla Neovim with nvim-lspconfig:
-- Define the custom server first
vim.lsp.config('hx_requests_lsp', {
cmd = { 'hx-requests-lsp', '--stdio' },
filetypes = { 'html', 'htmldjango', 'python' },
root_markers = { 'manage.py', '.git' },
})
-- Then enable it
vim.lsp.enable('hx_requests_lsp')
LazyVim:
Add this to your lua/plugins/lspconfig.lua:
return {
"neovim/nvim-lspconfig",
opts = function(_, opts)
-- Define the custom server
vim.lsp.config("hx_requests_lsp", {
cmd = { "hx-requests-lsp", "--stdio" },
filetypes = { "html", "htmldjango", "python" },
root_markers = { "manage.py", ".git" },
})
-- Add to server list
return vim.tbl_deep_extend("force", opts or {}, {
servers = {
hx_requests_lsp = {},
},
})
end,
}
NvChad / LunarVim / AstroNvim:
Add the vim.lsp.config() definition to your configuration file before setting up lspconfig, then add hx_requests_lsp = {} to your servers list.
Other Editors
Configure your editor to use hx-requests-lsp --stdio as the language server command for html, htmldjango, and python filetypes in Django projects (detected by manage.py in the root directory).
Usage
Once installed, the LSP provides these features in your editor:
| Feature | Description |
|---|---|
| Go to Definition | Jump to hx_request class from template usage |
| Find References | Find all template usages of an hx_request |
| Hover Info | View details about an hx_request on hover |
| Autocomplete | Get suggestions when typing {% hx_get or {% hx_post |
| Diagnostics | Warnings for undefined hx_request names |
Supported Patterns
Python (definitions)
from hx_requests.hx_requests import BaseHxRequest, ModalHxRequest
class MyRequest(BaseHxRequest):
name = "my_request" # This name is indexed
GET_template = "partials/my.html"
Templates (usages)
{% load hx_tags %}
<!-- hx_post with name as first argument -->
<button {% hx_post 'my_request' object=item %}>Click</button>
<!-- hx_get -->
<div {% hx_get 'another_request' %}>Load</div>
<!-- hx_vals with hx_request_name keyword -->
<div {% hx_vals hx_request_name='my_request' title='Modal' %}>Open</div>
Requirements
- Python 3.11+
Troubleshooting
Server not found
- Verify it's installed:
which hx-requests-lsp - Make sure you're in the correct virtualenv or used
pipxfor global install - For Neovim, check if the LSP is running with
:LspInfo
No autocompletion or diagnostics
- Ensure your template files are properly recognized by your editor
- Restart your editor to reload the extension
- Check that hx_request classes have a
nameattribute
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! See CONTRIBUTING.md for development setup instructions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hx_requests_lsp-1.2.2.tar.gz.
File metadata
- Download URL: hx_requests_lsp-1.2.2.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c41d5ce174485ce9a97ffcec35ce8dab2567be61623178747d67c5a53c00f4e8
|
|
| MD5 |
894cfcf9dbf92ebe65d72b1fbbcee3dd
|
|
| BLAKE2b-256 |
48fd0170b82fcddf2a850089e49b465ec0ee8b2407c1387935839599fec22b2f
|
Provenance
The following attestation bundles were made for hx_requests_lsp-1.2.2.tar.gz:
Publisher:
workflow.yml on jordannpenn/hx-requests-lsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hx_requests_lsp-1.2.2.tar.gz -
Subject digest:
c41d5ce174485ce9a97ffcec35ce8dab2567be61623178747d67c5a53c00f4e8 - Sigstore transparency entry: 957392691
- Sigstore integration time:
-
Permalink:
jordannpenn/hx-requests-lsp@e247437d715d53e0834e7ac31d05b16a40dfdcc4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jordannpenn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@e247437d715d53e0834e7ac31d05b16a40dfdcc4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hx_requests_lsp-1.2.2-py3-none-any.whl.
File metadata
- Download URL: hx_requests_lsp-1.2.2-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
028c893efd11206446a24af87681dd10ce9753467e7eb54c45b428f256b2416d
|
|
| MD5 |
8cd8c31c2c77111c0e7c6205659dedbb
|
|
| BLAKE2b-256 |
503c3e8c01a9205dd7685ee9f252825b3cf6f5a791914c1e6f5969232e35859c
|
Provenance
The following attestation bundles were made for hx_requests_lsp-1.2.2-py3-none-any.whl:
Publisher:
workflow.yml on jordannpenn/hx-requests-lsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hx_requests_lsp-1.2.2-py3-none-any.whl -
Subject digest:
028c893efd11206446a24af87681dd10ce9753467e7eb54c45b428f256b2416d - Sigstore transparency entry: 957392694
- Sigstore integration time:
-
Permalink:
jordannpenn/hx-requests-lsp@e247437d715d53e0834e7ac31d05b16a40dfdcc4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jordannpenn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@e247437d715d53e0834e7ac31d05b16a40dfdcc4 -
Trigger Event:
push
-
Statement type: