summaryrefslogtreecommitdiff
path: root/src/lsp/lsp.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 06:22:44 -0300
committerGabriel Schneider <[email protected]>2026-10-01 07:16:43 -0300
commit85b60dedb6bdb192abd11b2d58ca7c0e8c944b18 (patch)
tree13bc6a9f1f1551088c992a29cb365f5d0a63b239 /src/lsp/lsp.zig
parentfb330ce04c4eec4de317637d26310b74e2ee5923 (diff)
downloadpardes-85b60dedb6bdb192abd11b2d58ca7c0e8c944b18.tar.gz
pardes-85b60dedb6bdb192abd11b2d58ca7c0e8c944b18.zip
A Rename, references and the like tell the server of every open file of its language first, so a rename reaches files it had not seen and the preview lists them
zls renames only in the documents in its store, and syncDoc told it of a file only when a query was asked from it, so renaming in progress.zig left main.zig unchanged and broken, with no preview. For a query whose answer can reach other files (rename, references, implementation, workspace symbols, calls and type hierarchy), the host snapshots every other open file and the client syncs those its server answers for first. The mock server answers a rename in each document it was told of; lsp-rename-files opens main.rs by a look, renames from lib.rs, and its preview lists both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/lsp/lsp.zig')
-rw-r--r--src/lsp/lsp.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lsp/lsp.zig b/src/lsp/lsp.zig
index 33e95570..8dc4da4f 100644
--- a/src/lsp/lsp.zig
+++ b/src/lsp/lsp.zig
@@ -31,11 +31,26 @@ pub const Req = struct {
offset: u32,
arg: []const u8 = "",
root: []const u8 = "",
+ /// The other files open in the editor, for a query whose answer can
+ /// reach them (a rename, references): the server is told of each first,
+ /// or it answers from what it has seen and misses the rest.
+ others: []const Doc = &.{},
/// For `explain`: the query it narrates, read from `arg` (`<kind>
/// <arg>`) by `explaining`; a definition when none was asked before.
explains: Kind = .definition,
};
+pub const Doc = struct { path: []const u8, source: [:0]const u8 };
+
+/// Whether a query's answer can name places in other files, so every open
+/// file of the server's language is synced before it is asked.
+pub fn reachesOtherFiles(kind: Kind) bool {
+ return switch (kind) {
+ .rename, .references, .implementation, .workspace_symbols, .incoming_calls, .outgoing_calls, .supertypes, .subtypes => true,
+ else => false,
+ };
+}
+
/// An `explain` request made the one it narrates: `explains` and `arg` set
/// from its `<kind> <arg>`; any other request as it is.
pub fn explaining(req: Req) Req {