Skip to content

Commit

Permalink
fixup! refactor(lsp): replace util.buf_versions with changedtick
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed May 23, 2024
1 parent 289d52a commit 1613f60
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
10 changes: 10 additions & 0 deletions runtime/lua/vim/lsp/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2199,6 +2199,16 @@ function M._refresh(method, opts)
end
end

---@nodoc
---@deprecated
---@type table<integer,integer>
M.buf_versions = setmetatable({}, {
__index = function(_, bufnr)
vim.deprecate('vim.lsp.util.buf_versions', 'vim.b.changedtick', '0.12')
return vim.b[bufnr].changedtick
end,
})

M._get_line_byte_from_position = get_line_byte_from_position

return M
24 changes: 12 additions & 12 deletions test/functional/plugin/lsp/semantic_tokens_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,14 @@ describe('semantic token highlighting', function()
end)

it('buffer is highlighted when attached', function()
insert(text)
exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_win_set_buf(0, bufnr)
vim.bo[bufnr].filetype = 'some-filetype'
client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
]])

insert(text)

screen:expect {
grid = [[
#include <iostream> |
Expand All @@ -141,6 +140,7 @@ describe('semantic token highlighting', function()
end)

it('use LspTokenUpdate and highlight_token', function()
insert(text)
exec_lua([[
vim.api.nvim_create_autocmd("LspTokenUpdate", {
callback = function(args)
Expand All @@ -157,8 +157,6 @@ describe('semantic token highlighting', function()
client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
]])

insert(text)

screen:expect {
grid = [[
#include <iostream> |
Expand All @@ -180,14 +178,17 @@ describe('semantic token highlighting', function()
end)

it('buffer is unhighlighted when client is detached', function()
insert(text)

exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_win_set_buf(0, bufnr)
client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
vim.wait(1000, function()
return #server.messages > 1
end)
]])

insert(text)

exec_lua([[
vim.notify = function() end
vim.lsp.buf_detach_client(bufnr, client_id)
Expand Down Expand Up @@ -331,14 +332,13 @@ describe('semantic token highlighting', function()
end)

it('buffer is re-highlighted when force refreshed', function()
insert(text)
exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_win_set_buf(0, bufnr)
client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
]])

insert(text)

screen:expect {
grid = [[
#include <iostream> |
Expand Down Expand Up @@ -412,13 +412,14 @@ describe('semantic token highlighting', function()
end)

it('updates highlights with delta request on buffer change', function()
insert(text)

exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_win_set_buf(0, bufnr)
client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
]])

insert(text)
screen:expect {
grid = [[
#include <iostream> |
Expand Down Expand Up @@ -597,6 +598,7 @@ describe('semantic token highlighting', function()
end)

it('does not send delta requests if not supported by server', function()
insert(text)
exec_lua(
[[
local legend, response, edit_response = ...
Expand Down Expand Up @@ -625,7 +627,6 @@ describe('semantic token highlighting', function()
edit_response
)

insert(text)
screen:expect {
grid = [[
#include <iostream> |
Expand Down Expand Up @@ -1449,6 +1450,7 @@ int main()
},
}) do
it(test.it, function()
insert(test.text1)
exec_lua(create_server_definition)
exec_lua(
[[
Expand Down Expand Up @@ -1485,8 +1487,6 @@ int main()
test.response2
)

insert(test.text1)

test.expected_screen1()

local highlights = exec_lua([[
Expand Down

0 comments on commit 1613f60

Please sign in to comment.