Native VBS and CMake builds of the server and every registered suite: protocol and document sync, VBS/compdb providers, stock GCC diagnostics (including in-process default profile preparation), the stock occurrence observer and hover/definition, the bounded Scheduler, C++ module graph, scan and artifact cache with real CMI production, the context-aware symbol index with schema-2 snapshot migration, navigation and guarded rename, reflection provenance with splice-origin extraction, index-backed completion and signature help, live GCC worker control with a registered DAP suite, and the Neovim and VS Code clients. VoidLibrary follows main. The private GCC 16.2.0 frontend is reproduced from the versioned patches and verified stepping reflection/template code with projected values 17/34 and 41/82.
110 lines
4.5 KiB
Lua
110 lines
4.5 KiB
Lua
-- Run with nvim --headless -u NONE -i NONE -l tests/native/NeovimClient.lua.
|
|
local server = assert(vim.env.VLS_SERVER, "set VLS_SERVER to the installed vls")
|
|
local adapter = assert(vim.env.VLS_DAP, "set VLS_DAP to the installed vls-dap")
|
|
local trace = assert(vim.env.VLS_TRACE, "set VLS_TRACE to integral-17.vls")
|
|
local plugin = assert(vim.env.VLS_NVIM_DAP, "set VLS_NVIM_DAP to the nvim-dap checkout")
|
|
local repository = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h:h:h")
|
|
vim.opt.runtimepath:prepend(plugin)
|
|
vim.opt.runtimepath:prepend(repository .. "/clients/neovim")
|
|
|
|
local vls = require("vls")
|
|
vls.setup({ server = server, dap_adapter = adapter })
|
|
dofile(repository .. "/clients/neovim/plugin/vls.lua")
|
|
local dap = require("dap")
|
|
|
|
local function wait_for(label, predicate, timeout)
|
|
assert(vim.wait(timeout or 10000, predicate, 25), "timed out waiting for " .. label)
|
|
end
|
|
|
|
local work = vim.fn.tempname()
|
|
assert(vim.fn.mkdir(work, "p") == 1)
|
|
local file = work .. "/unit.cpp"
|
|
assert(vim.fn.writefile({ "int value = 17;", "int read() { return value; }" }, file) == 0)
|
|
vim.cmd.edit(vim.fn.fnameescape(file))
|
|
local buffer = vim.api.nvim_get_current_buf()
|
|
vim.bo[buffer].filetype = "cpp"
|
|
|
|
local client, err = vls.start(buffer)
|
|
assert(client, err)
|
|
wait_for("LSP initialization", function() return client.initialized end)
|
|
|
|
local status, status_err = vls.status(buffer)
|
|
assert(not status_err and type(status.state) == "string", vim.inspect({ status, status_err }))
|
|
local analysis, analysis_err = vls.analysis_status(buffer)
|
|
assert(not analysis_err and type(analysis.state) == "string",
|
|
vim.inspect({ analysis, analysis_err }))
|
|
|
|
local messages = {}
|
|
local original_notify = vim.notify
|
|
vim.notify = function(message) table.insert(messages, message) end
|
|
vim.cmd("VlsStatus")
|
|
vim.notify = original_notify
|
|
wait_for("status notification", function() return #messages > 0 end)
|
|
assert(messages[1]:find("VoidLanguageServer provider status", 1, true), messages[1])
|
|
|
|
local stops = 0
|
|
dap.listeners.after.event_stopped.vls_client_test = function(_, event)
|
|
assert(event.threadId == 1)
|
|
stops = stops + 1
|
|
end
|
|
local replay, replay_err = vls.replay(trace)
|
|
assert(replay, replay_err)
|
|
wait_for("first replay stop", function() return stops == 1 and dap.session() ~= nil end)
|
|
local session = assert(dap.session())
|
|
|
|
local function request(method, arguments)
|
|
local done, failure, body = false, nil, nil
|
|
session:request(method, arguments, function(problem, result)
|
|
failure, body, done = problem, result, true
|
|
end)
|
|
wait_for(method, function() return done end)
|
|
assert(not failure, vim.inspect(failure))
|
|
return body
|
|
end
|
|
|
|
local function read_value()
|
|
local frame = assert(request("stackTrace", { threadId = 1 }).stackFrames[1])
|
|
local scope = request("scopes", { frameId = frame.id }).scopes[1]
|
|
local variables = request("variables", { variablesReference = scope.variablesReference })
|
|
for _, variable in ipairs(variables.variables) do
|
|
if variable.name == "Result" then
|
|
return variable.value, frame.name
|
|
end
|
|
end
|
|
error("recorded result is missing")
|
|
end
|
|
|
|
local value, name = read_value()
|
|
assert(value == "17" and name == "reflected_value", vim.inspect({ value, name }))
|
|
local first = assert(vls.session())
|
|
assert(type(first.sessionId) == "string" and type(first.generation) == "number")
|
|
local page = assert(vls.timeline(0, 4))
|
|
assert(page.sessionId == first.sessionId and #page.events > 0, vim.inspect(page))
|
|
local source = assert(vls.source())
|
|
assert(vim.fn.sha256(source) == first.sourceSha256)
|
|
|
|
dap.continue()
|
|
wait_for("second replay stop", function() return stops == 2 and session.stopped_thread_id == 1 end)
|
|
value, name = read_value()
|
|
assert(value == "34" and name == "twice", vim.inspect({ value, name }))
|
|
local stale, stale_err = vls.timeline()
|
|
assert(not stale and stale_err and stale_err:find("stale", 1, true),
|
|
vim.inspect({ stale, stale_err }))
|
|
local second = assert(vls.session())
|
|
assert(second.generation > first.generation)
|
|
local page2 = assert(vls.timeline(0, 2))
|
|
assert(page2.generation == second.generation)
|
|
vim.cmd("VlsTimeline 0 2")
|
|
local view = vim.api.nvim_get_current_buf()
|
|
local lines = vim.api.nvim_buf_get_lines(view, 0, -1, false)
|
|
assert(lines[1] and lines[1]:find("session", 1, true), vim.inspect(lines))
|
|
vim.cmd("close")
|
|
|
|
vls.stop()
|
|
wait_for("replay shutdown", function() return dap.session() == nil end)
|
|
client:stop()
|
|
wait_for("server shutdown", function()
|
|
return #vim.lsp.get_clients({ name = "VoidLanguageServer" }) == 0
|
|
end)
|
|
print("Neovim client passed: LSP status, replay session, timeline, source and stale rejection")
|