From acded15af821d2e78c153da6b12f86f194ca69c5 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Mon, 12 May 2025 12:26:36 -0500 Subject: [PATCH] added * command in vim mode --- src/keybind/builtin/vim.json | 3 ++- src/tui/editor.zig | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index dc77afd..6d35d71 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -86,6 +86,7 @@ ["", "redo"], ["/", "find"], + ["*", "find_word_at_cursor"], ["", "TODO"], @@ -187,7 +188,7 @@ ["mW", "set_global_mark", 87], ["mX", "set_global_mark", 88], ["mY", "set_global_mark", 89], - ["mZ", "set_global_mark", 90] + ["mZ", "set_global_mark", 90], ["'A", "goto_global_mark", 65], ["'B", "goto_global_mark", 66], diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 96ffb0c..bab36ef 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -4772,6 +4772,14 @@ pub const Editor = struct { } pub const find_query_meta: Meta = .{ .arguments = &.{.string} }; + pub fn find_word_at_cursor(self: *Self, ctx: Context) Result { + _ = ctx; + const query: []const u8 = try self.copy_word_at_cursor(self.allocator); + try self.find_in_buffer(query); + self.allocator.free(query); + } + pub const find_word_at_cursor_meta: Meta = .{ .description = "Search for the word under the cursor" }; + fn find_in(self: *Self, query: []const u8, comptime find_f: ripgrep.FindF, write_buffer: bool) !void { const root = try self.buf_root(); self.cancel_all_matches();