Browse Source

Add support for LSP workspace/didChangeWatchedFiles (#6524)

Co-authored-by: Aiden Cline <[email protected]>
Marcel de Vries 1 tháng trước cách đây
mục cha
commit
f3db966317
1 tập tin đã thay đổi với 23 bổ sung0 xóa
  1. 23 0
      packages/opencode/src/lsp/client.ts

+ 23 - 0
packages/opencode/src/lsp/client.ts

@@ -98,6 +98,9 @@ export namespace LSPClient {
           },
           workspace: {
             configuration: true,
+            didChangeWatchedFiles: {
+              dynamicRegistration: true,
+            },
           },
           textDocument: {
             synchronization: {
@@ -151,6 +154,16 @@ export namespace LSPClient {
 
           const version = files[input.path]
           if (version !== undefined) {
+            log.info("workspace/didChangeWatchedFiles", input)
+            await connection.sendNotification("workspace/didChangeWatchedFiles", {
+              changes: [
+                {
+                  uri: pathToFileURL(input.path).href,
+                  type: 2, // Changed
+                },
+              ],
+            })
+
             const next = version + 1
             files[input.path] = next
             log.info("textDocument/didChange", {
@@ -167,6 +180,16 @@ export namespace LSPClient {
             return
           }
 
+          log.info("workspace/didChangeWatchedFiles", input)
+          await connection.sendNotification("workspace/didChangeWatchedFiles", {
+            changes: [
+              {
+                uri: pathToFileURL(input.path).href,
+                type: 1, // Created
+              },
+            ],
+          })
+
           log.info("textDocument/didOpen", input)
           diagnostics.delete(input.path)
           await connection.sendNotification("textDocument/didOpen", {