@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.mjs CHANGED
@@ -22,15 +22,17 @@ import { URI } from "vscode-uri";
22
22
  var processorCaches = /* @__PURE__ */ new WeakMap();
23
23
  function getFSDir(doc) {
24
24
  const filename = getFSPath(doc);
25
- return filename ? path.dirname(filename) : void 0;
25
+ return filename && path.dirname(filename);
26
26
  }
27
27
  function getFSPath(doc) {
28
- return URI.parse(doc.uri).fsPath;
28
+ const parsed = URI.parse(doc.uri);
29
+ return parsed.scheme === "file" ? parsed.fsPath : void 0;
29
30
  }
30
31
  function getMarkoFile(doc) {
31
32
  const { uri } = doc;
32
- const { fsPath: filename, scheme } = URI.parse(uri);
33
- const dirname = filename && path.dirname(filename);
33
+ const { fsPath, scheme } = URI.parse(uri);
34
+ const filename = scheme === "file" ? fsPath : void 0;
35
+ const dirname = filename ? path.dirname(filename) : process.cwd();
34
36
  const cache = Project.getCache(dirname);
35
37
  let file = cache.get(doc);
36
38
  if (!file) {
@@ -55,10 +57,7 @@ function getMarkoFile(doc) {
55
57
  return file;
56
58
  }
57
59
  function clearMarkoCacheForFile(doc) {
58
- const { fsPath: filename } = URI.parse(doc.uri);
59
- const dirname = filename && path.dirname(filename);
60
- const cache = Project.getCache(dirname);
61
- cache.delete(doc);
60
+ Project.getCache(getFSDir(doc)).delete(doc);
62
61
  }
63
62
  function processDoc(doc, process2) {
64
63
  const file = getMarkoFile(doc);
@@ -1975,8 +1974,6 @@ var format2 = async (doc, params, cancel) => {
1975
1974
  const options = {
1976
1975
  parser: "marko",
1977
1976
  filepath,
1978
- markoCompiler: Project3.getCompiler(dir),
1979
- markoCompilerConfig: Project3.getConfig(dir),
1980
1977
  plugins: [markoPrettier],
1981
1978
  tabWidth: params.options.tabSize,
1982
1979
  useTabs: params.options.insertSpaces === false,
@@ -1986,6 +1983,7 @@ var format2 = async (doc, params, cancel) => {
1986
1983
  };
1987
1984
  if (cancel.isCancellationRequested)
1988
1985
  return;
1986
+ markoPrettier.setCompiler(Project3.getCompiler(dir), Project3.getConfig(dir));
1989
1987
  const ret = [
1990
1988
  TextEdit6.replace(
1991
1989
  {
@@ -2035,7 +2033,7 @@ import {
2035
2033
  // src/ts-plugin/host.ts
2036
2034
  import path6 from "path";
2037
2035
  import * as defaultCompiler from "@marko/compiler";
2038
- import * as defaultConfig from "@marko/compiler/config";
2036
+ import defaultConfig from "@marko/compiler/config";
2039
2037
  import * as defaultTranslator from "@marko/translator-default";
2040
2038
  import {
2041
2039
  Processors,
@@ -2812,7 +2810,7 @@ function processScript(doc, tsProject) {
2812
2810
  ts,
2813
2811
  parsed,
2814
2812
  lookup,
2815
- scriptLang: Project5.getScriptLang(filename, markoScriptLang, ts, host),
2813
+ scriptLang: filename ? Project5.getScriptLang(filename, markoScriptLang, ts, host) : markoScriptLang,
2816
2814
  runtimeTypesCode: (_a = Project5.getTypeLibs(tsProject.rootDir, ts, host)) == null ? void 0 : _a.markoTypesCode
2817
2815
  });
2818
2816
  });