diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-01-05 15:46:28 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-01-05 15:46:28 +0800 |
commit | 2877f084943ba30a9970cbe9a5cb0be844a2ec64 (patch) | |
tree | 06b86c4f7466ad8c0b416be234e1e381e73820da /script/provider | |
parent | 598d81b133c36a7bf392c8f9c22007b00a387e1e (diff) | |
download | lua-language-server-2877f084943ba30a9970cbe9a5cb0be844a2ec64.zip |
update
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/diagnostic.lua | 19 | ||||
-rw-r--r-- | script/provider/provider.lua | 32 |
2 files changed, 27 insertions, 24 deletions
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 |