aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2025-03-17 09:11:05 +0000
committerGitHub <noreply@github.com>2025-03-17 09:11:05 +0000
commitd0cda9d6c59d88314b67f251a1c13216424aebcf (patch)
treea4285ba08a7bfaf544826019939212480c50c40b
parent502324a7b5f875ba61d65444cee34146f47c8f74 (diff)
parent96e5b61be1b18159804f6d7209601f98d16f7a7d (diff)
downloadrneovim-d0cda9d6c59d88314b67f251a1c13216424aebcf.tar.gz
rneovim-d0cda9d6c59d88314b67f251a1c13216424aebcf.tar.bz2
rneovim-d0cda9d6c59d88314b67f251a1c13216424aebcf.zip
Merge pull request #32871 from ofseed/test-lsp
test(lsp): add some tests for LSP bugs
-rw-r--r--test/functional/plugin/lsp/inlay_hint_spec.lua22
-rw-r--r--test/functional/plugin/lsp/semantic_tokens_spec.lua33
2 files changed, 55 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua
index eefcf825b8..e410a54c31 100644
--- a/test/functional/plugin/lsp/inlay_hint_spec.lua
+++ b/test/functional/plugin/lsp/inlay_hint_spec.lua
@@ -7,6 +7,7 @@ local eq = t.eq
local dedent = t.dedent
local exec_lua = n.exec_lua
local insert = n.insert
+local feed = n.feed
local api = n.api
local clear_notrace = t_lsp.clear_notrace
@@ -369,6 +370,27 @@ test text
screen:expect({ grid = grid_without_inlay_hints, unchanged = true })
end)
+ it('refreshes hints on request', function()
+ exec_lua([[vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })]])
+ screen:expect({ grid = grid_with_inlay_hints })
+ feed('kibefore <Esc>')
+ screen:expect([[
+ before^ {1:01234}test text |
+ |*2
+ ]])
+ exec_lua(function()
+ vim.lsp.inlay_hint.on_refresh(
+ nil,
+ nil,
+ { method = 'workspace/inlayHint/refresh', client_id = client_id }
+ )
+ end)
+ screen:expect([[
+ {1:01234}before^ test text |
+ |*2
+ ]])
+ end)
+
after_each(function()
api.nvim_exec_autocmds('VimLeavePre', { modeline = false })
end)
diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua
index 9912bf2063..03dbf6baea 100644
--- a/test/functional/plugin/lsp/semantic_tokens_spec.lua
+++ b/test/functional/plugin/lsp/semantic_tokens_spec.lua
@@ -600,6 +600,39 @@ describe('semantic token highlighting', function()
}
end)
+ it('resets active request after receiving error responses from the server', function()
+ local error = { code = -32801, message = 'Content modified' }
+ exec_lua(function()
+ _G.server2 = _G._create_server({
+ capabilities = {
+ semanticTokensProvider = {
+ full = { delta = false },
+ },
+ },
+ handlers = {
+ -- There is same logic for handling nil responses and error responses,
+ -- so keep responses not nil.
+ --
+ -- if an error response was not be handled, this test will hang on here.
+ --- @param callback function
+ ['textDocument/semanticTokens/full'] = function(_, _, callback)
+ callback(error, vim.fn.json_decode(response))
+ end,
+ --- @param callback function
+ ['textDocument/semanticTokens/full/delta'] = function(_, _, callback)
+ callback(error, vim.fn.json_decode(response))
+ end,
+ },
+ })
+ return vim.lsp.start({ name = 'dummy', cmd = _G.server2.cmd })
+ end)
+ screen:expect([[
+ ^ |
+ {1:~ }|*14
+ |
+ ]])
+ end)
+
it('does not send delta requests if not supported by server', function()
insert(text)
exec_lua(function()