summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/files.lua2
-rw-r--r--script/provider/diagnostic.lua19
-rw-r--r--script/provider/provider.lua32
-rw-r--r--script/workspace/loading.lua2
-rw-r--r--script/workspace/workspace.lua5
5 files changed, 34 insertions, 26 deletions
diff --git a/script/files.lua b/script/files.lua
index d18fade3..fbc158ae 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -464,7 +464,7 @@ function m.compileState(uri, text)
end
return nil
end
- local prog <close> = progress.create(lang.script.WINDOW_COMPILING, 0.5)
+ local prog <close> = progress.create(ws.getScope(uri), lang.script.WINDOW_COMPILING, 0.5)
prog:setMessage(ws.getRelativePath(uri))
local clock = os.clock()
local state, err = parser.compile(text
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 4a6706bb..3b99b6b0 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -220,7 +220,7 @@ function m.doDiagnostic(uri)
local version = files.getVersion(uri)
local scp = ws.getScope(uri)
- local prog <close> = progress.create(lang.script.WINDOW_DIAGNOSING, 0.5)
+ local prog <close> = progress.create(scp, lang.script.WINDOW_DIAGNOSING, 0.5)
prog:setMessage(ws.getRelativePath(uri))
local syntax = m.syntaxErrors(uri, state)
@@ -249,7 +249,9 @@ function m.doDiagnostic(uri)
end
end
- if await.hasID('diagnosticsScope:' .. uri) then
+ m.coroutineUri[coroutine.running()] = uri
+
+ if await.hasID('diagnosticsScope:' .. scp.uri) then
scp:set('diagStepPush', nil)
else
local clock = os.clock()
@@ -262,6 +264,8 @@ function m.doDiagnostic(uri)
end
m.diagnostics(uri, diags)
+ await.sleep(1.0)
+ await.sleep(1.0)
pushResult()
scp:set('diagStepPush', nil)
end
@@ -344,11 +348,10 @@ function m.diagnosticsScope(uri, force)
end
await.close ('diagnosticsScope:' .. uri)
await.call(function () ---@async
- m.coroutineUri[coroutine.running()] = uri
await.sleep(delay)
m.diagnosticsAllClock = os.clock()
local clock = os.clock()
- local bar <close> = progress.create(lang.script.WORKSPACE_DIAGNOSTIC, 1)
+ local bar <close> = progress.create(ws.getScope(uri), lang.script.WORKSPACE_DIAGNOSTIC, 1)
local cancelled
bar:onCancel(function ()
log.debug('Cancel workspace diagnostics')
@@ -375,10 +378,10 @@ function m.diagnosticsScope(uri, force)
end
function m.checkStepResult(uri)
- if await.hasID('diagnosticsScope:' .. uri) then
+ local scp = ws.getScope(uri)
+ if await.hasID('diagnosticsScope:' .. scp.uri) then
return
end
- local scp = ws.getScope(uri)
local stepPush = scp:get 'diagStepPush'
if stepPush then
stepPush()
@@ -422,11 +425,11 @@ files.watch(function (ev, uri) ---@async
m.clear(uri)
m.refresh(uri)
elseif ev == 'update' then
- if ws.isReady() then
+ if ws.isReady(uri) then
m.refresh(uri)
end
elseif ev == 'open' then
- if ws.isReady() then
+ if ws.isReady(uri) then
xpcall(m.doDiagnostic, log.error, uri)
end
elseif ev == 'close' then
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 77c45778..10376239 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -115,7 +115,7 @@ m.register 'initialized'{
---@async
function (params)
files.init()
- local _ <close> = progress.create(lang.script.WINDOW_INITIALIZING, 0.5)
+ local _ <close> = progress.create(workspace.getFirstScope(), lang.script.WINDOW_INITIALIZING, 0.5)
updateConfig()
local registrations = {}
@@ -266,7 +266,7 @@ m.register 'textDocument/hover' {
if not config.get(uri, 'Lua.hover.enable') then
return
end
- if not workspace.isReady() then
+ if not workspace.isReady(uri) then
local count, max = workspace.getLoadingProcess(uri)
return {
contents = {
@@ -275,7 +275,7 @@ m.register 'textDocument/hover' {
}
}
end
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_HOVER, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_HOVER, 0.5)
local core = require 'core.hover'
if not files.exists(uri) then
return nil
@@ -304,7 +304,7 @@ m.register 'textDocument/definition' {
if not files.exists(uri) then
return nil
end
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_DEFINITION, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_DEFINITION, 0.5)
local core = require 'core.definition'
local pos = converter.unpackPosition(uri, params.position)
local result = core(uri, pos)
@@ -343,7 +343,7 @@ m.register 'textDocument/typeDefinition' {
if not files.exists(uri) then
return nil
end
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_TYPE_DEFINITION, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_TYPE_DEFINITION, 0.5)
local core = require 'core.type-definition'
local pos = converter.unpackPosition(uri, params.position)
local result = core(uri, pos)
@@ -382,7 +382,7 @@ m.register 'textDocument/references' {
if not files.exists(uri) then
return nil
end
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_REFERENCE, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_REFERENCE, 0.5)
local core = require 'core.reference'
local pos = converter.unpackPosition(uri, params.position)
local result = core(uri, pos)
@@ -433,7 +433,7 @@ m.register 'textDocument/rename' {
if not files.exists(uri) then
return nil
end
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_RENAME, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_RENAME, 0.5)
local core = require 'core.rename'
local pos = converter.unpackPosition(uri, params.position)
local result = core.rename(uri, pos, params.newName)
@@ -479,7 +479,7 @@ m.register 'textDocument/completion' {
---@async
function (params)
local uri = files.getRealUri(params.textDocument.uri)
- if not workspace.isReady() then
+ if not workspace.isReady(uri) then
local count, max = workspace.getLoadingProcess(uri)
return {
{
@@ -493,7 +493,7 @@ m.register 'textDocument/completion' {
}
}
end
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_COMPLETION, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_COMPLETION, 0.5)
--log.info(util.dump(params))
local core = require 'core.completion'
--log.debug('textDocument/completion')
@@ -639,7 +639,7 @@ m.register 'textDocument/signatureHelp' {
if not files.exists(uri) then
return nil
end
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SIGNATURE, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_SIGNATURE, 0.5)
local pos = converter.unpackPosition(uri, params.position)
local core = require 'core.signature'
local results = core(uri, pos)
@@ -679,7 +679,7 @@ m.register 'textDocument/documentSymbol' {
function (params)
local uri = files.getRealUri(params.textDocument.uri)
workspace.awaitReady(uri)
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SYMBOL, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_SYMBOL, 0.5)
local core = require 'core.document-symbol'
local symbols = core(uri)
@@ -780,7 +780,7 @@ m.register 'workspace/symbol' {
abortByFileUpdate = true,
---@async
function (params)
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_WS_SYMBOL, 0.5)
+ local _ <close> = progress.create(workspace.getFirstScope(), lang.script.WINDOW_PROCESSING_WS_SYMBOL, 0.5)
local core = require 'core.workspace-symbol'
local symbols = core(params.query)
@@ -814,7 +814,7 @@ m.register 'textDocument/semanticTokens/full' {
function (params)
local uri = files.getRealUri(params.textDocument.uri)
workspace.awaitReady(uri)
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_FULL, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_SEMANTIC_FULL, 0.5)
local core = require 'core.semantic-tokens'
local results = core(uri, 0, math.huge)
return {
@@ -829,7 +829,7 @@ m.register 'textDocument/semanticTokens/range' {
function (params)
local uri = files.getRealUri(params.textDocument.uri)
workspace.awaitReady(uri)
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5)
local core = require 'core.semantic-tokens'
local cache = files.getOpenedCache(uri)
local start, finish
@@ -925,7 +925,7 @@ m.register 'textDocument/onTypeFormatting' {
function (params)
local uri = files.getRealUri(params.textDocument.uri)
workspace.awaitReady(uri)
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_TYPE_FORMATTING, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_TYPE_FORMATTING, 0.5)
local ch = params.ch
if not files.exists(uri) then
return nil
@@ -1001,7 +1001,7 @@ do
workspace.awaitReady(uri)
local edits = {}
local hint = require 'core.hint'
- local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_HINT, 0.5)
+ local _ <close> = progress.create(workspace.getScope(uri), lang.script.WINDOW_PROCESSING_HINT, 0.5)
for _, visible in ipairs(visibles) do
local piece = hint(uri, visible.start, visible.finish)
if piece then
diff --git a/script/workspace/loading.lua b/script/workspace/loading.lua
index cbcfa567..7730946b 100644
--- a/script/workspace/loading.lua
+++ b/script/workspace/loading.lua
@@ -159,7 +159,7 @@ local m = {}
function m.create(scp)
local loading = setmetatable({
scp = scp,
- _bar = progress.create(lang.script('WORKSPACE_LOADING', scp.uri)),
+ _bar = progress.create(scp, lang.script('WORKSPACE_LOADING', scp.uri)),
_stash = {},
_cache = {},
}, mt)
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index 4baacc24..999f2e11 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -455,6 +455,11 @@ function m.getScope(uri)
or scope.fallback
end
+---@return scope
+function m.getFirstScope()
+ return m.folders[1] or scope.fallback
+end
+
---等待工作目录加载完成
---@async
function m.awaitReady(uri)