@markdy/language-server 0.7.18 → 0.7.20

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.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +13 -6
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -8,6 +8,18 @@ Current capabilities:
8
8
  - hover docs for common actions
9
9
  - document symbols for scenes, actors, defs, and seqs
10
10
 
11
+ ## Visual guide
12
+
13
+ <p align="center">
14
+ <img src="https://raw.githubusercontent.com/HoangYell/markdy-com/main/website/public/images/markdy-tooling-map.webp" alt="Markdy tooling and editor support visual" width="900" />
15
+ </p>
16
+
17
+ ## Love Story result
18
+
19
+ <p align="center">
20
+ <img src="https://raw.githubusercontent.com/HoangYell/markdy-com/main/website/public/images/markdy-love-story-result.webp" alt="Love Story main Markdy result" width="900" />
21
+ </p>
22
+
11
23
  Run on stdio:
12
24
 
13
25
  ```sh
package/dist/index.js CHANGED
@@ -175,29 +175,33 @@ function buildSemanticTokenData(document) {
175
175
  for (let line = 0; line < lines.length; line++) {
176
176
  const content = lines[line];
177
177
  const head = content.trim();
178
+ const tokens = [];
178
179
  for (const keyword of KEYWORDS) {
179
- const idx = head.indexOf(keyword);
180
- if (idx === 0) {
180
+ if (head.startsWith(keyword) && !/\w/.test(head.charAt(keyword.length))) {
181
181
  const start = content.indexOf(keyword);
182
- if (start >= 0) pushSemanticToken(data, cursor, line, start, keyword.length, "keyword");
182
+ if (start >= 0) tokens.push({ char: start, length: keyword.length, type: "keyword" });
183
183
  }
184
184
  }
185
185
  for (const name of actors) {
186
186
  const match = new RegExp(`\\b${name}\\b`).exec(content);
187
187
  if (match?.index !== void 0) {
188
- pushSemanticToken(data, cursor, line, match.index, name.length, "variable");
188
+ tokens.push({ char: match.index, length: name.length, type: "variable" });
189
189
  }
190
190
  }
191
191
  const actionMatch = /\.\s*([A-Za-z_]\w*)\s*\(/.exec(content);
192
192
  if (actionMatch?.index !== void 0) {
193
193
  const actionName = actionMatch[1];
194
194
  const actionStart = actionMatch.index + actionMatch[0].indexOf(actionName);
195
- pushSemanticToken(data, cursor, line, actionStart, actionName.length, "method");
195
+ tokens.push({ char: actionStart, length: actionName.length, type: "method" });
196
196
  }
197
197
  const defMatch = /^def\s+([A-Za-z_]\w*)/.exec(head);
198
198
  if (defMatch) {
199
199
  const start = content.indexOf(defMatch[1]);
200
- if (start >= 0) pushSemanticToken(data, cursor, line, start, defMatch[1].length, "class");
200
+ if (start >= 0) tokens.push({ char: start, length: defMatch[1].length, type: "class" });
201
+ }
202
+ tokens.sort((a, b) => a.char - b.char);
203
+ for (const token of tokens) {
204
+ pushSemanticToken(data, cursor, line, token.char, token.length, token.type);
201
205
  }
202
206
  }
203
207
  return data;
@@ -277,6 +281,9 @@ connection.onInitialize((_params) => ({
277
281
  }));
278
282
  documents.onDidOpen((e) => validateTextDocument(e.document));
279
283
  documents.onDidChangeContent((e) => validateTextDocument(e.document));
284
+ documents.onDidClose((e) => {
285
+ connection.sendDiagnostics({ uri: e.document.uri, diagnostics: [] });
286
+ });
280
287
  connection.onCompletion((params) => {
281
288
  const doc = documents.get(params.textDocument.uri);
282
289
  if (!doc) return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markdy/language-server",
3
- "version": "0.7.18",
3
+ "version": "0.7.20",
4
4
  "description": "Language Server Protocol implementation for MarkdyScript.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "vscode-languageserver": "^9.0.1",
46
46
  "vscode-languageserver-textdocument": "^1.0.12",
47
- "@markdy/core": "0.7.18"
47
+ "@markdy/core": "0.7.20"
48
48
  },
49
49
  "devDependencies": {
50
50
  "tsup": "^8.5.1",