summaryrefslogtreecommitdiff
path: root/script/method/textDocument/didChange.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/method/textDocument/didChange.lua')
-rw-r--r--script/method/textDocument/didChange.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/script/method/textDocument/didChange.lua b/script/method/textDocument/didChange.lua
new file mode 100644
index 00000000..82e6c096
--- /dev/null
+++ b/script/method/textDocument/didChange.lua
@@ -0,0 +1,16 @@
+return function (lsp, params)
+ local doc = params.textDocument
+ local change = params.contentChanges
+ if lsp.workspace then
+ local path = lsp.workspace:relativePathByUri(doc.uri)
+ if not path or not lsp.workspace:isLuaFile(path) then
+ return
+ end
+ if not lsp:isOpen(doc.uri) and lsp.workspace.gitignore(path:string()) then
+ return
+ end
+ end
+ -- TODO 支持差量更新
+ lsp:saveText(doc.uri, doc.version, change[1].text)
+ return true
+end