yuhwa 1.1.0 → 1.2.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/astro.d.ts +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/cli.js +11 -6
- package/dist/editor/assets/index-BphHLTvA.js +689 -0
- package/dist/editor/assets/lsp.worker-sZtzIA6-.js +30 -0
- package/dist/editor/index.html +1 -1
- package/dist/{figure-db587hh6.d.ts → figure-CA2hy0xh.d.ts} +1 -1
- package/dist/{index-CAO4FUcz.d.ts → index-CnnoZYl0.d.ts} +29 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/ironmark.d.ts +1 -1
- package/dist/ironmark.js +1 -1
- package/dist/llms.txt +15 -10
- package/dist/lsp-browser.d.ts +2 -2
- package/dist/lsp-browser.js +1 -1
- package/dist/lsp-node.js +169 -31
- package/dist/lsp-server.d.ts +1 -1
- package/dist/lsp-server.js +1 -1
- package/dist/lsp.d.ts +44 -2
- package/dist/lsp.js +1 -1
- package/dist/markdown-it.d.ts +1 -1
- package/dist/markdown-it.js +1 -1
- package/dist/{node-DPojgovD.js → node-Bzn2uKXZ.js} +3 -3
- package/dist/remark.d.ts +1 -1
- package/dist/remark.js +1 -1
- package/dist/{server-BSHSx8uo.d.ts → server--jHjJjOS.d.ts} +1 -1
- package/dist/{server-CT_mbBNZ.js → server-Dxo7OG8K.js} +19 -2
- package/dist/{service-CNM6Z-RH.js → service-B1fpOg_L.js} +268 -29
- package/dist/{service-DquYYTVG.d.ts → service-Brvpt7Do.d.ts} +2 -0
- package/dist/{shared-B2rP00uA.js → shared-Ddw88O9D.js} +881 -417
- package/dist/{src-hrqH-a8K.js → src-DkQj7aIV.js} +855 -444
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +2 -2
- package/dist/vuepress.d.ts +1 -1
- package/dist/yuhwa.iife.js +63 -72
- package/package.json +1 -1
- package/dist/editor/assets/index-BGtCSg84.js +0 -689
- package/dist/editor/assets/lsp.worker-DUpBJRU2.js +0 -26
package/dist/lsp-node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
+
import { A as PLACEMENT_PROPS, B as themeNames, C as COLORS, D as NODE_PROPS, E as GROUP_PROPS, F as spanKey, I as THEME_KEYS, M as SPAN_KEYS, O as NUMBERS, P as parseSpanStyle, R as TONES, S as BOOLS, T as ENUMS, V as table, a as onTypeEdits, b as parse, d as optionKind, g as blockBraces, h as SETTING_VALUES, i as format, j as SHAPES, k as PANEL_PROPS, m as PANELS, n as applyChange, o as tidy, p as KNOWN_SETTINGS, r as diffEdits, s as diskResolve, t as VERSION, v as joinPath, w as EDGE_PROPS, x as serializeProps, y as lex } from "./shared-Ddw88O9D.js";
|
|
3
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
-
import { A as THEME_KEYS, C as ENUMS, D as PANEL_PROPS, E as NUMBERS, M as TONES, O as SHAPES, P as themeNames, S as EDGE_PROPS, T as NODE_PROPS, _ as joinPath, a as tidy, b as serializeProps, f as KNOWN_SETTINGS, h as blockBraces, i as format, m as SETTING_VALUES, n as applyChange, o as diskResolve, p as PANELS, r as diffEdits, t as VERSION, u as optionKind, v as lex, w as GROUP_PROPS, x as BOOLS, y as parse } from "./shared-B2rP00uA.js";
|
|
5
5
|
// \0rolldown/runtime.js
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -10710,15 +10710,6 @@ const HEAD_KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
10710
10710
|
]);
|
|
10711
10711
|
/** `tone` is the old name of `color`: still read, never offered */
|
|
10712
10712
|
const DEPRECATED_PROPS = /* @__PURE__ */ new Set(["tone"]);
|
|
10713
|
-
const COLOR_PROPS = /* @__PURE__ */ new Set([
|
|
10714
|
-
"fill",
|
|
10715
|
-
"stroke",
|
|
10716
|
-
"color",
|
|
10717
|
-
"text",
|
|
10718
|
-
"sub-color",
|
|
10719
|
-
"label-color",
|
|
10720
|
-
"label-bg"
|
|
10721
|
-
]);
|
|
10722
10713
|
const SIDES = [
|
|
10723
10714
|
"top",
|
|
10724
10715
|
"right",
|
|
@@ -10726,13 +10717,13 @@ const SIDES = [
|
|
|
10726
10717
|
"left",
|
|
10727
10718
|
"auto"
|
|
10728
10719
|
];
|
|
10729
|
-
const ARROWS = {
|
|
10720
|
+
const ARROWS = table({
|
|
10730
10721
|
"-": "solid line",
|
|
10731
10722
|
"--": "dashed line",
|
|
10732
10723
|
"..": "dotted line",
|
|
10733
10724
|
"=": "thick line",
|
|
10734
10725
|
"==": "thick line"
|
|
10735
|
-
};
|
|
10726
|
+
});
|
|
10736
10727
|
const ALL_PROPS = [.../* @__PURE__ */ new Set([
|
|
10737
10728
|
...NODE_PROPS,
|
|
10738
10729
|
...EDGE_PROPS,
|
|
@@ -10762,6 +10753,9 @@ const NAME_TYPE = {
|
|
|
10762
10753
|
panel: "type",
|
|
10763
10754
|
class: "class"
|
|
10764
10755
|
};
|
|
10756
|
+
/** props whose value is the id of the node placed against */
|
|
10757
|
+
const PLACEMENT = new Set(PLACEMENT_PROPS.filter((p) => p !== "rank"));
|
|
10758
|
+
const PLACED = new RegExp(`(?:^\\[|[,;])\\s*(${[...PLACEMENT].join("|")})\\s*:\\s*([\\p{L}_][\\p{L}\\p{N}_-]*)(?=\\s*(?:[,;\\]]|$))`, "gu");
|
|
10765
10759
|
const LAYOUT_WORDS = /* @__PURE__ */ new Set([
|
|
10766
10760
|
"at",
|
|
10767
10761
|
"size",
|
|
@@ -10785,6 +10779,8 @@ const range = (line, start, end) => ({
|
|
|
10785
10779
|
end: pos(line, end)
|
|
10786
10780
|
});
|
|
10787
10781
|
const keyOf = (t) => t.kind === "class" ? "." + t.value : t.value;
|
|
10782
|
+
/** a statement's tokens without a leading `export` */
|
|
10783
|
+
const unexported = (t) => t[0]?.value === "export" && t[0].kind === "ident" && t.length > 1 ? t.slice(1) : t;
|
|
10788
10784
|
const isKeywordHead = (t) => t[0].kind === "ident" && (HEAD_KEYWORDS.has(t[0].value) || PANELS.has(t[0].value) && t[t.length - 1].value === "{") && !!t[1] && t[1].kind !== "arrow" && t[1].value !== ":" && t[1].value !== ",";
|
|
10789
10785
|
function settingValues(key, d) {
|
|
10790
10786
|
if (key === "theme") return themeNames(d?.themes);
|
|
@@ -10820,21 +10816,82 @@ function propValues(key, panel, d) {
|
|
|
10820
10816
|
if (panel && key === "frame") return ["false"];
|
|
10821
10817
|
if (panel && key === "theme") return themeNames(d?.themes);
|
|
10822
10818
|
if (panel && key === "border") return ["none", ...TONES];
|
|
10823
|
-
if (panel && (key === "background" || key === "fill" || key === "stroke")) return TONES;
|
|
10824
10819
|
if (ENUMS[key]) return ENUMS[key];
|
|
10825
10820
|
if (BOOLS.includes(key)) return ["true", "false"];
|
|
10826
|
-
if (
|
|
10821
|
+
if (COLORS.includes(key)) return TONES;
|
|
10827
10822
|
return [];
|
|
10828
10823
|
}
|
|
10829
|
-
|
|
10824
|
+
/** The open span spec (`{size: 18, red`) the cursor is typing, if any. */
|
|
10825
|
+
function openSpan(before) {
|
|
10826
|
+
const m = before.match(/\{([^{}|"\n]*)$/);
|
|
10827
|
+
return m && /^[\w\s,:#.()%-]*$/.test(m[1]) ? m[1] : void 0;
|
|
10828
|
+
}
|
|
10829
|
+
/** The span spec (`{…|`) whose keys cover column `ch`, with its offset. */
|
|
10830
|
+
function spanAt(line, ch) {
|
|
10831
|
+
for (const m of line.matchAll(/\{([^{}|\n]+?)[ ]?\|/g)) {
|
|
10832
|
+
const at = m.index + 1;
|
|
10833
|
+
if (ch >= at && ch <= at + m[1].length && parseSpanStyle(m[1])) return {
|
|
10834
|
+
spec: m[1],
|
|
10835
|
+
at
|
|
10836
|
+
};
|
|
10837
|
+
}
|
|
10838
|
+
}
|
|
10839
|
+
function propInfo(key, panel) {
|
|
10840
|
+
const opt = panel ? PANELS.get(panel)?.options?.[key] : void 0;
|
|
10841
|
+
if (opt !== void 0) {
|
|
10842
|
+
const o = optionKind(opt);
|
|
10843
|
+
if (o.kind === "select") return `one of: ${o.values.join(", ")}`;
|
|
10844
|
+
if (o.kind === "flag") return "true or false";
|
|
10845
|
+
if (o.kind === "number") return "a number";
|
|
10846
|
+
if (o.kind === "color") return "a palette name or any CSS colour (#hex, rgb(), hsl())";
|
|
10847
|
+
return "text";
|
|
10848
|
+
}
|
|
10849
|
+
if (panel && key === "frame") return "`false` drops the box";
|
|
10850
|
+
if (panel && key === "theme") return "a theme name";
|
|
10851
|
+
if (panel && key === "border") return "`none`, a palette name or any CSS colour";
|
|
10830
10852
|
const values = propValues(key);
|
|
10831
10853
|
if (BOOLS.includes(key)) return "true or false";
|
|
10832
10854
|
if (NUMBERS.includes(key)) return "a number";
|
|
10833
10855
|
if (ENUMS[key]) return `one of: ${values.join(", ")}`;
|
|
10834
10856
|
if (DEPRECATED_PROPS.has(key)) return "old name of `color`";
|
|
10835
|
-
if (
|
|
10857
|
+
if (COLORS.includes(key)) return "a palette name or any CSS colour (#hex, rgb(), hsl())";
|
|
10836
10858
|
return "text";
|
|
10837
10859
|
}
|
|
10860
|
+
/**
|
|
10861
|
+
* The declaration that `line` is indented under, whose props its `key: value`
|
|
10862
|
+
* lines set (as `parse` does), or -1.
|
|
10863
|
+
*/
|
|
10864
|
+
function declAbove(a, line) {
|
|
10865
|
+
const indent = (l) => a.lines[l].match(/^\s*/)[0].length;
|
|
10866
|
+
for (let l = line - 1; l >= 0; l--) {
|
|
10867
|
+
const t = a.toks[l];
|
|
10868
|
+
if (!t.length || t[0].kind === "ident" && t[1]?.value === ":") continue;
|
|
10869
|
+
return t[0].value !== "}" && indent(l) < indent(line) ? l : -1;
|
|
10870
|
+
}
|
|
10871
|
+
return -1;
|
|
10872
|
+
}
|
|
10873
|
+
/** Props an indented line under the declaration on `line` can set. */
|
|
10874
|
+
function declProps(a, line) {
|
|
10875
|
+
const t = unexported(a.toks[line]);
|
|
10876
|
+
if (t[0].kind === "class") return ALL_PROPS;
|
|
10877
|
+
if (t[0].value === "group") return GROUP_PROPS;
|
|
10878
|
+
return t.some((x) => x.kind === "arrow") ? EDGE_PROPS : NODE_PROPS;
|
|
10879
|
+
}
|
|
10880
|
+
/**
|
|
10881
|
+
* Where a name quoted in a diagnostic sits on its line: a whole word, so `shap`
|
|
10882
|
+
* is not found inside `shape`, and with `props` the one inside `[...]`, so the
|
|
10883
|
+
* value in `red [shape: red]` wins over the node id.
|
|
10884
|
+
*/
|
|
10885
|
+
function findQuoted(code, q, props) {
|
|
10886
|
+
const re = new RegExp(`(?<![\\w-])${q.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w-])`, "g");
|
|
10887
|
+
let first = -1;
|
|
10888
|
+
for (const m of code.matchAll(re)) {
|
|
10889
|
+
const depth = [...code.slice(0, m.index)].reduce((n, c) => n + (c === "[" ? 1 : c === "]" ? -1 : 0), 0);
|
|
10890
|
+
if (props && depth > 0) return m.index;
|
|
10891
|
+
if (first < 0) first = m.index;
|
|
10892
|
+
}
|
|
10893
|
+
return first >= 0 ? first : code.indexOf(q);
|
|
10894
|
+
}
|
|
10838
10895
|
/** relative import path from one file to another */
|
|
10839
10896
|
function relPath(from, to) {
|
|
10840
10897
|
const a = (from ?? "").split("/").slice(0, -1);
|
|
@@ -10862,7 +10919,7 @@ var YuhwaService = class {
|
|
|
10862
10919
|
file,
|
|
10863
10920
|
resolve: this.opts.resolve
|
|
10864
10921
|
});
|
|
10865
|
-
const lines = text.split(
|
|
10922
|
+
const lines = text.split(/\r?\n/);
|
|
10866
10923
|
const opaque = lines.map(() => false);
|
|
10867
10924
|
const body = (r) => {
|
|
10868
10925
|
if (r) for (let i = r[0] + 1; i < r[1]; i++) opaque[i] = true;
|
|
@@ -10915,12 +10972,26 @@ var YuhwaService = class {
|
|
|
10915
10972
|
else if (x.kind === "punct" && x.value === ":" && arrow) ids = false;
|
|
10916
10973
|
if (x.kind === "class") add(li, x);
|
|
10917
10974
|
else if (ids && known(x) && !(k === 0 && skipHead)) add(li, x);
|
|
10975
|
+
else if (x.kind === "props") {
|
|
10976
|
+
const bare = lines[li].slice(x.start, x.end).replace(/(["'])(?:\\.|(?!\1).)*\1?/g, (q) => " ".repeat(q.length));
|
|
10977
|
+
for (const m of bare.matchAll(PLACED)) {
|
|
10978
|
+
const start = x.start + m.index + m[0].length - m[2].length;
|
|
10979
|
+
if (kinds.get(m[2]) === "node") occ.push({
|
|
10980
|
+
key: m[2],
|
|
10981
|
+
line: li,
|
|
10982
|
+
start,
|
|
10983
|
+
end: start + m[2].length
|
|
10984
|
+
});
|
|
10985
|
+
}
|
|
10986
|
+
}
|
|
10918
10987
|
}
|
|
10988
|
+
if (PLACEMENT.has(head) && t[1]?.value === ":" && known(t[2]) && t.length === 3) add(li, t[2]);
|
|
10919
10989
|
}
|
|
10920
10990
|
const decl = /* @__PURE__ */ new Map();
|
|
10991
|
+
const first = /* @__PURE__ */ new Map();
|
|
10992
|
+
for (const x of occ) if (!first.has(`${x.line}\0${x.key}`)) first.set(`${x.line}\0${x.key}`, x);
|
|
10921
10993
|
const declare = (key, line) => {
|
|
10922
|
-
|
|
10923
|
-
const o = occ.find((x) => x.key === key && x.line === line);
|
|
10994
|
+
const o = line === void 0 ? void 0 : first.get(`${line}\0${key}`);
|
|
10924
10995
|
if (o) decl.set(key, o);
|
|
10925
10996
|
};
|
|
10926
10997
|
for (const n of diagram.nodes.values()) declare(n.id, declLine(n));
|
|
@@ -10979,13 +11050,13 @@ var YuhwaService = class {
|
|
|
10979
11050
|
const start = Math.max(0, line.search(/\S/));
|
|
10980
11051
|
const end = Math.max(start, line.slice(0, codeEnd).trimEnd().length);
|
|
10981
11052
|
const quoted = /^\S+\.(yu|yuhwa):\d+:/i.test(message) ? void 0 : message.match(/"([^"\n]+)"/)?.[1];
|
|
10982
|
-
const at = quoted ? line.
|
|
10983
|
-
return at >= 0
|
|
11053
|
+
const at = quoted ? findQuoted(line.slice(0, codeEnd), quoted, /prop|unknown|expects|did you mean/i.test(message)) : -1;
|
|
11054
|
+
return at >= 0 ? range(li, at, at + quoted.length) : range(li, start, end);
|
|
10984
11055
|
}
|
|
10985
11056
|
/** Quick fixes: apply a diagnostic's `did you mean "…"` suggestion. */
|
|
10986
11057
|
fixes(text, diagnostics) {
|
|
10987
11058
|
const out = [];
|
|
10988
|
-
const lines = text.split(
|
|
11059
|
+
const lines = text.split(/\r?\n/);
|
|
10989
11060
|
for (const d of diagnostics) {
|
|
10990
11061
|
const m = (typeof d.message === "string" ? d.message : d.message.value).match(/"([^"\n]+)".*\(did you mean "([^"\n]+)"\?\)/);
|
|
10991
11062
|
if (!m) continue;
|
|
@@ -11024,8 +11095,21 @@ var YuhwaService = class {
|
|
|
11024
11095
|
const themeKeyItems = () => Object.entries(THEME_KEYS).map(([k, { info }]) => item(k, ITEM.Property, info, `${k}: `));
|
|
11025
11096
|
const nodes = () => [...d.nodes.values()].map((n) => item(n.id, ITEM.Variable, n.label !== n.id ? n.label : void 0));
|
|
11026
11097
|
const ends = () => [...nodes(), ...d.panels.map((x) => item(x.id, ITEM.Module, x.kind))];
|
|
11027
|
-
if (a.opaque[p.line]) return [];
|
|
11028
11098
|
const toks = lex(line).tokens;
|
|
11099
|
+
const spec = openSpan(before);
|
|
11100
|
+
const brace = before.length - (spec?.length ?? 0) - 1;
|
|
11101
|
+
const inString = toks.some((t) => t.kind === "string" && t.start < brace && brace < t.end);
|
|
11102
|
+
if (spec !== void 0 && (inString || a.opaque[p.line])) {
|
|
11103
|
+
const seg = spec.split(",").pop();
|
|
11104
|
+
const colon = seg.indexOf(":");
|
|
11105
|
+
if (colon >= 0) {
|
|
11106
|
+
const key = seg.slice(0, colon).trim().toLowerCase();
|
|
11107
|
+
const k = spanKey(key);
|
|
11108
|
+
return values(k ? SPAN_KEYS[k].values : []);
|
|
11109
|
+
}
|
|
11110
|
+
return Object.entries(SPAN_KEYS).map(([k, { info, flag }]) => item(k, ITEM.Property, info, flag ? k : `${k}: `));
|
|
11111
|
+
}
|
|
11112
|
+
if (a.opaque[p.line]) return [];
|
|
11029
11113
|
const tok = toks.find((t) => t.start < p.character && p.character < t.end);
|
|
11030
11114
|
const open = toks.find((t) => (t.kind === "props" || t.kind === "string") && t.start < p.character && p.character === t.end && t.end === line.length);
|
|
11031
11115
|
const inside = tok ?? (open && !/["'\]]$/.test(line.slice(open.start + 1)) ? open : void 0);
|
|
@@ -11052,14 +11136,15 @@ var YuhwaService = class {
|
|
|
11052
11136
|
}
|
|
11053
11137
|
if (kind === "theme") return themeKeyItems();
|
|
11054
11138
|
const keys = kind === "edge" ? EDGE_PROPS : kind === "group" ? GROUP_PROPS : kind === "class" ? ALL_PROPS : kind.startsWith("panel:") ? [...Object.keys(PANELS.get(kind.slice(6))?.options ?? {}), ...PANEL_PROPS] : NODE_PROPS;
|
|
11055
|
-
|
|
11139
|
+
const panel = kind.startsWith("panel:") ? kind.slice(6) : void 0;
|
|
11140
|
+
return [...new Set(keys)].filter((k) => !DEPRECATED_PROPS.has(k)).map((k) => item(k, ITEM.Property, propInfo(k, panel), `${k}: `));
|
|
11056
11141
|
}
|
|
11057
11142
|
if (inside) return [];
|
|
11058
11143
|
if (/(^|[\s,:])\.$/.test(before.slice(0, wordStart))) return Object.entries(d.classes).map(([c, props]) => item(c, ITEM.Class, serializeProps(props) || void 0));
|
|
11059
11144
|
const kv = before.match(/^(\s*)(?:export\s+)?([\w-]+)\s*:\s*[\p{L}\p{N}_-]*$/u);
|
|
11060
11145
|
if (kv && !toks.some((t) => t.kind === "arrow")) {
|
|
11061
11146
|
const key = kv[2].toLowerCase();
|
|
11062
|
-
if (
|
|
11147
|
+
if (a.depth[p.line] === 0 && declAbove(a, p.line) < 0) return values(settingValues(key, d));
|
|
11063
11148
|
if (inThemeBlock(a, p.line)) return values(themeValues(key, d));
|
|
11064
11149
|
return values(propValues(key, void 0, d));
|
|
11065
11150
|
}
|
|
@@ -11085,7 +11170,10 @@ var YuhwaService = class {
|
|
|
11085
11170
|
if (lineStart && inThemeBlock(a, p.line)) return themeKeyItems();
|
|
11086
11171
|
if (lineStart) {
|
|
11087
11172
|
const out = ends();
|
|
11088
|
-
|
|
11173
|
+
const decl = a.depth[p.line] === 0 ? declAbove(a, p.line) : -1;
|
|
11174
|
+
if (decl >= 0) {
|
|
11175
|
+
for (const k of new Set(declProps(a, decl))) if (!DEPRECATED_PROPS.has(k)) out.push(item(k, ITEM.Property, propInfo(k), `${k}: `));
|
|
11176
|
+
} else if (a.depth[p.line] === 0) {
|
|
11089
11177
|
out.push(...[...KNOWN_SETTINGS].map((k) => item(k, ITEM.Property, "setting", `${k}: `)));
|
|
11090
11178
|
for (const k of HEAD_KEYWORDS) out.push(item(k, ITEM.Keyword));
|
|
11091
11179
|
for (const [k, kind] of PANELS) out.push(item(k, ITEM.Module, kind.syntax ?? "panel"));
|
|
@@ -11104,6 +11192,7 @@ var YuhwaService = class {
|
|
|
11104
11192
|
}
|
|
11105
11193
|
/** what a `[...]` block on this line styles */
|
|
11106
11194
|
statementKind(toks, props) {
|
|
11195
|
+
toks = unexported(toks);
|
|
11107
11196
|
const head = toks[0];
|
|
11108
11197
|
if (head.kind === "class") return "class";
|
|
11109
11198
|
if (head.value === "group") return "group";
|
|
@@ -11153,6 +11242,16 @@ var YuhwaService = class {
|
|
|
11153
11242
|
}
|
|
11154
11243
|
return md(`**class** \`${name}\` is not defined`, o);
|
|
11155
11244
|
}
|
|
11245
|
+
const span = spanAt(a.lines[p.line] ?? "", p.character);
|
|
11246
|
+
if (span) {
|
|
11247
|
+
const st = parseSpanStyle(span.spec);
|
|
11248
|
+
const parts = Object.entries(st).map(([k, v]) => `${k}: ${v}`);
|
|
11249
|
+
const keys = Object.entries(SPAN_KEYS).map(([k, { info }]) => `- \`${k}\`: ${info}`).join("\n");
|
|
11250
|
+
return md(`**style span** \`${parts.join(", ")}\`\n\nstyles the text after \`|\`. Keys:\n\n${keys}`, {
|
|
11251
|
+
start: span.at,
|
|
11252
|
+
end: span.at + span.spec.length
|
|
11253
|
+
});
|
|
11254
|
+
}
|
|
11156
11255
|
const t = this.tokAt(a, p);
|
|
11157
11256
|
if (!t) return null;
|
|
11158
11257
|
if (t.kind === "class") return md(`**class** \`.${t.value}\` is not defined`, t);
|
|
@@ -11163,7 +11262,7 @@ var YuhwaService = class {
|
|
|
11163
11262
|
return md(`**edge** \`${t.value}\`: ${ARROWS[m[2]]}, ${heads}`, t);
|
|
11164
11263
|
}
|
|
11165
11264
|
const toks = a.toks[p.line];
|
|
11166
|
-
if (t === toks[0] && t.kind === "ident" && toks[1]?.value === ":" && a.depth[p.line] === 0) {
|
|
11265
|
+
if (t === toks[0] && t.kind === "ident" && toks[1]?.value === ":" && a.depth[p.line] === 0 && declAbove(a, p.line) < 0) {
|
|
11167
11266
|
const key = t.value.toLowerCase();
|
|
11168
11267
|
if (!KNOWN_SETTINGS.has(key)) return null;
|
|
11169
11268
|
const vs = settingValues(key, a.diagram);
|
|
@@ -11179,7 +11278,10 @@ var YuhwaService = class {
|
|
|
11179
11278
|
if (p.character < at || p.character > at + part.length) continue;
|
|
11180
11279
|
const key = part.split(":")[0].trim().toLowerCase();
|
|
11181
11280
|
const start = at + part.indexOf(part.trim());
|
|
11182
|
-
|
|
11281
|
+
const kind = this.statementKind(toks, t);
|
|
11282
|
+
const panel = kind.startsWith("panel:") ? kind.slice(6) : void 0;
|
|
11283
|
+
const known = panel ? key in (PANELS.get(panel)?.options ?? {}) || PANEL_PROPS.includes(key) : ALL_PROPS.includes(key);
|
|
11284
|
+
return key && known ? md(`**prop** \`${key}\`: ${propInfo(key, panel)}`, {
|
|
11183
11285
|
start,
|
|
11184
11286
|
end: start + key.length
|
|
11185
11287
|
}) : null;
|
|
@@ -11349,6 +11451,7 @@ var YuhwaService = class {
|
|
|
11349
11451
|
const name = isClass && !newName.startsWith(".") ? "." + newName : newName;
|
|
11350
11452
|
const t = lex(name).tokens;
|
|
11351
11453
|
if (t.length !== 1 || t[0].end !== name.length || t[0].kind !== (isClass ? "class" : "ident") || name[0] === "$") return { error: `"${newName}" is not a valid ${isClass ? "class name" : "id"}` };
|
|
11454
|
+
if (HEAD_KEYWORDS.has(name) || PANELS.has(name)) return { error: `"${name}" is a keyword` };
|
|
11352
11455
|
if (name !== o.key && a.kinds.has(name)) return { error: `"${name}" already exists` };
|
|
11353
11456
|
return a.occ.filter((x) => x.key === o.key).map((x) => ({
|
|
11354
11457
|
range: range(x.line, x.start, x.end),
|
|
@@ -11432,6 +11535,10 @@ var YuhwaService = class {
|
|
|
11432
11535
|
format(text) {
|
|
11433
11536
|
return diffEdits(text, format(text));
|
|
11434
11537
|
}
|
|
11538
|
+
/** Re-indent after a newline or `}` was typed at `pos`. */
|
|
11539
|
+
onType(text, pos, ch) {
|
|
11540
|
+
return onTypeEdits(text, pos, ch);
|
|
11541
|
+
}
|
|
11435
11542
|
folding(text, file) {
|
|
11436
11543
|
const a = this.analyze(text, file);
|
|
11437
11544
|
const out = a.blocks.filter(([s, e]) => e - 1 > s).map(([s, e]) => ({
|
|
@@ -11465,6 +11572,7 @@ var YuhwaService = class {
|
|
|
11465
11572
|
* pushed (`publishDiagnostics`) to the rest, never both.
|
|
11466
11573
|
*/
|
|
11467
11574
|
const REQUEST_FAILED = -32803;
|
|
11575
|
+
const DEBOUNCE_MS = 150;
|
|
11468
11576
|
const defaultToPath = (uri) => {
|
|
11469
11577
|
try {
|
|
11470
11578
|
return decodeURIComponent(new URL(uri).pathname);
|
|
@@ -11486,7 +11594,9 @@ function startServer(connection, opts = {}) {
|
|
|
11486
11594
|
const text = (uri) => docs.get(toPath(uri)) ?? "";
|
|
11487
11595
|
let pull = false;
|
|
11488
11596
|
let refresh = false;
|
|
11489
|
-
|
|
11597
|
+
let watch = false;
|
|
11598
|
+
const publish = () => {
|
|
11599
|
+
timer = void 0;
|
|
11490
11600
|
if (pull) {
|
|
11491
11601
|
if (refresh) connection.languages.diagnostics.refresh().catch(() => {});
|
|
11492
11602
|
return;
|
|
@@ -11496,6 +11606,11 @@ function startServer(connection, opts = {}) {
|
|
|
11496
11606
|
diagnostics: service.diagnostics(src, path)
|
|
11497
11607
|
});
|
|
11498
11608
|
};
|
|
11609
|
+
let timer;
|
|
11610
|
+
const validate = () => {
|
|
11611
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
11612
|
+
timer = setTimeout(publish, DEBOUNCE_MS);
|
|
11613
|
+
};
|
|
11499
11614
|
const changed = (uri, src) => {
|
|
11500
11615
|
const path = toPath(uri);
|
|
11501
11616
|
if (src === void 0) {
|
|
@@ -11515,6 +11630,7 @@ function startServer(connection, opts = {}) {
|
|
|
11515
11630
|
connection.onInitialize(({ capabilities: c }) => {
|
|
11516
11631
|
pull = !!c.textDocument?.diagnostic;
|
|
11517
11632
|
refresh = !!c.workspace?.diagnostics?.refreshSupport;
|
|
11633
|
+
watch = !!c.workspace?.didChangeWatchedFiles?.dynamicRegistration;
|
|
11518
11634
|
return {
|
|
11519
11635
|
capabilities: {
|
|
11520
11636
|
positionEncoding: "utf-16",
|
|
@@ -11545,6 +11661,10 @@ function startServer(connection, opts = {}) {
|
|
|
11545
11661
|
},
|
|
11546
11662
|
codeActionProvider: { codeActionKinds: ["quickfix"] },
|
|
11547
11663
|
documentFormattingProvider: true,
|
|
11664
|
+
documentOnTypeFormattingProvider: {
|
|
11665
|
+
firstTriggerCharacter: "\n",
|
|
11666
|
+
moreTriggerCharacter: ["}"]
|
|
11667
|
+
},
|
|
11548
11668
|
...pull && { diagnosticProvider: {
|
|
11549
11669
|
interFileDependencies: true,
|
|
11550
11670
|
workspaceDiagnostics: false
|
|
@@ -11553,6 +11673,9 @@ function startServer(connection, opts = {}) {
|
|
|
11553
11673
|
serverInfo: { name: "yuhwa-lsp" }
|
|
11554
11674
|
};
|
|
11555
11675
|
});
|
|
11676
|
+
connection.onInitialized(() => {
|
|
11677
|
+
if (watch) connection.client.register(import_api.DidChangeWatchedFilesNotification.type, { watchers: [{ globPattern: "**/*.{yu,yuhwa}" }] }).catch(() => {});
|
|
11678
|
+
});
|
|
11556
11679
|
connection.onDidOpenTextDocument((p) => changed(p.textDocument.uri, p.textDocument.text));
|
|
11557
11680
|
connection.onDidChangeTextDocument((p) => {
|
|
11558
11681
|
if (!p.contentChanges.length) return;
|
|
@@ -11569,6 +11692,7 @@ function startServer(connection, opts = {}) {
|
|
|
11569
11692
|
items: service.diagnostics(text(p.textDocument.uri), toPath(p.textDocument.uri))
|
|
11570
11693
|
}));
|
|
11571
11694
|
connection.onDocumentFormatting((p) => service.format(text(p.textDocument.uri)));
|
|
11695
|
+
connection.onDocumentOnTypeFormatting((p) => service.onType(text(p.textDocument.uri), p.position, p.ch));
|
|
11572
11696
|
connection.onCompletion((p) => service.completion(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri)));
|
|
11573
11697
|
connection.onHover((p) => service.hover(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri)));
|
|
11574
11698
|
connection.onDefinition((p) => {
|
|
@@ -11606,6 +11730,20 @@ function startServer(connection, opts = {}) {
|
|
|
11606
11730
|
connection.listen();
|
|
11607
11731
|
return service;
|
|
11608
11732
|
}
|
|
11733
|
+
// src/lsp/uri.ts
|
|
11734
|
+
/**
|
|
11735
|
+
* Path of a `file:` URI with forward slashes on every platform (`C:/w/a.yu` on
|
|
11736
|
+
* Windows), so import paths, which always use `/`, join and compare with it.
|
|
11737
|
+
*/
|
|
11738
|
+
function uriToPath(uri, windows = process.platform === "win32") {
|
|
11739
|
+
if (!uri.startsWith("file:")) return uri;
|
|
11740
|
+
const path = fileURLToPath(uri, { windows });
|
|
11741
|
+
return windows ? path.replace(/\\/g, "/") : path;
|
|
11742
|
+
}
|
|
11743
|
+
/** The `file:` URI of a path from `uriToPath`. */
|
|
11744
|
+
function pathToUri(path, windows = process.platform === "win32") {
|
|
11745
|
+
return pathToFileURL(path, { windows }).href;
|
|
11746
|
+
}
|
|
11609
11747
|
// src/lsp/node.ts
|
|
11610
11748
|
/**
|
|
11611
11749
|
* `yuhwa-lsp`: the language server for editors. The transport comes from the
|
|
@@ -11633,7 +11771,7 @@ Usage: yuhwa-lsp [--stdio | --node-ipc | --socket=<port> | --pipe=<name>]
|
|
|
11633
11771
|
if (!args.some((a) => /^--(stdio|node-ipc|socket|pipe)(=|$)/.test(a))) process.argv.push("--stdio");
|
|
11634
11772
|
startServer((0, import_main.createConnection)(import_main.ProposedFeatures.all), {
|
|
11635
11773
|
readFile: diskResolve,
|
|
11636
|
-
toPath: (uri) =>
|
|
11637
|
-
toUri: (p) =>
|
|
11774
|
+
toPath: (uri) => uriToPath(uri),
|
|
11775
|
+
toUri: (p) => pathToUri(p)
|
|
11638
11776
|
});
|
|
11639
11777
|
export {};
|
package/dist/lsp-server.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* Diagnostics are pulled (`textDocument/diagnostic`) by clients that can, and
|
|
7
7
|
* pushed (`publishDiagnostics`) to the rest, never both.
|
|
8
8
|
*/
|
|
9
|
-
import { n as startServer, t as ServerOptions } from "./server
|
|
9
|
+
import { n as startServer, t as ServerOptions } from "./server--jHjJjOS.js";
|
|
10
10
|
export { ServerOptions, startServer };
|
package/dist/lsp-server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as startServer } from "./server-
|
|
1
|
+
export { t as startServer } from "./server-Dxo7OG8K.js";
|
package/dist/lsp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as YuhwaService, i as Target, n as SEMANTIC_LEGEND, r as ServiceOptions, t as Fix } from "./service-
|
|
1
|
+
import { a as YuhwaService, i as Target, n as SEMANTIC_LEGEND, r as ServiceOptions, t as Fix } from "./service-Brvpt7Do.js";
|
|
2
2
|
import { H as Position, U as Range, nt as TextEdit } from "./main-DYrwpkoa.js";
|
|
3
3
|
/** Format yuhwa source. Returns the new text; whitespace is all that changes. */
|
|
4
4
|
export declare function format(text: string): string;
|
|
@@ -13,4 +13,46 @@ export declare function applyChange(text: string, change: {
|
|
|
13
13
|
text: string;
|
|
14
14
|
range?: Range;
|
|
15
15
|
}): string;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The indent for a line broken at `offset`: the current line's own, one step
|
|
18
|
+
* deeper when the text before the break opens a block. Indentation-shaped
|
|
19
|
+
* bodies (mind maps, tree views) keep their depth, so Enter starts a sibling.
|
|
20
|
+
*/
|
|
21
|
+
export declare function newlineIndent(text: string, offset: number): string;
|
|
22
|
+
/** The indent for a `}` typed on the line holding `offset`: that of its opener. */
|
|
23
|
+
export declare function closeIndent(text: string, offset: number): string;
|
|
24
|
+
/**
|
|
25
|
+
* What a line broken at `offset` starts with: its indent, plus the bullet of
|
|
26
|
+
* an outline item (`- ` or `* `), so a list in a mind map or tree view goes on.
|
|
27
|
+
*/
|
|
28
|
+
export declare function newlinePrefix(text: string, offset: number): string;
|
|
29
|
+
/** A text change: replace `start`..`end` with `insert`, then put the caret at `caret` if set. */
|
|
30
|
+
interface KeyEdit {
|
|
31
|
+
start: number;
|
|
32
|
+
end: number;
|
|
33
|
+
insert: string;
|
|
34
|
+
caret?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Enter with the selection `from`..`to`: the new line keeps the depth (one step
|
|
38
|
+
* deeper after `{`) and continues a bullet. Enter on an empty bullet ends the
|
|
39
|
+
* list, and Enter between `{` and `}` puts the `}` on a line of its own.
|
|
40
|
+
*/
|
|
41
|
+
export declare function enterEdit(text: string, from: number, to: number): KeyEdit;
|
|
42
|
+
/**
|
|
43
|
+
* Tab and Shift+Tab: indent (or outdent by one step) every line the selection
|
|
44
|
+
* `from`..`to` touches, wherever the caret sits on it. Mind maps and tree
|
|
45
|
+
* views nest by indentation, so Tab on `- item` moves the item, not its text.
|
|
46
|
+
* Returns the new text and selection.
|
|
47
|
+
*/
|
|
48
|
+
export declare function shiftLines(text: string, from: number, to: number, out?: boolean): {
|
|
49
|
+
text: string;
|
|
50
|
+
from: number;
|
|
51
|
+
to: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Edits after a character was typed at `pos`: a newline re-indents the new
|
|
55
|
+
* line and continues a bullet, a `}` alone on its line lines up with its opener.
|
|
56
|
+
*/
|
|
57
|
+
export declare function onTypeEdits(text: string, pos: Position, ch: string): TextEdit[];
|
|
58
|
+
export { type Fix, type KeyEdit, SEMANTIC_LEGEND, type ServiceOptions, type Target, YuhwaService };
|
package/dist/lsp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as SEMANTIC_LEGEND, n as YuhwaService, r as applyChange, i as
|
|
1
|
+
export { t as SEMANTIC_LEGEND, n as YuhwaService, r as applyChange, i as closeIndent, a as diffEdits, o as enterEdit, s as format, c as newlineIndent, l as newlinePrefix, u as offsetAt, d as onTypeEdits, f as positionAt, p as shiftLines } from "./service-B1fpOg_L.js";
|
package/dist/markdown-it.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* A fence with `no-render` (```yuhwa no-render) stays a code block.
|
|
10
10
|
* ```yuhwa file="diagrams/arch.yu" renders that file instead of the block.
|
|
11
11
|
*/
|
|
12
|
-
import { t as YuhwaDocsOptions } from "./figure-
|
|
12
|
+
import { t as YuhwaDocsOptions } from "./figure-CA2hy0xh.js";
|
|
13
13
|
type Rule = (tokens: any[], idx: number, options: any, env: any, self: any) => string;
|
|
14
14
|
interface MarkdownIt {
|
|
15
15
|
renderer: {
|
package/dist/markdown-it.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as wantsRender, i as toHtml, n as renderBlock, o as zoomTag } from "./node-
|
|
1
|
+
import { a as wantsRender, i as toHtml, n as renderBlock, o as zoomTag } from "./node-Bzn2uKXZ.js";
|
|
2
2
|
// src/integrations/markdown-it.ts
|
|
3
3
|
/**
|
|
4
4
|
* markdown-it plugin: renders ```yuhwa fences at build time.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync, realpathSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
|
-
import { K as isYuhwaPath, n as render } from "./src-
|
|
3
|
+
import { It as table, K as isYuhwaPath, n as render } from "./src-DkQj7aIV.js";
|
|
4
4
|
import { n as zoomScript } from "./zoom-script-CVdAzMhX.js";
|
|
5
5
|
import { t as zoomHeight } from "./zoom-QeqB6QlH.js";
|
|
6
6
|
// src/integrations/figure.ts
|
|
@@ -123,12 +123,12 @@ function renderFigure(source, opts = {}, at = {}) {
|
|
|
123
123
|
result: light
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
const ATTR = {
|
|
126
|
+
const ATTR = table({
|
|
127
127
|
className: "class",
|
|
128
128
|
srcSet: "srcset",
|
|
129
129
|
dataYuhwa: "data-yuhwa",
|
|
130
130
|
dataZoom: "data-zoom"
|
|
131
|
-
};
|
|
131
|
+
});
|
|
132
132
|
const escape = (s) => s.replace(/[&<>"]/g, (c) => ({
|
|
133
133
|
"&": "&",
|
|
134
134
|
"<": "<",
|
package/dist/remark.d.ts
CHANGED
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
* A fence with `no-render` (```yuhwa no-render) stays a code block.
|
|
11
11
|
* ```yuhwa file="diagrams/arch.yu" renders that file instead of the block.
|
|
12
12
|
*/
|
|
13
|
-
import { t as YuhwaDocsOptions } from "./figure-
|
|
13
|
+
import { t as YuhwaDocsOptions } from "./figure-CA2hy0xh.js";
|
|
14
14
|
export default function remarkYuhwa(opts?: YuhwaDocsOptions): (tree: any, file?: any) => void;
|
|
15
15
|
export { type YuhwaDocsOptions, remarkYuhwa };
|
package/dist/remark.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as wantsRender, n as renderBlock, o as zoomTag } from "./node-
|
|
1
|
+
import { a as wantsRender, n as renderBlock, o as zoomTag } from "./node-Bzn2uKXZ.js";
|
|
2
2
|
// src/integrations/remark.ts
|
|
3
3
|
/**
|
|
4
4
|
* remark plugin: replaces ```yuhwa code blocks with a rendered figure.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="../../typings/thenable.d.ts" preserve="true" />
|
|
2
2
|
import { $ as SymbolTag, A as Hover, B as Location, C as DocumentHighlight, D as FoldingRange, E as DocumentUri, F as InlineValue, G as SelectionRange, H as Position, I as InlineValueContext, J as SemanticTokensEdit, K as SemanticTokens, L as InsertTextMode, M as InlineCompletionContext, N as InlineCompletionItem, O as FoldingRangeKind, P as InlineCompletionList, Q as SymbolKind, R as LSPAny, S as DiagnosticTag, T as DocumentSymbol, U as Range, V as MarkupKind, W as ReferenceContext, X as SignatureHelp, Y as SemanticTokensLegend, Z as SymbolInformation, _ as Declaration, a as CodeActionContext, at as VersionedTextDocumentIdentifier, b as DefinitionLink, c as CodeLens, ct as WorkspaceFolder, d as ColorPresentation, dt as uinteger, et as TextDocumentIdentifier, f as Command, g as CompletionList, h as CompletionItemTag, i as CodeAction, it as URI, j as InlayHint, k as FormattingOptions, l as Color, lt as WorkspaceSymbol, m as CompletionItemKind, n as CallHierarchyItem, nt as TextEdit, o as CodeActionKind, ot as WorkspaceEdit, p as CompletionItem, q as SemanticTokensDelta, r as CallHierarchyOutgoingCall, rt as TypeHierarchyItem, s as CodeActionTag, st as WorkspaceEditMetadata, t as CallHierarchyIncomingCall, tt as TextDocumentItem, u as ColorInformation, ut as integer, v as DeclarationLink, w as DocumentLink, x as Diagnostic, y as Definition, z as LSPObject } from "./main-DYrwpkoa.js";
|
|
3
|
-
import { a as YuhwaService } from "./service-
|
|
3
|
+
import { a as YuhwaService } from "./service-Brvpt7Do.js";
|
|
4
4
|
interface ResponseErrorLiteral<D = void> {
|
|
5
5
|
/**
|
|
6
6
|
* A number indicating the error type that occurred.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as YuhwaService, r as applyChange, t as SEMANTIC_LEGEND } from "./service-
|
|
1
|
+
import { n as YuhwaService, r as applyChange, t as SEMANTIC_LEGEND } from "./service-B1fpOg_L.js";
|
|
2
2
|
// \0rolldown/runtime.js
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -9745,6 +9745,7 @@ var require_api = /* @__PURE__ */ __commonJSMin(((exports, module, this$1) => {
|
|
|
9745
9745
|
// src/lsp/server.ts
|
|
9746
9746
|
var import_api = require_api();
|
|
9747
9747
|
const REQUEST_FAILED = -32803;
|
|
9748
|
+
const DEBOUNCE_MS = 150;
|
|
9748
9749
|
const defaultToPath = (uri) => {
|
|
9749
9750
|
try {
|
|
9750
9751
|
return decodeURIComponent(new URL(uri).pathname);
|
|
@@ -9766,7 +9767,9 @@ function startServer(connection, opts = {}) {
|
|
|
9766
9767
|
const text = (uri) => docs.get(toPath(uri)) ?? "";
|
|
9767
9768
|
let pull = false;
|
|
9768
9769
|
let refresh = false;
|
|
9769
|
-
|
|
9770
|
+
let watch = false;
|
|
9771
|
+
const publish = () => {
|
|
9772
|
+
timer = void 0;
|
|
9770
9773
|
if (pull) {
|
|
9771
9774
|
if (refresh) connection.languages.diagnostics.refresh().catch(() => {});
|
|
9772
9775
|
return;
|
|
@@ -9776,6 +9779,11 @@ function startServer(connection, opts = {}) {
|
|
|
9776
9779
|
diagnostics: service.diagnostics(src, path)
|
|
9777
9780
|
});
|
|
9778
9781
|
};
|
|
9782
|
+
let timer;
|
|
9783
|
+
const validate = () => {
|
|
9784
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
9785
|
+
timer = setTimeout(publish, DEBOUNCE_MS);
|
|
9786
|
+
};
|
|
9779
9787
|
const changed = (uri, src) => {
|
|
9780
9788
|
const path = toPath(uri);
|
|
9781
9789
|
if (src === void 0) {
|
|
@@ -9795,6 +9803,7 @@ function startServer(connection, opts = {}) {
|
|
|
9795
9803
|
connection.onInitialize(({ capabilities: c }) => {
|
|
9796
9804
|
pull = !!c.textDocument?.diagnostic;
|
|
9797
9805
|
refresh = !!c.workspace?.diagnostics?.refreshSupport;
|
|
9806
|
+
watch = !!c.workspace?.didChangeWatchedFiles?.dynamicRegistration;
|
|
9798
9807
|
return {
|
|
9799
9808
|
capabilities: {
|
|
9800
9809
|
positionEncoding: "utf-16",
|
|
@@ -9825,6 +9834,10 @@ function startServer(connection, opts = {}) {
|
|
|
9825
9834
|
},
|
|
9826
9835
|
codeActionProvider: { codeActionKinds: ["quickfix"] },
|
|
9827
9836
|
documentFormattingProvider: true,
|
|
9837
|
+
documentOnTypeFormattingProvider: {
|
|
9838
|
+
firstTriggerCharacter: "\n",
|
|
9839
|
+
moreTriggerCharacter: ["}"]
|
|
9840
|
+
},
|
|
9828
9841
|
...pull && { diagnosticProvider: {
|
|
9829
9842
|
interFileDependencies: true,
|
|
9830
9843
|
workspaceDiagnostics: false
|
|
@@ -9833,6 +9846,9 @@ function startServer(connection, opts = {}) {
|
|
|
9833
9846
|
serverInfo: { name: "yuhwa-lsp" }
|
|
9834
9847
|
};
|
|
9835
9848
|
});
|
|
9849
|
+
connection.onInitialized(() => {
|
|
9850
|
+
if (watch) connection.client.register(import_api.DidChangeWatchedFilesNotification.type, { watchers: [{ globPattern: "**/*.{yu,yuhwa}" }] }).catch(() => {});
|
|
9851
|
+
});
|
|
9836
9852
|
connection.onDidOpenTextDocument((p) => changed(p.textDocument.uri, p.textDocument.text));
|
|
9837
9853
|
connection.onDidChangeTextDocument((p) => {
|
|
9838
9854
|
if (!p.contentChanges.length) return;
|
|
@@ -9849,6 +9865,7 @@ function startServer(connection, opts = {}) {
|
|
|
9849
9865
|
items: service.diagnostics(text(p.textDocument.uri), toPath(p.textDocument.uri))
|
|
9850
9866
|
}));
|
|
9851
9867
|
connection.onDocumentFormatting((p) => service.format(text(p.textDocument.uri)));
|
|
9868
|
+
connection.onDocumentOnTypeFormatting((p) => service.onType(text(p.textDocument.uri), p.position, p.ch));
|
|
9852
9869
|
connection.onCompletion((p) => service.completion(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri)));
|
|
9853
9870
|
connection.onHover((p) => service.hover(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri)));
|
|
9854
9871
|
connection.onDefinition((p) => {
|