aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp
diff options
context:
space:
mode:
authorIlia Choly <ilia.choly@gmail.com>2024-05-23 09:17:53 -0400
committerGitHub <noreply@github.com>2024-05-23 15:17:53 +0200
commitaf200c10cf9d117a14ebf9f2e9c666721a1090d6 (patch)
tree96f4e94ed24dff6a0ddea56d2c19bf96731470cd /test/functional/plugin/lsp
parent2908f71dc9e9591f97e0f9d70dbc8d8b18f9e475 (diff)
downloadrneovim-af200c10cf9d117a14ebf9f2e9c666721a1090d6.tar.gz
rneovim-af200c10cf9d117a14ebf9f2e9c666721a1090d6.tar.bz2
rneovim-af200c10cf9d117a14ebf9f2e9c666721a1090d6.zip
fix(lsp): check if buffer was detached in on_init callback (#28914)
Co-authored-by: Jongwook Choi <wookayin@gmail.com>
Diffstat (limited to 'test/functional/plugin/lsp')
-rw-r--r--test/functional/plugin/lsp/inlay_hint_spec.lua12
-rw-r--r--test/functional/plugin/lsp/semantic_tokens_spec.lua34
-rw-r--r--test/functional/plugin/lsp/testutil.lua3
3 files changed, 24 insertions, 25 deletions
diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua
index 3d0fcc31ff..d3b5ae0e4e 100644
--- a/test/functional/plugin/lsp/inlay_hint_spec.lua
+++ b/test/functional/plugin/lsp/inlay_hint_spec.lua
@@ -70,8 +70,8 @@ before_each(function()
inlayHintProvider = true,
},
handlers = {
- ['textDocument/inlayHint'] = function()
- return vim.json.decode(response)
+ ['textDocument/inlayHint'] = function(_, _, callback)
+ callback(nil, vim.json.decode(response))
end,
}
})
@@ -106,8 +106,8 @@ describe('vim.lsp.inlay_hint', function()
inlayHintProvider = true,
},
handlers = {
- ['textDocument/inlayHint'] = function()
- return {}
+ ['textDocument/inlayHint'] = function(_, _, callback)
+ callback(nil, {})
end,
}
})
@@ -206,8 +206,8 @@ describe('vim.lsp.inlay_hint', function()
inlayHintProvider = true,
},
handlers = {
- ['textDocument/inlayHint'] = function()
- return { expected2 }
+ ['textDocument/inlayHint'] = function(_, _, callback)
+ callback(nil, { expected2 })
end,
}
})
diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua
index 60f02b0521..7908c5d2e7 100644
--- a/test/functional/plugin/lsp/semantic_tokens_spec.lua
+++ b/test/functional/plugin/lsp/semantic_tokens_spec.lua
@@ -95,11 +95,11 @@ describe('semantic token highlighting', function()
},
},
handlers = {
- ['textDocument/semanticTokens/full'] = function()
- return vim.fn.json_decode(response)
+ ['textDocument/semanticTokens/full'] = function(_, _, callback)
+ callback(nil, vim.fn.json_decode(response))
end,
- ['textDocument/semanticTokens/full/delta'] = function()
- return vim.fn.json_decode(edit_response)
+ ['textDocument/semanticTokens/full/delta'] = function(_, _, callback)
+ callback(nil, vim.fn.json_decode(edit_response))
end,
}
})
@@ -560,11 +560,11 @@ describe('semantic token highlighting', function()
},
},
handlers = {
- ['textDocument/semanticTokens/full'] = function()
- return nil
+ ['textDocument/semanticTokens/full'] = function(_, _, callback)
+ callback(nil, nil)
end,
['textDocument/semanticTokens/full/delta'] = function()
- return nil
+ callback(nil, nil)
end,
}
})
@@ -608,11 +608,11 @@ describe('semantic token highlighting', function()
},
},
handlers = {
- ['textDocument/semanticTokens/full'] = function()
- return vim.fn.json_decode(response)
+ ['textDocument/semanticTokens/full'] = function(_, _, callback)
+ callback(nil, vim.fn.json_decode(response))
end,
- ['textDocument/semanticTokens/full/delta'] = function()
- return vim.fn.json_decode(edit_response)
+ ['textDocument/semanticTokens/full/delta'] = function(_, _, callback)
+ callback(nil, vim.fn.json_decode(edit_response))
end,
}
})
@@ -1075,8 +1075,8 @@ b = "as"]],
},
},
handlers = {
- ['textDocument/semanticTokens/full'] = function()
- return vim.fn.json_decode(resp)
+ ['textDocument/semanticTokens/full'] = function(_, _, callback)
+ callback(nil, vim.fn.json_decode(resp))
end,
}
})
@@ -1461,11 +1461,11 @@ int main()
},
},
handlers = {
- ['textDocument/semanticTokens/full'] = function()
- return vim.fn.json_decode(resp1)
+ ['textDocument/semanticTokens/full'] = function(_, _, callback)
+ callback(nil, vim.fn.json_decode(resp1))
end,
- ['textDocument/semanticTokens/full/delta'] = function()
- return vim.fn.json_decode(resp2)
+ ['textDocument/semanticTokens/full/delta'] = function(_, _, callback)
+ callback(nil, vim.fn.json_decode(resp2))
end,
}
})
diff --git a/test/functional/plugin/lsp/testutil.lua b/test/functional/plugin/lsp/testutil.lua
index 4d14752f2a..3430a1e1a3 100644
--- a/test/functional/plugin/lsp/testutil.lua
+++ b/test/functional/plugin/lsp/testutil.lua
@@ -39,8 +39,7 @@ M.create_server_definition = [[
})
local handler = handlers[method]
if handler then
- local response, err = handler(method, params)
- callback(err, response)
+ handler(method, params, callback)
elseif method == 'initialize' then
callback(nil, {
capabilities = opts.capabilities or {}