Dax Raad 9 months ago
parent
commit
e1ec815d1b
3 changed files with 30 additions and 3 deletions
  1. 27 0
      js/src/lsp/index.ts
  2. 2 2
      js/src/lsp/language.ts
  3. 1 1
      js/src/tool/util/file-times.ts

+ 27 - 0
js/src/lsp/index.ts

@@ -8,6 +8,7 @@ export namespace LSP {
   const state = App.state("lsp", async () => {
     const clients = new Map<string, LSPClient.Info>();
 
+    // QUESTION: how lazy should lsp auto discovery be? should it not initialize until a file is opened?
     clients.set(
       "typescript",
       await LSPClient.create({
@@ -28,4 +29,30 @@ export namespace LSP {
     const tasks = clients.map((x) => input(x));
     return Promise.all(tasks);
   }
+
+  const AUTO: {
+    command: string[];
+    extensions: string[];
+    install?: () => Promise<void>;
+  }[] = [
+    {
+      command: ["bun", "x", "typescript-language-server", "--stdio"],
+      extensions: [
+        "ts",
+        "tsx",
+        "js",
+        "jsx",
+        "mjs",
+        "cjs",
+        "mts",
+        "cts",
+        "mtsx",
+        "ctsx",
+      ],
+    },
+    {
+      command: ["gopls"],
+      extensions: ["go"],
+    },
+  ];
 }

+ 2 - 2
js/src/lsp/language.ts

@@ -1,4 +1,4 @@
-export const LANGUAGE_EXTENSIONS: Record<string, string> = {
+export const LANGUAGE_EXTENSIONS = {
   ".abap": "abap",
   ".bat": "bat",
   ".bib": "bibtex",
@@ -80,4 +80,4 @@ export const LANGUAGE_EXTENSIONS: Record<string, string> = {
   ".xsl": "xsl",
   ".yaml": "yaml",
   ".yml": "yaml",
-};
+} as const;

+ 1 - 1
js/src/tool/util/file-times.ts

@@ -1,7 +1,7 @@
 import { App } from "../../app";
 
 export namespace FileTimes {
-  export const state = App.state("tool.edit", () => ({
+  export const state = App.state("tool.filetimes", () => ({
     read: new Map<string, Date>(),
     write: new Map<string, Date>(),
   }));