@marko/language-server 1.1.1 → 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.mjs CHANGED
@@ -13,13 +13,17 @@ import {
13
13
  TextDocumentSyncKind,
14
14
  createConnection
15
15
  } from "vscode-languageserver/node";
16
- import { Project as Project5 } from "@marko/language-tools";
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
  }
@@ -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 Project4,
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 Project3,
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
- Project3.setDefaultTypePaths({
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 = Project4.getScriptLang(
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: Project4.getScriptLang(filename, markoScriptLang, ts, host),
2801
- runtimeTypesCode: (_a = Project4.getTypeLibs(tsProject.rootDir, ts, host)) == null ? void 0 : _a.markoTypesCode
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 = Project4.getCache(configFile && rootDir);
2881
+ const cache = Project5.getCache(configFile && rootDir);
2874
2882
  let projectCache = cache.get(getTSProject);
2875
2883
  let cached;
2876
2884
  if (projectCache) {
@@ -4063,7 +4071,7 @@ for (const command in service.commands) {
4063
4071
  }
4064
4072
  function validateDocs() {
4065
4073
  queueDiagnostic();
4066
- Project5.clearCaches();
4074
+ Project6.clearCaches();
4067
4075
  }
4068
4076
  function queueDiagnostic() {
4069
4077
  clearTimeout(diagnosticTimeout);