Skip to content

Commit

Permalink
Add djlspPath setting for vscode extension
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenhesselink committed Jun 12, 2024
1 parent ee92767 commit 92a81df
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Then, install the `djlsp` extension from the Visual Studio Code marketplace.
## Settings

Within the `settings.json` file, you can configure the following settings:
- `djangoTemplateLsp.djlspPath`: Path to the `djlsp` executable. Default: `~/.local/bin/djlsp`
- `djangoTemplateLsp.dockerComposeFile`: Docker Compose file name. Default: `docker-compose.yml`
- `djangoTemplateLsp.dockerServiceName`: Docker service name. Default: `django`
- `djangoTemplateLsp.djangoSettingsModule`: Django settings module. Default: ``
Expand Down
19 changes: 12 additions & 7 deletions vscode/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@ export function activate(context: ExtensionContext) {
return home ? filePath.replace('~', home) : filePath;
};

// Check if djlsp is installed
const djlspPaths = [
'~/.local/bin/djlsp',
'~/.local/pipx/venvs/django-template-lsp/bin/djlsp',
].map(expandHomeDir);
const configuration = workspace.getConfiguration('djangoTemplateLsp');

const djlspPaths = [];

const djlspPathConfig = configuration.get('djlspPath', false);

if (djlspPathConfig) {
djlspPaths.push(expandHomeDir(djlspPathConfig));
} else {
djlspPaths.push(expandHomeDir('~/.local/bin/djlsp'));
djlspPaths.push(expandHomeDir('~/.local/pipx/venvs/django-template-lsp/bin/djlsp'));
}

const djlspPath = djlspPaths.find(fs.existsSync);

Expand All @@ -31,8 +38,6 @@ export function activate(context: ExtensionContext) {
throw new Error('djlsp is not installed');
}

const configuration = workspace.getConfiguration('djangoTemplateLsp');

const djlspArgs = [];

if (configuration.get("enableLogging", false)) {
Expand Down
5 changes: 5 additions & 0 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"type": "object",
"title": "Django Template LSP",
"properties": {
"djangoTemplateLsp.djlspPath": {
"type": "string",
"default": "",
"description": "The path to the djlsp executable, by default it will search for djlsp in your .local directory"
},
"djangoTemplateLsp.dockerComposeFile": {
"type": "string",
"default": "docker-compose.yml",
Expand Down

0 comments on commit 92a81df

Please sign in to comment.