feat: WIP start work on goto_definition LSP command

This commit is contained in:
CJ van den Berg 2024-03-31 22:38:25 +02:00
parent eb94bf5258
commit 2e8fd58ba5
5 changed files with 121 additions and 82 deletions

View file

@ -9,6 +9,7 @@ const ripgrep = @import("ripgrep");
const tracy = @import("tracy");
const text_manip = @import("text_manip");
const syntax = @import("syntax");
const project_manager = @import("project_manager");
const scrollbar_v = @import("scrollbar_v.zig");
const editor_gutter = @import("editor_gutter.zig");
@ -3146,6 +3147,13 @@ pub const Editor = struct {
try self.send_editor_jump_destination();
}
pub fn goto_definition(self: *Self, _: command.Context) tp.result {
const file_path = self.file_path orelse return;
const primary = self.get_primary();
const file_type = (self.syntax orelse return).file_type.name;
return project_manager.goto_definition(file_path, file_type, primary.cursor.row, primary.cursor.col);
}
pub fn select(self: *Self, ctx: command.Context) tp.result {
var sel: Selection = .{};
if (!try ctx.args.match(.{ tp.extract(&sel.begin.row), tp.extract(&sel.begin.col), tp.extract(&sel.end.row), tp.extract(&sel.end.col) }))

View file

@ -186,7 +186,7 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result {
key.F09 => self.cmd("theme_prev", .{}),
key.F10 => self.cmd("theme_next", .{}),
key.F11 => self.cmd("toggle_logview", .{}),
key.F12 => self.cmd("toggle_inputview", .{}),
key.F12 => self.cmd("goto_definition", .{}),
key.F34 => self.cmd("toggle_whitespace", .{}), // C-F10
key.ESC => self.cmd("cancel", .{}),
key.ENTER => self.cmd("smart_insert_line", .{}),