@astrojs/language-server 2.16.3 → 2.16.4

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/check.js CHANGED
@@ -125,7 +125,7 @@ class AstroCheck {
125
125
  (0, svelte_js_1.getSvelteLanguagePlugin)(),
126
126
  (0, vue_js_1.getVueLanguagePlugin)(),
127
127
  ];
128
- const services = [...(0, index_js_2.create)(this.ts), (0, astro_js_1.create)(this.ts)];
128
+ const services = [...(0, index_js_2.create)(this.ts), (0, astro_js_1.create)()];
129
129
  if (tsconfigPath) {
130
130
  const includeProjectReference = false; // #920
131
131
  this.linter = kit.createTypeScriptChecker(languagePlugins, services, tsconfigPath, includeProjectReference, ({ project }) => {
@@ -83,7 +83,7 @@ function preprocessHTML(text, frontmatterEnd) {
83
83
  }
84
84
  return content;
85
85
  function shouldBlankStartOrEndTagLike(offset) {
86
- // not null rather than falsy, otherwise it won't work on first tag(0)
86
+ // not null rather than falsy; otherwise, it won't work on first tag(0)
87
87
  return (currentStartTagStart !== null && (0, utils_1.isInsideExpression)(content, currentStartTagStart, offset));
88
88
  }
89
89
  function blankStartOrEndTagLike(offset, state) {
@@ -38,7 +38,7 @@ function getLanguageServicePlugins(connection, ts, collectionConfig, initializeP
38
38
  }),
39
39
  (0, volar_service_typescript_twoslash_queries_1.create)(ts),
40
40
  (0, index_js_2.create)(),
41
- (0, astro_js_1.create)(ts),
41
+ (0, astro_js_1.create)(),
42
42
  getPrettierService(),
43
43
  (0, yaml_js_1.create)(collectionConfig),
44
44
  ];
@@ -1,2 +1,2 @@
1
1
  import type { LanguageServicePlugin } from '@volar/language-server';
2
- export declare const create: (ts: typeof import("typescript")) => LanguageServicePlugin;
2
+ export declare const create: () => LanguageServicePlugin;
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.create = void 0;
4
- const node_path_1 = require("node:path");
5
4
  const language_server_1 = require("@volar/language-server");
6
- const tinyglobby_1 = require("tinyglobby");
7
5
  const vscode_uri_1 = require("vscode-uri");
8
6
  const index_js_1 = require("../core/index.js");
9
- const utils_js_1 = require("./utils.js");
10
- const create = (ts) => {
7
+ const create = () => {
11
8
  return {
12
9
  capabilities: {
13
10
  completionProvider: {
@@ -17,7 +14,6 @@ const create = (ts) => {
17
14
  interFileDependencies: false,
18
15
  workspaceDiagnostics: false,
19
16
  },
20
- codeLensProvider: {},
21
17
  },
22
18
  create(context) {
23
19
  return {
@@ -61,55 +57,11 @@ const create = (ts) => {
61
57
  };
62
58
  }
63
59
  },
64
- provideCodeLenses(document, token) {
65
- if (token.isCancellationRequested)
66
- return;
67
- if (!(0, utils_js_1.isJSDocument)(document.languageId))
68
- return;
69
- if (!context.project.typescript)
70
- return;
71
- const { uriConverter } = context.project.typescript;
72
- const languageService = context.inject('typescript/languageService');
73
- if (!languageService)
74
- return;
75
- const tsProgram = languageService.getProgram();
76
- if (!tsProgram)
77
- return;
78
- const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
79
- if (!decoded)
80
- return;
81
- const globcodeLens = [];
82
- const sourceFile = tsProgram.getSourceFile(decoded[0].fsPath);
83
- function walk() {
84
- return ts.forEachChild(sourceFile, function cb(node) {
85
- if (ts.isCallExpression(node) && node.expression.getText() === 'Astro.glob') {
86
- const globArgument = node.arguments.at(0);
87
- if (globArgument && decoded) {
88
- globcodeLens.push(getGlobResultAsCodeLens(globArgument.getText().slice(1, -1), (0, node_path_1.dirname)(uriConverter.asFileName(decoded[0])), document.positionAt(node.arguments.pos)));
89
- }
90
- }
91
- return ts.forEachChild(node, cb);
92
- });
93
- }
94
- walk();
95
- return globcodeLens;
96
- },
97
60
  };
98
61
  },
99
62
  };
100
63
  };
101
64
  exports.create = create;
102
- function getGlobResultAsCodeLens(globText, dir, position) {
103
- const globResult = (0, tinyglobby_1.globSync)(globText, {
104
- cwd: dir,
105
- onlyFiles: true,
106
- expandDirectories: false,
107
- });
108
- return {
109
- range: language_server_1.Range.create(position, position),
110
- command: { title: `Matches ${globResult.length} files`, command: '' },
111
- };
112
- }
113
65
  function getFrontmatterCompletion(file, document, position) {
114
66
  const base = {
115
67
  kind: language_server_1.CompletionItemKind.Snippet,
@@ -10,7 +10,7 @@ function mapEdit(edit, code, languageId) {
10
10
  }
11
11
  }
12
12
  else {
13
- // If the edit is at the start of the file, add a newline before it, otherwise we'll get `<script>text`
13
+ // If the edit is at the start of the file, add a newline before it; otherwise, we'll get `<script>text`
14
14
  if (edit.range.start.line === 0 && edit.range.start.character === 0) {
15
15
  edit.newText = '\n' + edit.newText;
16
16
  }
@@ -52,7 +52,7 @@ function getSnippetCompletions(frontmatter) {
52
52
  documentation: {
53
53
  kind: 'markdown',
54
54
  value: [
55
- 'Add prerender export. When [using server-side rendering](https://docs.astro.build/en/guides/on-demand-rendering/#enabling-on-demand-rendering), this value will be used to determine whether to prerender the page or not.',
55
+ 'Add prerender export. When [using server-side rendering](https://docs.astro.build/en/guides/on-demand-rendering/#enabling-on-demand-rendering), this value will be used to determine whether or not to prerender the page.',
56
56
  '\n',
57
57
  '[Astro reference](https://docs.astro.build/en/reference/routing-reference/#prerender)',
58
58
  ].join('\n'),
@@ -47,7 +47,7 @@ const create = (collectionConfig) => {
47
47
  const changedConfig = events.changes.some((change) => change.uri.endsWith('collections.json'));
48
48
  if (changedConfig) {
49
49
  collectionConfig.reload(
50
- // For some reason, context.env.workspaceFolders is not an array of WorkspaceFolders nor the older format, strange
50
+ // For some reason, context.env.workspaceFolders is neither an array of WorkspaceFolders nor the older format, strange
51
51
  context.env.workspaceFolders.map((folder) => ({ uri: folder.toString() })));
52
52
  languageService.configure(getSettings(collectionConfig));
53
53
  }
@@ -83,7 +83,7 @@ const create = (collectionConfig) => {
83
83
  diagnostic.source = 'astro';
84
84
  // In Astro, schema errors are always fatal
85
85
  diagnostic.severity = language_server_1.DiagnosticSeverity.Error;
86
- // Map missing properties to the entire frontmatte
86
+ // Map missing properties to the entire frontmatter
87
87
  if (diagnostic.message.startsWith('Missing property')) {
88
88
  diagnostic.range = language_server_1.Range.create({ line: 0, character: 0 }, document.positionAt(document.getText().length));
89
89
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@astrojs/language-server",
3
- "version": "2.16.3",
3
+ "version": "2.16.4",
4
4
  "author": "withastro",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/withastro/astro.git",
8
+ "url": "git+https://github.com/withastro/astro.git",
9
9
  "directory": "packages/language-tools/language-server"
10
10
  },
11
11
  "type": "commonjs",
@@ -20,13 +20,13 @@
20
20
  "astro-ls": "./bin/nodeServer.js"
21
21
  },
22
22
  "dependencies": {
23
- "@astrojs/compiler": "^2.13.0",
24
- "@astrojs/yaml2ts": "^0.2.2",
23
+ "@astrojs/compiler": "^2.13.1",
24
+ "@astrojs/yaml2ts": "^0.2.3",
25
25
  "@jridgewell/sourcemap-codec": "^1.5.5",
26
- "@volar/kit": "~2.4.27",
27
- "@volar/language-core": "~2.4.27",
28
- "@volar/language-server": "~2.4.27",
29
- "@volar/language-service": "~2.4.27",
26
+ "@volar/kit": "~2.4.28",
27
+ "@volar/language-core": "~2.4.28",
28
+ "@volar/language-server": "~2.4.28",
29
+ "@volar/language-service": "~2.4.28",
30
30
  "muggle-string": "^0.4.1",
31
31
  "tinyglobby": "^0.2.15",
32
32
  "volar-service-css": "0.0.68",
@@ -41,8 +41,8 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^20.9.0",
44
- "@volar/test-utils": "~2.4.27",
45
- "@volar/typescript": "~2.4.27",
44
+ "@volar/test-utils": "~2.4.28",
45
+ "@volar/typescript": "~2.4.28",
46
46
  "tsx": "^4.21.0",
47
47
  "typescript": "^5.9.3",
48
48
  "vscode-languageserver-protocol": "^3.17.5",
@@ -64,8 +64,7 @@
64
64
  "scripts": {
65
65
  "build": "tsc",
66
66
  "dev": "tsc --watch",
67
- "sync-fixture": "pnpm --dir ./test/fixture sync",
68
- "test": "pnpm sync-fixture && astro-scripts test \"**/*.test.ts\" --teardown-test ./test/misc/teardown.ts --tsx true",
67
+ "test": "astro-scripts test \"**/*.test.ts\" --teardown-test ./test/misc/teardown.ts --tsx true --setup ./test/setup.js",
69
68
  "test:match": "pnpm run test --match"
70
69
  }
71
70
  }
@@ -1,11 +0,0 @@
1
- import type { AttributeNode, Point } from '@astrojs/compiler';
2
- import { Position as LSPPosition } from '@volar/language-server';
3
- /**
4
- * Transform a Point from the Astro compiler to an LSP Position
5
- */
6
- export declare function PointToPosition(point: Point): LSPPosition;
7
- type WithRequired<T, K extends keyof T> = T & {
8
- [P in K]-?: T[P];
9
- };
10
- export type AttributeNodeWithPosition = WithRequired<AttributeNode, 'position'>;
11
- export {};
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PointToPosition = PointToPosition;
4
- const language_server_1 = require("@volar/language-server");
5
- /**
6
- * Transform a Point from the Astro compiler to an LSP Position
7
- */
8
- function PointToPosition(point) {
9
- // Columns and lines are 0-based in LSP, but the compiler's Point are 1 based.
10
- return language_server_1.Position.create(point.line - 1, point.column - 1);
11
- }
12
- //# sourceMappingURL=compilerUtils.js.map