diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/Effect.zig | 6 | ||||
| -rw-r--r-- | core/File.zig | 8 | ||||
| -rw-r--r-- | core/dump.zig | 6 | ||||
| -rw-r--r-- | core/lsp/lsp.zig | 6 |
4 files changed, 23 insertions, 3 deletions
diff --git a/core/Effect.zig b/core/Effect.zig index 3bca04c9..72244f2b 100644 --- a/core/Effect.zig +++ b/core/Effect.zig @@ -64,6 +64,10 @@ pub const Effect = union(enum) { /// `arg` up to 128 bytes, or for `explain` the query it explains, /// `<kind> <arg>`. lsp: struct { id: u32, kind: lsp.Kind, pane: Pane.Id, offset: u32, arg: Buf(160) }, + /// A file opened in pane `pane` (File.open, a session's revived pane): + /// the server its language speaks to started and told of it, off the + /// loop (dev/Lsp.zig open), so its first query finds it ready. + lsp_open: struct { pane: Pane.Id }, /// Snapshot the matching request with pipeRequest(id), then run it away /// from the UI/event loop and answer with pipe_resp. pipe: struct { id: u32 }, @@ -216,6 +220,8 @@ fn performInner(p: *Pardes, e: Effect) void { }, .lsp => |q| p.tape.host(p, .lsp, .{.{ .id = q.id, .kind = q.kind, .pane = q.pane, .offset = q.offset, .arg = q.arg.slice() }}) orelse p.update(.{ .lsp_resp = .{ .id = q.id, .rows = "" } }), + // No workers here (a test, a board): no server starts before a query. + .lsp_open => |o| _ = p.tape.host(p, .lsp_open, .{o.pane}), .pipe => |q| p.tape.host(p, .pipe, .{q.id}) orelse p.update(.{ .pipe_resp = .{ .id = q.id, .success = false, .outputs = &.{} } }), // No workers here (a test, a board): it runs on the loop. diff --git a/core/File.zig b/core/File.zig index 0f9178ac..d16b0c73 100644 --- a/core/File.zig +++ b/core/File.zig @@ -922,7 +922,13 @@ pub fn open(p: *Pardes, id: usize, path: []const u8, line: usize) !*Pane { pane.body.cur_pinned = true; pane.body.cur_row = @intCast(scroll); p.installPane(id, pane); - if (filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = .at(id), .on = true } }); + if (filesystem.localPath(path) != null) { + p.emit(.{ .watch = .{ .pane = .at(id), .on = true } }); + // Its language's server started now, off the loop: the first + // question asked of it finds it ready. Not a picker's preview's, + // which opens no pane (Pick.preview). + p.emit(.{ .lsp_open = .{ .pane = .at(id) } }); + } return pane; } diff --git a/core/dump.zig b/core/dump.zig index 2dde9c8c..d7c44b71 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -718,8 +718,9 @@ fn reviveSession(p: *Pardes, previous: ?*Pardes, resumed: bool) !void { } /// A loaded pane given to this host: a terminal a new shell in its old -/// one's directory under its history, a file watched again (one changed on -/// disk since comes back as it is now, one unsaved is marked changed), a +/// one's directory under its history, a file watched again and its +/// language's server started (one changed on disk since comes back as it +/// is now, one unsaved is marked changed), a /// kind's pane opened again (a PDF a build before the pdf addon dumped, as /// the addon's). fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool) void { @@ -762,6 +763,7 @@ fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool } else |_| {} } p.emit(.{ .watch = .{ .pane = .at(id), .on = true } }); + p.emit(.{ .lsp_open = .{ .pane = .at(id) } }); // Its file gone from disk since the dump: its text is nowhere else, so // it is said deleted, and Del, Exit and Restore ask first. One never on // disk (a name not yet saved) comes back as it was. diff --git a/core/lsp/lsp.zig b/core/lsp/lsp.zig index 7a636f72..00ffc98b 100644 --- a/core/lsp/lsp.zig +++ b/core/lsp/lsp.zig @@ -96,6 +96,12 @@ pub fn query(io: std.Io, arena: std.mem.Allocator, req: Req, out: *std.Io.Writer return client.query(io, arena, req, out); } +/// A file opened in a pane: its language's server started and told of it +/// (lsp_client.open), on a host's worker. +pub fn open(io: std.Io, arena: std.mem.Allocator, req: Req) !void { + return client.open(io, arena, req); +} + /// The one line the client answers with when it cannot answer at all, and /// why: the core says it rather than "nothing found". pub fn none(out: *std.Io.Writer, comptime fmt: []const u8, args: anytype) std.Io.Writer.Error!void { |
