commit 7cc8b45b04ce898e22722421eea4015bea981525
parent 7158ca3c5fb7584e5fe2e3e6e3e4dad473cf3cd8
Author: Lou Woell <lou.woell@posteo.de>
Date:   Thu,  4 Sep 2025 15:30:28 +0200

implement goto-definition

Diffstat:
Mcmd/harehelper/helper.ha | 6++++++
Mharedoc.el | 15+++++++++++++++
2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/cmd/harehelper/helper.ha b/cmd/harehelper/helper.ha @@ -22,6 +22,9 @@ const help: []getopt::help = [ ("find", [ "find module for identifier", "args", + ("locate", [ + "return location of declaration for identifier", + "identifier", ]: []getopt::help), ("list-modules", [ "findc module for identifier", @@ -34,6 +37,7 @@ export fn main () void = { const cmd = getopt::parse(os::args, help...); defer getopt::finish(&cmd); + const ctx = module::context { harepath = os::tryenv("HAREPATH", HAREPATH), harecache = match (os::getenv("HARECACHE")) { @@ -73,6 +77,8 @@ export fn main () void = { list(*c.1, &ctx); case "list-modules" => list_modules(&ctx); + case "locate" => + locate(*c.1, &ctx); case => void; }; os::exit(0); diff --git a/haredoc.el b/haredoc.el @@ -89,6 +89,21 @@ the results in a new buffer." (interactive) (haredoc (hare/identifier-at-point))) +;;;###autoload +(defun hare/goto-defintion () + (interactive) + (when-let* ((name (hare/identifier-at-point)) + (loc (split-string (hh/exec (list hare/helperbin "-p" + (hare/root-dir) + "locate" name)) + ":")) + (file (car loc)) + (line (string-to-number (cadr loc)))) + (when (not (string= file "")) + (with-current-buffer (find-file file) + (print file) + (goto-line line))))) + (define-derived-mode haredoc-mode help-mode "🐇") (provide 'haredoc)