summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server-beta/src/proto/proto.lua4
-rw-r--r--server-beta/src/proto/provider.lua8
-rw-r--r--server-beta/src/pub/pub.lua6
-rw-r--r--server-beta/src/workspace/workspace.lua10
4 files changed, 13 insertions, 15 deletions
diff --git a/server-beta/src/proto/proto.lua b/server-beta/src/proto/proto.lua
index e851610a..1d8160c1 100644
--- a/server-beta/src/proto/proto.lua
+++ b/server-beta/src/proto/proto.lua
@@ -52,7 +52,7 @@ function m.notify(name, params)
io.stdout:write(buf)
end
-function m.request(name, params)
+function m.awaitRequest(name, params)
local id = reqCounter()
local buf = jsonrpc.encode {
id = id,
@@ -112,7 +112,7 @@ function m.listen()
subprocess.filemode(io.stdout, 'b')
io.stdin:setvbuf 'no'
io.stdout:setvbuf 'no'
- pub.syncTask('loadProto')
+ pub.task('loadProto')
end
return m
diff --git a/server-beta/src/proto/provider.lua b/server-beta/src/proto/provider.lua
index ea1fb203..7527ea16 100644
--- a/server-beta/src/proto/provider.lua
+++ b/server-beta/src/proto/provider.lua
@@ -8,7 +8,7 @@ local workspace = require 'workspace'
local config = require 'config'
local function updateConfig()
- local configs = proto.request('workspace/configuration', {
+ local configs = proto.awaitRequest('workspace/configuration', {
items = {
{
scopeUri = workspace.uri,
@@ -67,7 +67,7 @@ end)
proto.on('initialized', function (params)
updateConfig()
- proto.request('client/registerCapability', {
+ proto.awaitRequest('client/registerCapability', {
registrations = {
-- 监视文件变化
{
@@ -89,9 +89,7 @@ proto.on('initialized', function (params)
}
}
})
- await.create(function ()
- workspace.preload()
- end)
+ await.create(workspace.awaitPreload)
return true
end)
diff --git a/server-beta/src/pub/pub.lua b/server-beta/src/pub/pub.lua
index 0888dbc3..3e97fe9f 100644
--- a/server-beta/src/pub/pub.lua
+++ b/server-beta/src/pub/pub.lua
@@ -101,10 +101,10 @@ function m.popReport(brave, name, params)
xpcall(abil, log.error, params, brave)
end
---- 发布任务(异步)
+--- 发布任务
---@parma name string
---@param params any
-function m.task(name, params)
+function m.awaitTask(name, params)
local info = {
id = counter(),
name = name,
@@ -136,7 +136,7 @@ end
---@parma name string
---@param params any
---@param callback function
-function m.syncTask(name, params, callback)
+function m.task(name, params, callback)
local info = {
id = counter(),
name = name,
diff --git a/server-beta/src/workspace/workspace.lua b/server-beta/src/workspace/workspace.lua
index c8deb001..79fd03df 100644
--- a/server-beta/src/workspace/workspace.lua
+++ b/server-beta/src/workspace/workspace.lua
@@ -41,7 +41,7 @@ function m.getIgnoreMatcher()
end
-- config.workspace.ignoreSubmodules
if config.config.workspace.ignoreSubmodules then
- local buf = pub.task('loadFile', furi.encode(m.path .. '/.gitmodules'))
+ local buf = pub.awaitTask('loadFile', furi.encode(m.path .. '/.gitmodules'))
if buf then
for path in buf:gmatch('path = ([^\r\n]+)') do
log.info('Ignore by .gitmodules:', path)
@@ -51,7 +51,7 @@ function m.getIgnoreMatcher()
end
-- config.workspace.useGitIgnore
if config.config.workspace.useGitIgnore then
- local buf = pub.task('loadFile', furi.encode(m.path .. '/.gitignore'))
+ local buf = pub.awaitTask('loadFile', furi.encode(m.path .. '/.gitignore'))
if buf then
for line in buf:gmatch '[^\r\n]+' do
log.info('Ignore by .gitignore:', line)
@@ -82,8 +82,8 @@ function m.isIgnored(uri)
return ignore(path)
end
---- 预读工作区内所有文件(异步)
-function m.preload()
+--- 预读工作区内所有文件
+function m.awaitPreload()
if not m.uri then
return
end
@@ -114,7 +114,7 @@ function m.preload()
return
end
max = max + 1
- pub.syncTask('loadFile', uri, function (text)
+ pub.task('loadFile', uri, function (text)
read = read + 1
--log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #text / 1000.0))
files.setText(uri, text)