From f41acd608039f4dce4cf839885b2ec4cb6329726 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 27 Sep 2022 17:39:37 +1000 Subject: using occurrence in eldoc - allows showing docs for things like literal strings and _ --- hcel-source.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hcel-source.el b/hcel-source.el index d9812fb..8b5efd1 100644 --- a/hcel-source.el +++ b/hcel-source.el @@ -148,16 +148,21 @@ the location with pulsing. (defun hcel-type-at-point () (interactive) (hcel-render-type-internal hcel-package-id hcel-module-path - (hcel-text-property-near-point 'identifier))) + (hcel-text-property-near-point 'identifier) + (hcel-text-property-near-point 'occurrence))) -;; TODO: use occurrence for things without an id, e.g. _ -(defun hcel-render-type-internal (package-id module-path identifier) - (when (and package-id module-path identifier) +(defun hcel-render-type-internal (package-id module-path identifier + &optional occurrence) + (when (and package-id module-path (or identifier occurrence)) (let ((hcel-buffer (hcel-buffer-name package-id module-path))) (when (get-buffer hcel-buffer) (with-current-buffer hcel-buffer - (when-let* ((id (alist-get (intern identifier) hcel-identifiers)) - (id-type (alist-get 'idType id))) + (let* ((id (when identifier + (alist-get (intern identifier) hcel-identifiers))) + (occ (when occurrence + (alist-get (intern occurrence) hcel-occurrences))) + (id-type (or (alist-get 'idType id) + (alist-get 'idOccType occ)))) (concat (hcel-render-id-type id-type) (when-let* ((external-id (alist-get 'externalId id)) @@ -431,8 +436,9 @@ the location with pulsing. "hcel match" (xref-make-buffer-location buffer pos) len)))) - (t - (error "unimplemented: %s" (hcel-location-tag location-info)))))))))) + ;; FIXME: error when trying to find definition for an empty + ;; string + (t nil)))))))) (provide 'hcel-source) ;;; hcel-source.el ends here. -- cgit v1.2.3