summaryrefslogtreecommitdiff
path: root/server-beta/src/proto
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-09-20 17:57:28 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-09-20 17:57:28 +0800
commit8602723c7127e2fd6380c602650de62bd8afad02 (patch)
treee8a6050024cc9d789b044cb134c4bbc002534500 /server-beta/src/proto
parent3e4061cfa9e62e6fda785faa72de4b11fa6676ee (diff)
downloadlua-language-server-8602723c7127e2fd6380c602650de62bd8afad02.zip
简单的文件管理
Diffstat (limited to 'server-beta/src/proto')
-rw-r--r--server-beta/src/proto/init.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/server-beta/src/proto/init.lua b/server-beta/src/proto/init.lua
index 6e52fcbe..26fd5df8 100644
--- a/server-beta/src/proto/init.lua
+++ b/server-beta/src/proto/init.lua
@@ -3,6 +3,7 @@ local util = require 'utility'
local cap = require 'proto.capability'
local pub = require 'pub'
local task = require 'task'
+local files = require 'files'
proto.on('initialize', function (params)
--log.debug(util.dump(params))
@@ -38,10 +39,16 @@ proto.on('textDocument/didOpen', function (params)
local doc = params.textDocument
local uri = doc.uri
local text = doc.text
- local state = pub.task('compile', text)
+ files.open(uri)
+ files.setText(uri, text)
+ local ast = pub.task('compile', text)
+ files.setAst(uri, ast)
end)
proto.on('textDocument/didClose', function (params)
+ local doc = params.textDocument
+ local uri = doc.uri
+ files.close(uri)
end)
proto.on('textDocument/didChange', function (params)
@@ -49,7 +56,9 @@ proto.on('textDocument/didChange', function (params)
local change = params.contentChanges
local uri = doc.uri
local text = change[1].text
- local state = pub.task('compile', text)
+ files.setText(uri, text)
+ local ast = pub.task('compile', text)
+ files.setAst(uri, ast)
end)
return proto