hx-requests-lsp VS Code Extension
VS Code extension that provides Language Server Protocol support 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 (Ctrl/Cmd + Click)
- 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
From VS Code Marketplace (Recommended)
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X)
- Search for "hx-requests-lsp"
- Click Install
The extension bundles the language server - no additional installation required.
From VSIX File
- Download the
.vsix file from Releases
- In VS Code, press
Ctrl+Shift+P
- Type "Install from VSIX" and select it
- Choose the downloaded
.vsix file
Usage
Once installed, the extension automatically activates for Django projects. Features work in HTML and Django template files:
| Feature |
How to Use |
| Go to Definition |
F12 or Ctrl+Click on an hx_request name |
| Find References |
Shift+F12 or right-click → "Find All References" |
| Hover Info |
Hover over an hx_request name |
| Autocomplete |
Type {% hx_get or {% hx_post (quotes optional) |
| Diagnostics |
Undefined hx_request names show warnings |
Configuration
| Setting |
Default |
Description |
hxRequestsLsp.enable |
true |
Enable/disable the language server |
hxRequestsLsp.serverPath |
"" |
Path to hx-requests-lsp executable (auto-detected if empty) |
hxRequestsLsp.pythonPath |
"" |
Path to Python interpreter (auto-detected if empty) |
hxRequestsLsp.trace.server |
"off" |
Trace communication with the server (off, messages, verbose) |
Server Discovery
The extension includes a bundled language server, but can also use an external installation. It looks for the server in this order:
- Configured
serverPath setting
- Bundled server (included with extension)
- Workspace virtual environment (
.venv/bin/hx-requests-lsp or venv/bin/hx-requests-lsp)
- Python module via configured/detected Python interpreter
- System PATH
Commands
- hx-requests: Restart hx-requests Language Server - Restart the language server
Dev Containers
To include this extension in your dev container, add it to your devcontainer.json:
{
"customizations": {
"vscode": {
"extensions": [
"jordanpenn.hx-requests-lsp"
]
}
}
}
Troubleshooting
Server not starting
Check the "hx-requests LSP" output channel for errors (View → Output → select "hx-requests LSP")
No completions
- Ensure your template files have the correct language mode (HTML or Django HTML)
- Check that your hx_request classes have a
name attribute
- Restart the language server:
Ctrl+Shift+P → "hx-requests: Restart hx-requests Language Server"
Wrong Python environment
Configure hxRequestsLsp.pythonPath in your workspace settings to point to the correct interpreter.
Development
Prerequisites
Setup
# Clone the repository
git clone https://github.com/jordannpenn/hx-requests-lsp-vscode-extension
cd hx-requests-lsp-vscode-extension
# Install dependencies
npm install
# Build the extension
npm run compile
# Package for distribution
npm run package
Testing Locally
- Open this folder in VS Code
- Press
F5 to launch a new VS Code window with the extension loaded
- Open a Django project to test the features
License
MIT License - see LICENSE file for details