diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-20 17:30:16 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-20 17:30:16 +0800 |
commit | 64e1114725a8956ac9f280b923fc8eacb0f07265 (patch) | |
tree | cb0afc0fd86acd729a117fc03b9c2c2074cf87ec | |
parent | e75a364e400a3e394d3ff557523a99ab9880619d (diff) | |
download | lua-language-server-64e1114725a8956ac9f280b923fc8eacb0f07265.zip |
不监视文件变化
-rw-r--r-- | server/src/method/initialized.lua | 2 | ||||
-rw-r--r-- | server/src/method/workspace/didChangeWatchedFiles.lua | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/server/src/method/initialized.lua b/server/src/method/initialized.lua index 0fdda7fa..f79d035d 100644 --- a/server/src/method/initialized.lua +++ b/server/src/method/initialized.lua @@ -21,7 +21,7 @@ return function (lsp) watchers = { { globPattern = '**/*.lua', - kind = 1 | 2 | 4, -- Create | Change | Delete + kind = 1 | 4, -- Create | Change | Delete }, }, }, diff --git a/server/src/method/workspace/didChangeWatchedFiles.lua b/server/src/method/workspace/didChangeWatchedFiles.lua index ec71250f..df57baff 100644 --- a/server/src/method/workspace/didChangeWatchedFiles.lua +++ b/server/src/method/workspace/didChangeWatchedFiles.lua @@ -8,6 +8,7 @@ return function (lsp, params) if not lsp.workspace then return end + local needReset for _, change in ipairs(params.changes) do if change.type == FileChangeType.Created then lsp.workspace:addFile(change.uri) @@ -16,7 +17,12 @@ return function (lsp, params) -- 删除文件后,清除该文件的诊断 lsp:clearDiagnostics(change.uri) end + if lsp:isOpen(change.uri) then + needReset = true + end end -- 发生任何文件变化后,重新计算当前的打开文件 - lsp.workspace:reset() + if needReset then + lsp.workspace:reset() + end end |