Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lsp): remove warnings from "Partial Result Progress" #148

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor(lsp): add debugging info
  • Loading branch information
linrongbin16 committed Jul 11, 2024
commit 0590f8d1fb14bafb3bd227ae81e382d89b6772cc
6 changes: 3 additions & 3 deletions .nvim.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
60 changes: 36 additions & 24 deletions lua/lsp-progress.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ local function update_progress(client, progress)
cli:add_series(token, ss)
-- start spin, it will also notify user at a fixed rate
spin(client_id, token)
-- logger.debug(
-- "|progress_handler| add new series to client(%s): %s",
-- vim.inspect(cli),
-- vim.inspect(ss)
-- )
-- logger.debug(
-- "|progress_handler| add new series to client(%s): %s",
-- vim.inspect(cli),
-- vim.inspect(ss)
-- )
elseif value.kind == "report" then
local ss = cli:get_series(token)
if ss then
Expand All @@ -207,28 +207,40 @@ local function update_progress(client, progress)
-- )
end
else
-- The `$/progress` actually has several types:
-- 1. Work Done Progress: The `value` payload has a `kind` field to tell user "begin", "report" and "end".
-- 2. Partial Result Progress: The `value` has no such `kind` field, i.e. the `kind` is `nil`.
--
-- References:
-- Progress Support: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#progress
-- Work Done Progress: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workDoneProgress
-- Partial Result Progress: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#partialResults
if value.kind ~= "end" then
-- It's a partial result progress
logger.warn(
"|lsp-progress.progress_handler| Unknown message kind `%s` from client %s",
"|lsp-progress.progress_handler| Unknown message kind `%s` from client %s, progress: %s",
value.kind,
vim.inspect(cli)
vim.inspect(cli),
vim.inspect(progress)
)
end
if cli:has_series(token) then
local ss = cli:get_series(token)
ss:finish(value.message)
cli:format()
-- logger.debug(
-- "|progress_handler| series is done in client(%s): %s",
-- vim.inspect(cli),
-- vim.inspect(ss)
-- )
-- else
-- logger.debug(
-- "|lsp-progress.progress_handler| Series (token: %s) not found in client %s when ending",
-- token,
-- vim.inspect(cli)
-- )
else
-- It's a work done progress
if cli:has_series(token) then
local ss = cli:get_series(token)
ss:finish(value.message)
cli:format()
-- logger.debug(
-- "|progress_handler| series is done in client(%s): %s",
-- vim.inspect(cli),
-- vim.inspect(ss)
-- )
-- else
-- logger.debug(
-- "|lsp-progress.progress_handler| Series (token: %s) not found in client %s when ending",
-- token,
-- vim.inspect(cli)
-- )
end
end
end

Expand Down Expand Up @@ -374,4 +386,4 @@ local M = {
_register_client = _register_client,
}

return M
return M
Loading