Skip to content

Commit 130a69f

Browse files
committed
use preview
1 parent 16c576d commit 130a69f

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

script/provider/diagnostic.lua

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,7 @@ function m.diagnosticsScope(uri, force)
489489
end
490490

491491
---@async
492-
function m.pullDiagnosticScope()
493-
local results = {}
492+
function m.pullDiagnosticScope(callback)
494493
local processing = 0
495494

496495
for _, scp in ipairs(scope.folders) do
@@ -515,7 +514,7 @@ function m.pullDiagnosticScope()
515514
m.awaitDiagnosticsScope(scp.uri, function (fileUri)
516515
local suc, result, unchanged = xpcall(m.pullDiagnostic, log.error, fileUri, true)
517516
if suc then
518-
results[#results+1] = {
517+
callback {
519518
uri = fileUri,
520519
result = result,
521520
unchanged = unchanged,
@@ -527,18 +526,21 @@ function m.pullDiagnosticScope()
527526
end
528527
end
529528

530-
while processing > 0 do
531-
await.sleep(0.1)
529+
-- sleep for ever
530+
while true do
531+
await.sleep(1.0)
532532
end
533-
534-
return results
535533
end
536534

537535
---@param uri uri
538536
---@return 'server' | 'client'
539537
function m.getOwner(uri)
540-
--TODO
541-
return 'client'
538+
-- TODO
539+
if PREVIEW then
540+
return 'client'
541+
else
542+
return 'server'
543+
end
542544
end
543545

544546
function m.refreshClient()

script/provider/provider.lua

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,7 @@ m.register 'inlayHint/resolve' {
12131213
}
12141214

12151215
m.register 'textDocument/diagnostic' {
1216+
preview = true,
12161217
capability = {
12171218
diagnosticProvider = {
12181219
identifier = 'identifier',
@@ -1245,9 +1246,10 @@ m.register 'textDocument/diagnostic' {
12451246
}
12461247

12471248
m.register 'workspace/diagnostic' {
1249+
preview = true,
12481250
capability = {
12491251
diagnosticProvider = {
1250-
workspaceDiagnostics = true,
1252+
workspaceDiagnostics = false,
12511253
}
12521254
},
12531255
---@async
@@ -1258,18 +1260,16 @@ m.register 'workspace/diagnostic' {
12581260
excepts[#excepts+1] = id.value
12591261
end
12601262
core.clearCacheExcept(excepts)
1261-
local results = core.pullDiagnosticScope()
1262-
local items = {}
1263-
for i, result in ipairs(results) do
1263+
local function convertItem(result)
12641264
if result.unchanged then
1265-
items[i] = {
1265+
return {
12661266
kind = 'unchanged',
12671267
resultId = result.uri,
12681268
uri = result.uri,
12691269
version = result.version,
12701270
}
12711271
else
1272-
items[i] = {
1272+
return {
12731273
kind = 'full',
12741274
resultId = result.uri,
12751275
items = result.result or {},
@@ -1278,9 +1278,17 @@ m.register 'workspace/diagnostic' {
12781278
}
12791279
end
12801280
end
1281-
return {
1282-
items = items,
1283-
}
1281+
core.pullDiagnosticScope(function (result)
1282+
proto.notify('$/progress', {
1283+
token = params.partialResultToken,
1284+
value = {
1285+
items = {
1286+
convertItem(result)
1287+
}
1288+
}
1289+
})
1290+
end)
1291+
return { items = {} }
12841292
end
12851293
}
12861294

0 commit comments

Comments
 (0)