aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-09-27 17:39:37 +1000
committerYuchen Pei <hi@ypei.me>2022-09-27 17:40:31 +1000
commitf41acd608039f4dce4cf839885b2ec4cb6329726 (patch)
tree88b3fe80867948552a35f91b40bfbf2106fc786b
parent52ae047cbd8741e7fc4fdc4b9aee5001b6549e6c (diff)
using occurrence in eldoc
- allows showing docs for things like literal strings and _
-rw-r--r--hcel-source.el22
1 files 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.