From 628aa40f13e9bbd313b51ab625f193110aad8dd0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 9 Aug 2026 04:20:20 -0300 Subject: Tab after a dot in insert mode lists what could go there --- src/lsp/lsp.zig | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/lsp/lsp.zig') diff --git a/src/lsp/lsp.zig b/src/lsp/lsp.zig index b8356724..0ce70869 100644 --- a/src/lsp/lsp.zig +++ b/src/lsp/lsp.zig @@ -51,6 +51,12 @@ pub const Kind = enum { format, /// SPC h select_refs, + /// Tab in insert mode, with a `.` immediately before the cursor. NOT an + /// autocomplete popup — the seam returns locations, so this answers "what + /// could go here, and where is each of those DEFINED": one row per + /// candidate, pointing at its declaration, in the same `+Search` buffer + /// `gr` fills. Nothing is inserted. + completion, // The two introspection kinds. A backend that answers nothing is // indistinguishable from a backend that is broken, so these exist to tell @@ -160,6 +166,9 @@ pub fn query(gpa: std.mem.Allocator, arena: std.mem.Allocator, req: Req, out: *s /// base tree shipped with. const backend = if (@import("pardes_config").zls_backend) @import("lsp_zls.zig") else struct { pub fn query(_: std.mem.Allocator, _: std.mem.Allocator, _: Req, _: *std.Io.Writer) void {} + pub fn speaks(_: []const u8) bool { + return false; + } pub const supports: std.EnumSet(Kind) = .initEmpty(); }; @@ -169,5 +178,15 @@ const backend = if (@import("pardes_config").zls_backend) @import("lsp_zls.zig") /// does not have shows up immediately in the harness's matrix. pub const supports: std.EnumSet(Kind) = backend.supports; +/// Does the backend read this file's LANGUAGE at all? `supports` answers what +/// a backend can do; this answers what it can do it TO, and it exists for the +/// one key that must not be eaten when the answer is no: insert-mode Tab +/// diverts to `completion` after a `.`, so in a README — or in any pane the +/// backend would refuse — it has to indent instead. The core asks rather than +/// knowing, so the list of extensions stays the backend's business. +pub fn speaks(path: []const u8) bool { + return backend.speaks(path); +} + /// Name shown by the harness and in `SPC ?`. Each implementation renames it. pub const backend_name = "zls-inproc"; -- cgit v1.3