@marko/language-server 1.1.4 → 1.1.6
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 +11 -13
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +10 -12
- package/dist/index.mjs.map +2 -2
- package/dist/utils/file.d.ts +2 -2
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -34,15 +34,17 @@ var import_vscode_uri = require("vscode-uri");
|
|
|
34
34
|
var processorCaches = /* @__PURE__ */ new WeakMap();
|
|
35
35
|
function getFSDir(doc) {
|
|
36
36
|
const filename = getFSPath(doc);
|
|
37
|
-
return filename
|
|
37
|
+
return filename && import_path.default.dirname(filename);
|
|
38
38
|
}
|
|
39
39
|
function getFSPath(doc) {
|
|
40
|
-
|
|
40
|
+
const parsed = import_vscode_uri.URI.parse(doc.uri);
|
|
41
|
+
return parsed.scheme === "file" ? parsed.fsPath : void 0;
|
|
41
42
|
}
|
|
42
43
|
function getMarkoFile(doc) {
|
|
43
44
|
const { uri } = doc;
|
|
44
|
-
const { fsPath
|
|
45
|
-
const
|
|
45
|
+
const { fsPath, scheme } = import_vscode_uri.URI.parse(uri);
|
|
46
|
+
const filename = scheme === "file" ? fsPath : void 0;
|
|
47
|
+
const dirname = filename ? import_path.default.dirname(filename) : process.cwd();
|
|
46
48
|
const cache = import_language_tools.Project.getCache(dirname);
|
|
47
49
|
let file = cache.get(doc);
|
|
48
50
|
if (!file) {
|
|
@@ -67,10 +69,7 @@ function getMarkoFile(doc) {
|
|
|
67
69
|
return file;
|
|
68
70
|
}
|
|
69
71
|
function clearMarkoCacheForFile(doc) {
|
|
70
|
-
|
|
71
|
-
const dirname = filename && import_path.default.dirname(filename);
|
|
72
|
-
const cache = import_language_tools.Project.getCache(dirname);
|
|
73
|
-
cache.delete(doc);
|
|
72
|
+
import_language_tools.Project.getCache(getFSDir(doc)).delete(doc);
|
|
74
73
|
}
|
|
75
74
|
function processDoc(doc, process2) {
|
|
76
75
|
const file = getMarkoFile(doc);
|
|
@@ -1963,8 +1962,6 @@ var format2 = async (doc, params, cancel) => {
|
|
|
1963
1962
|
const options = {
|
|
1964
1963
|
parser: "marko",
|
|
1965
1964
|
filepath,
|
|
1966
|
-
markoCompiler: import_language_tools14.Project.getCompiler(dir),
|
|
1967
|
-
markoCompilerConfig: import_language_tools14.Project.getConfig(dir),
|
|
1968
1965
|
plugins: [markoPrettier],
|
|
1969
1966
|
tabWidth: params.options.tabSize,
|
|
1970
1967
|
useTabs: params.options.insertSpaces === false,
|
|
@@ -1974,6 +1971,7 @@ var format2 = async (doc, params, cancel) => {
|
|
|
1974
1971
|
};
|
|
1975
1972
|
if (cancel.isCancellationRequested)
|
|
1976
1973
|
return;
|
|
1974
|
+
markoPrettier.setCompiler(import_language_tools14.Project.getCompiler(dir), import_language_tools14.Project.getConfig(dir));
|
|
1977
1975
|
const ret = [
|
|
1978
1976
|
import_vscode_languageserver9.TextEdit.replace(
|
|
1979
1977
|
{
|
|
@@ -2012,7 +2010,7 @@ var import_language_tools16 = require("@marko/language-tools");
|
|
|
2012
2010
|
// src/ts-plugin/host.ts
|
|
2013
2011
|
var import_path6 = __toESM(require("path"));
|
|
2014
2012
|
var defaultCompiler = __toESM(require("@marko/compiler"));
|
|
2015
|
-
var
|
|
2013
|
+
var import_config = __toESM(require("@marko/compiler/config"));
|
|
2016
2014
|
var defaultTranslator = __toESM(require("@marko/translator-default"));
|
|
2017
2015
|
var import_language_tools15 = require("@marko/language-tools");
|
|
2018
2016
|
var fsPathReg = /^(?:[./\\]|[A-Z]:)/i;
|
|
@@ -2022,7 +2020,7 @@ import_language_tools15.Project.setDefaultTypePaths({
|
|
|
2022
2020
|
markoTypesFile: import_path6.default.join(__dirname, "marko.runtime.d.ts")
|
|
2023
2021
|
});
|
|
2024
2022
|
import_language_tools15.Project.setDefaultCompilerMeta(defaultCompiler, {
|
|
2025
|
-
...
|
|
2023
|
+
...import_config.default,
|
|
2026
2024
|
translator: defaultTranslator
|
|
2027
2025
|
});
|
|
2028
2026
|
function patch(ts2, configFile, extractCache3, resolutionCache, host, ps) {
|
|
@@ -2784,7 +2782,7 @@ function processScript(doc, tsProject) {
|
|
|
2784
2782
|
ts: import_tsserverlibrary.default,
|
|
2785
2783
|
parsed,
|
|
2786
2784
|
lookup,
|
|
2787
|
-
scriptLang: import_language_tools16.Project.getScriptLang(filename, markoScriptLang, import_tsserverlibrary.default, host),
|
|
2785
|
+
scriptLang: filename ? import_language_tools16.Project.getScriptLang(filename, markoScriptLang, import_tsserverlibrary.default, host) : markoScriptLang,
|
|
2788
2786
|
runtimeTypesCode: (_a = import_language_tools16.Project.getTypeLibs(tsProject.rootDir, import_tsserverlibrary.default, host)) == null ? void 0 : _a.markoTypesCode
|
|
2789
2787
|
});
|
|
2790
2788
|
});
|