Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] yarn berry support (#370) #371

Merged
merged 3 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/healthy-parents-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro-vscode': patch
---

Added settings to configure the path to the language server and the runtime to use to run it
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-this-alias': 'off',
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'prefer-const': 'off',
Expand Down
12 changes: 12 additions & 0 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@
"type": "object",
"title": "Astro configuration",
"properties": {
"astro.language-server.ls-path": {
"scope": "application",
"type": "string",
"title": "Language Server: Path",
"description": "Path to the language server executable. You won't need this in most cases, set this only when needing a specific version of the language server"
},
"astro.language-server.runtime": {
"scope": "application",
"type": "string",
"title": "Language Server: Runtime",
"description": "Path to the node executable used to execute the language server. You won't need this in most cases"
},
"astro.trace.server": {
"scope": "window",
"type": "string",
Expand Down
23 changes: 22 additions & 1 deletion packages/vscode/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as path from 'path';
import {
window,
commands,
Expand All @@ -23,7 +24,20 @@ const TagCloseRequest: RequestType<TextDocumentPositionParams, string, any> = ne
let client: LanguageClient;

export async function activate(context: ExtensionContext) {
const serverModule = require.resolve('@astrojs/language-server/bin/nodeServer.js');
const runtimeConfig = workspace.getConfiguration('astro.language-server');

const { workspaceFolders } = workspace;
const rootPath = workspaceFolders?.[0].uri.fsPath;

let lsPath = runtimeConfig.get<string>('ls-path');
if (typeof lsPath === 'string' && lsPath.trim() !== '' && typeof rootPath === 'string') {
lsPath = path.isAbsolute(lsPath) ? lsPath : path.join(rootPath, lsPath);
console.info(`Using language server at ${lsPath}`);
} else {
lsPath = undefined;
}

const serverModule = require.resolve(lsPath ?? '@astrojs/language-server/bin/nodeServer.js');

const port = 6040;
const debugOptions = { execArgv: ['--nolazy', '--inspect=' + port] };
Expand All @@ -37,6 +51,13 @@ export async function activate(context: ExtensionContext) {
},
};

const serverRuntime = runtimeConfig.get<string>('runtime');
if (serverRuntime) {
serverOptions.run.runtime = serverRuntime;
serverOptions.debug.runtime = serverRuntime;
console.info(`Using ${serverRuntime} as runtime`);
}

const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'astro' }],
synchronize: {
Expand Down