summaryrefslogtreecommitdiff
path: root/server-beta/src
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src')
-rw-r--r--server-beta/src/proto/provider.lua80
-rw-r--r--server-beta/src/workspace/workspace.lua3
2 files changed, 80 insertions, 3 deletions
diff --git a/server-beta/src/proto/provider.lua b/server-beta/src/proto/provider.lua
index 0b9c285e..fbaba8ca 100644
--- a/server-beta/src/proto/provider.lua
+++ b/server-beta/src/proto/provider.lua
@@ -6,6 +6,53 @@ local files = require 'files'
local proto = require 'proto.proto'
local inte = require 'proto.interface'
local workspace = require 'workspace'
+local config = require 'config'
+
+local function updateConfig()
+ local configs = proto.request('workspace/configuration', {
+ items = {
+ {
+ scopeUri = workspace.uri,
+ section = 'Lua',
+ },
+ {
+ scopeUri = workspace.uri,
+ section = 'files.associations',
+ },
+ {
+ scopeUri = workspace.uri,
+ section = 'files.exclude',
+ }
+ },
+ })
+
+ local updated = configs[1]
+ local other = {
+ associations = configs[2],
+ exclude = configs[3],
+ }
+
+ local oldConfig = util.deepCopy(config.config)
+ local oldOther = util.deepCopy(config.other)
+ config:setConfig(updated, other)
+ local newConfig = config.config
+ local newOther = config.other
+ if not util.equal(oldConfig.runtime, newConfig.runtime) then
+ end
+ if not util.equal(oldConfig.diagnostics, newConfig.diagnostics) then
+ end
+ if newConfig.completion.enable then
+ else
+ end
+ if not util.equal(oldConfig.plugin, newConfig.plugin) then
+ end
+ if not util.equal(oldConfig.workspace, newConfig.workspace)
+ or not util.equal(oldConfig.plugin, newConfig.plugin)
+ or not util.equal(oldOther.associations, newOther.associations)
+ or not util.equal(oldOther.exclude, newOther.exclude)
+ then
+ end
+end
proto.on('initialize', function (params)
--log.debug(util.dump(params))
@@ -13,9 +60,6 @@ proto.on('initialize', function (params)
local name = params.workspaceFolders[1].name
local uri = params.workspaceFolders[1].uri
workspace.init(name, uri)
- task.create(function ()
- workspace.preload()
- end)
end
return {
capabilities = cap.initer,
@@ -23,6 +67,32 @@ proto.on('initialize', function (params)
end)
proto.on('initialized', function (params)
+ updateConfig()
+ proto.request('client/registerCapability', {
+ registrations = {
+ -- 监视文件变化
+ {
+ id = '0',
+ method = 'workspace/didChangeWatchedFiles',
+ registerOptions = {
+ watchers = {
+ {
+ globPattern = '**/',
+ kind = 1 | 2 | 4,
+ }
+ },
+ },
+ },
+ -- 配置变化
+ {
+ id = '1',
+ method = 'workspace/didChangeConfiguration',
+ }
+ }
+ })
+ task.create(function ()
+ workspace.preload()
+ end)
return true
end)
@@ -36,6 +106,10 @@ proto.on('shutdown', function ()
return true
end)
+proto.on('workspace/configuration', function ()
+ updateConfig()
+end)
+
proto.on('textDocument/didOpen', function (params)
local doc = params.textDocument
local uri = doc.uri
diff --git a/server-beta/src/workspace/workspace.lua b/server-beta/src/workspace/workspace.lua
index 8508e5c5..1684f224 100644
--- a/server-beta/src/workspace/workspace.lua
+++ b/server-beta/src/workspace/workspace.lua
@@ -13,6 +13,9 @@ end
--- 预读工作区内所有文件(异步)
function m.preload()
+ if not m.uri then
+ return
+ end
log.info('Preload start.')
local function scan(dir, callback)
local result = pub.task('listDirectory', dir)