Implement the VLS roadmap on the native VBS build

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.
This commit is contained in:
faumaray committed 2026-12-05 14:06:50 +03:00
1 parent ca04975d54
commit da8003f6d4
310 files changed
+47552 -480

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
# VoidLanguageServer Neovim client
Thin Neovim LSP and replay-DAP integration for the installed `vls` and
`vls-dap`. All language, build and debugger semantics stay in the C++ server;
this plugin only starts processes, forwards user actions and renders bounded
replies.
## Setup
Add this directory to `runtimepath` (for example with your plugin manager), or
copy `plugin/` and `lua/` into a Neovim config directory. Neovim 0.12.6 or newer
is tested. `nvim-dap` is optional and only needed for replay.
```lua
require("vls").setup({
server = "/absolute/path/to/vls", -- default: vls on PATH
dap_adapter = "/absolute/path/to/vls-dap", -- default: vls-dap on PATH
gcc_profile = nil, -- absolute prepared GCC profile
provider = nil, -- auto, vbs, compdb or none
})
```
## Commands
| Command | Action |
| --- | --- |
| `:VlsStart` | Start the server for the current buffer and workspace root. |
| `:VlsStatus` | Request `voidLanguageServer/providerStatus`. |
| `:VlsAnalysisStatus` | Request `voidLanguageServer/analysisStatus`. |
| `:VlsReplay {trace}` | Launch `vls-dap --replay` on an absolute recording. |
| `:VlsSession` | Subscribe to the active replay session and generation. |
| `:VlsTimeline [start] [count]` | Render a bounded timeline page. |
| `:VlsFrames [start] [count]` | Render a bounded frame page. |
| `:VlsSource` | Render the captured source of the active replay. |
| `:VlsStop` | Terminate the replay. |
| `:VlsRename {name}` | Request a guarded rename and apply it transactionally. |
Replies from a generation older than the subscribed one are rejected instead
of being rendered. Rename edits are validated for every buffer before any is
touched; if a buffer write fails, all already-changed buffers are restored
exactly and the transaction reports the failure.
## Acceptance
```sh
VLS_SERVER="$PWD/build/native/profiles/debug/out/bin/vls" \
VLS_DAP="$PWD/build/native/profiles/debug/out/bin/vls-dap" \
VLS_TRACE="$PWD/tests/debug/fixtures/integral-17.vls" \
VLS_NVIM_DAP="$PWD/build/dap-evidence/nvim-dap" \
nvim --headless -u NONE -i NONE -l tests/native/NeovimClient.lua
```
The test uses a temporary workspace, does not read or write user
configuration, and checks LSP status, a real replay session, timeline paging,
captured source, stale-generation rejection and shutdown.
+367
View File
@@ -0,0 +1,367 @@
local M = {}
local defaults = {
server = nil,
dap_adapter = nil,
gcc_profile = nil,
provider = nil,
}
local state = { config = {}, replay = nil }
function M.setup(options)
state.config = vim.tbl_extend("force", defaults, options or {})
end
local function config()
return state.config
end
local function absolute(path)
return type(path) == "string" and vim.startswith(path, "/")
end
local function executable(name, explicit)
local path = explicit or vim.fn.exepath(name)
if path == nil or path == "" then
return nil, name .. " is not on PATH"
end
if not absolute(path) then
return nil, name .. " did not resolve to an absolute path"
end
return path
end
local function workspace_root(bufnr)
local name = vim.api.nvim_buf_get_name(bufnr)
if name == "" then
return vim.fn.getcwd()
end
local markers = { ".git", "vbs.lock", "compile_commands.json", "build.cpp" }
return vim.fs.root(name, markers) or vim.fn.fnamemodify(name, ":p:h")
end
local function client_for(bufnr)
for _, client in ipairs(vim.lsp.get_clients({ bufnr = bufnr })) do
if client.name == "VoidLanguageServer" then
return client
end
end
return nil
end
function M.start(bufnr)
bufnr = bufnr or vim.api.nvim_get_current_buf()
local server, err = executable("vls", config().server)
if not server then
return nil, err
end
local root = workspace_root(bufnr)
local cmd = { server, "--stdio", "--workspace-root", root }
if config().provider then
vim.list_extend(cmd, { "--provider", config().provider })
end
if config().gcc_profile then
if not absolute(config().gcc_profile) then
return nil, "gcc_profile must be an absolute path"
end
vim.list_extend(cmd, { "--gcc-profile", config().gcc_profile })
end
local id = vim.lsp.start({ name = "VoidLanguageServer", cmd = cmd, root_dir = root },
{ bufnr = bufnr })
if not id then
return nil, "could not start VoidLanguageServer"
end
return vim.lsp.get_client_by_id(id)
end
local function request_sync(bufnr, method, params)
bufnr = bufnr or vim.api.nvim_get_current_buf()
local client = client_for(bufnr)
if not client then
return nil, "no VoidLanguageServer attached to this buffer"
end
local reply = client:request_sync(method, params, 5000, bufnr)
if not reply then
return nil, method .. " timed out"
end
if reply.err then
return nil, vim.inspect(reply.err)
end
return reply.result
end
function M.status(bufnr)
bufnr = bufnr or vim.api.nvim_get_current_buf()
local client = client_for(bufnr)
if not client then
return nil, "no VoidLanguageServer attached to this buffer"
end
return request_sync(bufnr, "voidLanguageServer/providerStatus", {
textDocument = { uri = vim.uri_from_bufnr(bufnr) },
workspaceUri = vim.uri_from_fname(client.config.root_dir),
})
end
function M.analysis_status(bufnr)
bufnr = bufnr or vim.api.nvim_get_current_buf()
return request_sync(bufnr, "voidLanguageServer/analysisStatus", {
textDocument = { uri = vim.uri_from_bufnr(bufnr) },
})
end
local function dap()
local ok, module = pcall(require, "dap")
if ok then
return module
end
return nil
end
function M.replay(trace)
if not absolute(trace) then
return nil, "an absolute trace path is required"
end
if vim.fn.filereadable(trace) ~= 1 then
return nil, "trace is not readable: " .. trace
end
local adapter, err = executable("vls-dap", config().dap_adapter)
if not adapter then
return nil, err
end
local dap_module = dap()
if not dap_module then
return nil, "nvim-dap is not installed"
end
local name = "vls-replay"
dap_module.adapters[name] = { type = "executable", command = adapter,
args = { "--replay", trace } }
dap_module.configurations.cpp = dap_module.configurations.cpp or {}
for index = #dap_module.configurations.cpp, 1, -1 do
if dap_module.configurations.cpp[index].type == name then
table.remove(dap_module.configurations.cpp, index)
end
end
local configuration = { type = name, request = "launch",
name = "VLS replay " .. vim.fn.fnamemodify(trace, ":t") }
table.insert(dap_module.configurations.cpp, configuration)
state.replay = { trace = trace }
dap_module.run(configuration)
return state.replay
end
local function session()
local dap_module = dap()
if not dap_module then
return nil
end
return dap_module.session()
end
local function request(method, arguments)
local active = session()
if not active then
return nil, "no active replay session"
end
local done, failure, body = false, nil, nil
active:request(method, arguments, function(err, result)
failure, body, done = err, result, true
end)
if not vim.wait(5000, function() return done end, 10) then
return nil, method .. " timed out"
end
if failure then
return nil, vim.inspect(failure)
end
return body
end
function M.session()
local reply, err = request("vls/session")
if not reply then
return nil, err
end
state.replay = state.replay or {}
state.replay.schemaVersion = reply.schemaVersion
state.replay.sessionId = reply.sessionId
state.replay.generation = reply.generation
return reply
end
local function current()
local active = state.replay
if not active or not active.generation then
return nil, "subscribe with :VlsSession first"
end
return active
end
function M.timeline(start, count)
local active, err = current()
if not active then
return nil, err
end
local page, failure = request("vls/timeline", {
schemaVersion = active.schemaVersion,
sessionId = active.sessionId,
generation = active.generation,
start = start or 0,
count = count or 20,
})
if not page then
return nil, failure
end
if page.sessionId ~= active.sessionId or page.generation ~= active.generation then
return nil, "stale replay generation"
end
return page
end
function M.frames(start, count)
local active, err = current()
if not active then
return nil, err
end
local page, failure = request("vls/frames", {
schemaVersion = active.schemaVersion,
sessionId = active.sessionId,
generation = active.generation,
start = start or 0,
count = count or 20,
})
if not page then
return nil, failure
end
if page.sessionId ~= active.sessionId or page.generation ~= active.generation then
return nil, "stale replay generation"
end
return page
end
function M.source()
local active, err = current()
if not active then
return nil, err
end
local reply, failure = request("source", { sourceReference = 1 })
if not reply then
return nil, failure
end
return reply.content
end
function M.stop()
local dap_module = dap()
if dap_module and dap_module.session() then
dap_module.terminate()
end
state.replay = nil
end
function M.render(title, lines)
local buffer = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(buffer, 0, -1, false, lines)
vim.bo[buffer].bufhidden = "wipe"
vim.bo[buffer].filetype = "vls-inspection"
vim.api.nvim_buf_set_name(buffer, title .. " " .. os.date("%H:%M:%S"))
vim.cmd.split()
vim.api.nvim_win_set_buf(0, buffer)
return buffer
end
local function before(left, right)
if left.line ~= right.line then
return left.line > right.line
end
return left.character > right.character
end
-- Applies an LSP `changes` map transactionally. Every range is validated
-- before any buffer is touched; an application failure restores the exact
-- pre-edit lines and modified state of every buffer already changed.
function M.apply_workspace_edit(changes)
if type(changes) ~= "table" then
return nil, "no workspace edit changes"
end
local plan = {}
for uri, edits in pairs(changes) do
if type(edits) ~= "table" or #edits == 0 then
return nil, "empty edit list for " .. uri
end
local bufnr = vim.uri_to_bufnr(uri)
if not vim.api.nvim_buf_is_loaded(bufnr) then
vim.fn.bufload(bufnr)
end
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
local sorted = vim.deepcopy(edits)
table.sort(sorted, function(left, right)
return before(left.range.start, right.range.start)
end)
for _, edit in ipairs(sorted) do
local first, last = edit.range.start, edit.range["end"]
if first.line < 0 or first.line >= #lines or last.line < first.line or
last.line >= #lines or first.character < 0 or last.character < 0 or
first.character > #lines[first.line + 1] or
(last.line == first.line and last.character < first.character) then
return nil, "edit range is outside the buffer: " .. uri
end
if type(edit.newText) ~= "string" then
return nil, "edit text is not a string: " .. uri
end
end
plan[#plan + 1] = { bufnr = bufnr, uri = uri, lines = lines,
modified = vim.bo[bufnr].modified, edits = sorted }
end
table.sort(plan, function(left, right) return left.uri < right.uri end)
for _, item in ipairs(plan) do
if not vim.bo[item.bufnr].modifiable then
return nil, "buffer is not modifiable: " .. item.uri
end
end
local applied = {}
local ok, failure = pcall(function()
for _, item in ipairs(plan) do
applied[#applied + 1] = item
for _, edit in ipairs(item.edits) do
vim.api.nvim_buf_set_text(item.bufnr, edit.range.start.line,
edit.range.start.character, edit.range["end"].line,
edit.range["end"].character, { edit.newText })
end
end
end)
if ok then
return true
end
for _, item in ipairs(applied) do
vim.api.nvim_buf_set_lines(item.bufnr, 0, -1, false, item.lines)
vim.bo[item.bufnr].modified = item.modified
end
return nil, tostring(failure)
end
-- Requests a guarded rename from the server and applies it transactionally.
function M.rename(new_name, bufnr)
bufnr = bufnr or vim.api.nvim_get_current_buf()
local client = client_for(bufnr)
if not client then
return nil, "no VoidLanguageServer attached to this buffer"
end
local cursor = vim.api.nvim_win_get_cursor(0)
local reply = client:request_sync("textDocument/rename", {
textDocument = { uri = vim.uri_from_bufnr(bufnr) },
position = { line = cursor[1] - 1, character = cursor[2] },
newName = new_name,
}, 5000, bufnr)
if not reply then
return nil, "textDocument/rename timed out"
end
if reply.err then
return nil, (reply.err.message or vim.inspect(reply.err))
end
if not reply.result or not reply.result.changes then
return nil, "the server returned no rename changes"
end
return M.apply_workspace_edit(reply.result.changes)
end
return M
+92
View File
@@ -0,0 +1,92 @@
if vim.g.loaded_vls then
return
end
vim.g.loaded_vls = 1
local function report(subject, result, err)
if err then
vim.notify("VLS: " .. err, vim.log.levels.ERROR)
return
end
vim.notify(subject .. "\n" .. vim.inspect(result), vim.log.levels.INFO)
end
vim.api.nvim_create_user_command("VlsStart", function()
local client, err = require("vls").start()
report("VoidLanguageServer started",
client and { id = client.id, root = client.config.root_dir } or nil, err)
end, { desc = "Start VoidLanguageServer for the current buffer" })
vim.api.nvim_create_user_command("VlsStatus", function()
report("VoidLanguageServer provider status", require("vls").status())
end, { desc = "Request provider status for the current document" })
vim.api.nvim_create_user_command("VlsAnalysisStatus", function()
report("VoidLanguageServer analysis status", require("vls").analysis_status())
end, { desc = "Request semantic analysis status for the current document" })
vim.api.nvim_create_user_command("VlsReplay", function(options)
local trace = vim.fn.fnamemodify(options.args, ":p")
report("VoidLanguageServer replay", require("vls").replay(trace))
end, { nargs = 1, complete = "file", desc = "Replay an absolute VLS recording" })
vim.api.nvim_create_user_command("VlsSession", function()
report("VoidLanguageServer replay session", require("vls").session())
end, { desc = "Subscribe to the active replay session and generation" })
vim.api.nvim_create_user_command("VlsTimeline", function(options)
local fields = vim.split(options.args, "%s+", { trimempty = true })
local page, err = require("vls").timeline(tonumber(fields[1]), tonumber(fields[2]))
if err then
report("VoidLanguageServer timeline", nil, err)
return
end
local lines = { string.format("session %s generation %d total %d",
page.sessionId, page.generation, page.total) }
for _, event in ipairs(page.events) do
table.insert(lines, string.format("%d %s%s", event.sequence, event.kind,
event.acknowledgedAction and
string.format(" stop=%d action=%s", event.acknowledgedStop,
event.acknowledgedAction) or ""))
end
require("vls").render("VLS timeline", lines)
end, { nargs = "*", desc = "Show a bounded timeline page: :VlsTimeline [start] [count]" })
vim.api.nvim_create_user_command("VlsFrames", function(options)
local fields = vim.split(options.args, "%s+", { trimempty = true })
local page, err = require("vls").frames(tonumber(fields[1]), tonumber(fields[2]))
if err then
report("VoidLanguageServer frames", nil, err)
return
end
local lines = { string.format("session %s generation %d total %d",
page.sessionId, page.generation, page.total) }
for _, frame in ipairs(page.frames) do
table.insert(lines, string.format("%s %s", tostring(frame.id),
tostring(frame.name)))
end
require("vls").render("VLS frames", lines)
end, { nargs = "*", desc = "Show a bounded frame page: :VlsFrames [start] [count]" })
vim.api.nvim_create_user_command("VlsSource", function()
local content, err = require("vls").source()
if err then
report("VoidLanguageServer source", nil, err)
return
end
require("vls").render("VLS captured source", vim.split(content, "\n", { plain = true }))
end, { desc = "Show the captured source of the active replay" })
vim.api.nvim_create_user_command("VlsStop", function()
require("vls").stop()
vim.notify("VLS: replay stopped", vim.log.levels.INFO)
end, { desc = "Stop the active replay session" })
vim.api.nvim_create_user_command("VlsRename", function(options)
local ok, err = require("vls").rename(options.args)
if not ok then
vim.notify("VLS: " .. err, vim.log.levels.ERROR)
else
vim.notify("VLS: rename applied", vim.log.levels.INFO)
end
end, { nargs = 1, desc = "Rename the symbol at the cursor through the server" })