@marko/language-server 1.1.0 → 1.1.2
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/index.js +34 -28
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +19 -13
- package/dist/index.mjs.map +3 -3
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -13,13 +13,17 @@ import {
|
|
|
13
13
|
TextDocumentSyncKind,
|
|
14
14
|
createConnection
|
|
15
15
|
} from "vscode-languageserver/node";
|
|
16
|
-
import { Project as
|
|
16
|
+
import { Project as Project6 } from "@marko/language-tools";
|
|
17
17
|
|
|
18
18
|
// src/utils/file.ts
|
|
19
19
|
import path from "path";
|
|
20
20
|
import { Project, parse } from "@marko/language-tools";
|
|
21
21
|
import { URI } from "vscode-uri";
|
|
22
22
|
var processorCaches = /* @__PURE__ */ new WeakMap();
|
|
23
|
+
function getFSDir(doc) {
|
|
24
|
+
const filename = getFSPath(doc);
|
|
25
|
+
return filename ? path.dirname(filename) : void 0;
|
|
26
|
+
}
|
|
23
27
|
function getFSPath(doc) {
|
|
24
28
|
return URI.parse(doc.uri).fsPath;
|
|
25
29
|
}
|
|
@@ -1089,7 +1093,7 @@ function AttrName({
|
|
|
1089
1093
|
let label = attr.name;
|
|
1090
1094
|
let snippet = attr.name;
|
|
1091
1095
|
if (attr.enum) {
|
|
1092
|
-
snippet += `="
|
|
1096
|
+
snippet += `="$1"$0`;
|
|
1093
1097
|
} else {
|
|
1094
1098
|
switch (type) {
|
|
1095
1099
|
case "string":
|
|
@@ -1962,13 +1966,17 @@ function extractDocumentSymbols({
|
|
|
1962
1966
|
import { TextEdit as TextEdit6 } from "vscode-languageserver";
|
|
1963
1967
|
import * as prettier from "prettier";
|
|
1964
1968
|
import * as markoPrettier from "prettier-plugin-marko";
|
|
1969
|
+
import { Project as Project3 } from "@marko/language-tools";
|
|
1965
1970
|
var format2 = async (doc, params, cancel) => {
|
|
1966
1971
|
try {
|
|
1972
|
+
const dir = getFSDir(doc);
|
|
1967
1973
|
const filepath = getFSPath(doc);
|
|
1968
1974
|
const text = doc.getText();
|
|
1969
1975
|
const options = {
|
|
1970
1976
|
parser: "marko",
|
|
1971
1977
|
filepath,
|
|
1978
|
+
markoCompiler: Project3.getCompiler(dir),
|
|
1979
|
+
markoCompilerConfig: Project3.getConfig(dir),
|
|
1972
1980
|
plugins: [markoPrettier],
|
|
1973
1981
|
tabWidth: params.options.tabSize,
|
|
1974
1982
|
useTabs: params.options.insertSpaces === false,
|
|
@@ -2019,7 +2027,7 @@ import { URI as URI6 } from "vscode-uri";
|
|
|
2019
2027
|
import * as prettier2 from "prettier";
|
|
2020
2028
|
import {
|
|
2021
2029
|
NodeType as NodeType9,
|
|
2022
|
-
Project as
|
|
2030
|
+
Project as Project5,
|
|
2023
2031
|
ScriptLang,
|
|
2024
2032
|
extractScript
|
|
2025
2033
|
} from "@marko/language-tools";
|
|
@@ -2028,13 +2036,13 @@ import {
|
|
|
2028
2036
|
import path6 from "path";
|
|
2029
2037
|
import {
|
|
2030
2038
|
Processors,
|
|
2031
|
-
Project as
|
|
2039
|
+
Project as Project4,
|
|
2032
2040
|
getExt,
|
|
2033
2041
|
isDefinitionFile
|
|
2034
2042
|
} from "@marko/language-tools";
|
|
2035
2043
|
var fsPathReg = /^(?:[./\\]|[A-Z]:)/i;
|
|
2036
2044
|
var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
|
|
2037
|
-
|
|
2045
|
+
Project4.setDefaultTypePaths({
|
|
2038
2046
|
internalTypesFile: path6.join(__dirname, "marko.internal.d.ts"),
|
|
2039
2047
|
markoTypesFile: path6.join(__dirname, "marko.runtime.d.ts")
|
|
2040
2048
|
});
|
|
@@ -2413,7 +2421,7 @@ var ScriptService = {
|
|
|
2413
2421
|
return;
|
|
2414
2422
|
const tsProject = getTSProject(filename);
|
|
2415
2423
|
const extracted = processScript(doc, tsProject);
|
|
2416
|
-
const lang =
|
|
2424
|
+
const lang = Project5.getScriptLang(
|
|
2417
2425
|
filename,
|
|
2418
2426
|
tsProject.markoScriptLang,
|
|
2419
2427
|
ts,
|
|
@@ -2797,8 +2805,8 @@ function processScript(doc, tsProject) {
|
|
|
2797
2805
|
ts,
|
|
2798
2806
|
parsed,
|
|
2799
2807
|
lookup,
|
|
2800
|
-
scriptLang:
|
|
2801
|
-
runtimeTypesCode: (_a =
|
|
2808
|
+
scriptLang: Project5.getScriptLang(filename, markoScriptLang, ts, host),
|
|
2809
|
+
runtimeTypesCode: (_a = Project5.getTypeLibs(tsProject.rootDir, ts, host)) == null ? void 0 : _a.markoTypesCode
|
|
2802
2810
|
});
|
|
2803
2811
|
});
|
|
2804
2812
|
}
|
|
@@ -2870,7 +2878,7 @@ function getTSProject(docFsPath) {
|
|
|
2870
2878
|
}
|
|
2871
2879
|
}
|
|
2872
2880
|
const rootDir = configFile && path7.dirname(configFile) || process.cwd();
|
|
2873
|
-
const cache =
|
|
2881
|
+
const cache = Project5.getCache(configFile && rootDir);
|
|
2874
2882
|
let projectCache = cache.get(getTSProject);
|
|
2875
2883
|
let cached;
|
|
2876
2884
|
if (projectCache) {
|
|
@@ -3575,7 +3583,6 @@ var service = {
|
|
|
3575
3583
|
);
|
|
3576
3584
|
},
|
|
3577
3585
|
async doComplete(doc, params, cancel) {
|
|
3578
|
-
let isIncomplete = false;
|
|
3579
3586
|
const itemsByLabel = /* @__PURE__ */ new Map();
|
|
3580
3587
|
await Promise.allSettled(
|
|
3581
3588
|
plugins.map(async (plugin) => {
|
|
@@ -3589,7 +3596,6 @@ var service = {
|
|
|
3589
3596
|
curItems = cur;
|
|
3590
3597
|
} else {
|
|
3591
3598
|
curItems = cur.items;
|
|
3592
|
-
isIncomplete ||= cur.isIncomplete;
|
|
3593
3599
|
}
|
|
3594
3600
|
for (const item of curItems) {
|
|
3595
3601
|
const { label } = item;
|
|
@@ -3608,7 +3614,7 @@ var service = {
|
|
|
3608
3614
|
if (cancel.isCancellationRequested)
|
|
3609
3615
|
return;
|
|
3610
3616
|
if (itemsByLabel.size) {
|
|
3611
|
-
return { items: [...itemsByLabel.values()], isIncomplete };
|
|
3617
|
+
return { items: [...itemsByLabel.values()], isIncomplete: true };
|
|
3612
3618
|
}
|
|
3613
3619
|
},
|
|
3614
3620
|
async doCompletionResolve(item, cancel) {
|
|
@@ -4065,7 +4071,7 @@ for (const command in service.commands) {
|
|
|
4065
4071
|
}
|
|
4066
4072
|
function validateDocs() {
|
|
4067
4073
|
queueDiagnostic();
|
|
4068
|
-
|
|
4074
|
+
Project6.clearCaches();
|
|
4069
4075
|
}
|
|
4070
4076
|
function queueDiagnostic() {
|
|
4071
4077
|
clearTimeout(diagnosticTimeout);
|