diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-19 16:52:41 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-19 16:52:41 +0800 |
commit | c28a101f62fe7a118baa3eeccf13839249cae760 (patch) | |
tree | 65484ef74e5ab61100164e2647191c1d755d29b8 | |
parent | 7937b23423c65f41718edc684cb310d23e8da78c (diff) | |
download | lua-language-server-c28a101f62fe7a118baa3eeccf13839249cae760.zip |
关闭文件协议
-rw-r--r-- | src/lsp.lua | 11 | ||||
-rw-r--r-- | src/method/init.lua | 1 | ||||
-rw-r--r-- | src/method/textDocument/didClose.lua | 6 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/lsp.lua b/src/lsp.lua index 6c801a33..563f7919 100644 --- a/src/lsp.lua +++ b/src/lsp.lua @@ -118,6 +118,17 @@ function mt:loadText(uri) return obj.text end +function mt:removeText(uri, version) + local obj = self._file[uri] + if not obj then + return + end + if obj.version >= version then + return + end + self._file[uri] = nil +end + function mt:start(method) self._method = method while true do diff --git a/src/method/init.lua b/src/method/init.lua index 35a5a124..2674f7ae 100644 --- a/src/method/init.lua +++ b/src/method/init.lua @@ -8,5 +8,6 @@ init 'initialize' init 'textDocument/definition' init 'textDocument/didOpen' init 'textDocument/didChange' +init 'textDocument/didClose' return method diff --git a/src/method/textDocument/didClose.lua b/src/method/textDocument/didClose.lua new file mode 100644 index 00000000..3dcbd7d7 --- /dev/null +++ b/src/method/textDocument/didClose.lua @@ -0,0 +1,6 @@ +return function (lsp, params) + local doc = params.textDocument + log.debug('关闭文件:', doc.uri) + lsp:removeText(doc.uri, doc.version) + return true +end |