@astrojs/language-server 0.29.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -48,10 +48,19 @@ function startLanguageServer(connection, env) {
48
48
  let typescriptPlugin = undefined;
49
49
  let hasConfigurationCapability = false;
50
50
  connection.onInitialize((params) => {
51
+ let isPnpInit = false;
52
+ const canRequirePnp = params.initializationOptions?.canRequirePnp ?? false;
51
53
  const environment = params.initializationOptions?.environment ?? 'node';
52
54
  const workspaceUris = params.workspaceFolders?.map((folder) => folder.uri.toString()) ?? [params.rootUri ?? ''];
53
55
  workspaceUris.forEach((uri) => {
54
56
  uri = (0, utils_2.urlToPath)(uri);
57
+ if (canRequirePnp && !isPnpInit) {
58
+ const possiblePnpPath = (0, utils_2.getWorkspacePnpPath)(uri);
59
+ if (possiblePnpPath) {
60
+ require(possiblePnpPath).setup();
61
+ isPnpInit = true;
62
+ }
63
+ }
55
64
  // If the workspace is not an Astro project, we shouldn't warn about not finding Astro
56
65
  // Unless the extension enabled itself in an untitled workspace, in which case the warning is valid
57
66
  if (!(0, utils_2.isAstroWorkspace)(uri) && uri !== '/' && uri !== '') {
package/dist/utils.d.ts CHANGED
@@ -79,3 +79,4 @@ export interface AstroInstall {
79
79
  };
80
80
  }
81
81
  export declare function getAstroInstall(basePaths: string[]): AstroInstall | undefined;
82
+ export declare function getWorkspacePnpPath(workspacePath: string): string | null;
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAstroInstall = exports.isAstroWorkspace = exports.debounceThrottle = exports.debounceSameArg = exports.getRegExpMatches = exports.regexLastIndexOf = exports.isBeforeOrEqualToPosition = exports.isInRange = exports.isNotNullOrUndefined = exports.clamp = exports.modifyLines = exports.toPascalCase = exports.mergeDeep = exports.get = exports.getLastPartOfPath = exports.pathToUrl = exports.urlToPath = exports.normalizePath = exports.normalizeUri = void 0;
3
+ exports.getWorkspacePnpPath = exports.getAstroInstall = exports.isAstroWorkspace = exports.debounceThrottle = exports.debounceSameArg = exports.getRegExpMatches = exports.regexLastIndexOf = exports.isBeforeOrEqualToPosition = exports.isInRange = exports.isNotNullOrUndefined = exports.clamp = exports.modifyLines = exports.toPascalCase = exports.mergeDeep = exports.get = exports.getLastPartOfPath = exports.pathToUrl = exports.urlToPath = exports.normalizePath = exports.normalizeUri = void 0;
4
4
  const path_1 = require("path");
5
5
  const vscode_uri_1 = require("vscode-uri");
6
6
  const importPackage_1 = require("./importPackage");
@@ -257,3 +257,14 @@ function getAstroInstall(basePaths) {
257
257
  };
258
258
  }
259
259
  exports.getAstroInstall = getAstroInstall;
260
+ function getWorkspacePnpPath(workspacePath) {
261
+ try {
262
+ const possiblePath = (0, path_1.resolve)(workspacePath, '.pnp.cjs');
263
+ require.resolve(possiblePath);
264
+ return possiblePath;
265
+ }
266
+ catch {
267
+ return null;
268
+ }
269
+ }
270
+ exports.getWorkspacePnpPath = getWorkspacePnpPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/language-server",
3
- "version": "0.29.8",
3
+ "version": "1.0.0",
4
4
  "author": "withastro",
5
5
  "license": "MIT",
6
6
  "repository": {