diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-20 17:27:17 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-20 17:27:17 +0800 |
commit | e75a364e400a3e394d3ff557523a99ab9880619d (patch) | |
tree | 3d5bd6c4dd26431689fecda370cb0cf49baa742b /server/src | |
parent | 8d2ef4b2c801c482fe12eefebd8e6598415f19b9 (diff) | |
download | lua-language-server-e75a364e400a3e394d3ff557523a99ab9880619d.zip |
本地文件读完后重新编译
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/method/textDocument/didClose.lua | 1 | ||||
-rw-r--r-- | server/src/method/textDocument/didOpen.lua | 1 | ||||
-rw-r--r-- | server/src/service.lua | 15 | ||||
-rw-r--r-- | server/src/workspace.lua | 2 |
4 files changed, 19 insertions, 0 deletions
diff --git a/server/src/method/textDocument/didClose.lua b/server/src/method/textDocument/didClose.lua index d7f2841a..5da33010 100644 --- a/server/src/method/textDocument/didClose.lua +++ b/server/src/method/textDocument/didClose.lua @@ -1,5 +1,6 @@ return function (lsp, params) local doc = params.textDocument --lsp:removeText(doc.uri, doc.version) + lsp:close(doc.uri) return true end diff --git a/server/src/method/textDocument/didOpen.lua b/server/src/method/textDocument/didOpen.lua index 27fdda71..b6710d6b 100644 --- a/server/src/method/textDocument/didOpen.lua +++ b/server/src/method/textDocument/didOpen.lua @@ -1,5 +1,6 @@ return function (lsp, params) local doc = params.textDocument lsp:saveText(doc.uri, doc.version, doc.text) + lsp:open(doc.uri) return true end diff --git a/server/src/service.lua b/server/src/service.lua index 03529553..b48c379f 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -193,6 +193,20 @@ function mt:readText(uri, path) self._needCompile[uri] = true end +function mt:open(uri) + self._opening[uri] = true +end + +function mt:close(uri) + self._opening[uri] = nil +end + +function mt:reCompile() + for uri in pairs(self._opening) do + self._needCompile[uri] = true + end +end + function mt:loadVM(uri) local obj = self._file[uri] if not obj then @@ -287,6 +301,7 @@ return function () _file = {}, _needCompile = {}, _needDiagnostics = {}, + _opening = {}, _clock = -100, }, mt) return session diff --git a/server/src/workspace.lua b/server/src/workspace.lua index 356960a2..d14ad5d8 100644 --- a/server/src/workspace.lua +++ b/server/src/workspace.lua @@ -72,6 +72,7 @@ function mt:init(rootUri) local name = path:string():lower() self.files[name] = uriEncode(path) end + self:reset() end) end @@ -110,6 +111,7 @@ end function mt:reset() self.laoded = {} + self.lsp:reCompile() end return function (lsp, name, uri) |