Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion idris-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,23 @@ Considered as a global variable"

(defun idris-eldoc-lookup ()
"Return Eldoc string associated with the thing at point."
(get-char-property (point) 'idris-eldoc))
(let ((prop-val (get-char-property (point) 'idris-eldoc)))
;; Idris2 temporary hack to make eldoc bit useful
(if (and (stringp prop-val) (string-suffix-p ": " prop-val) (>=-protocol-version 2 1))
(let* ((thing (idris-name-at-point))
(ty (idris-eval (list :type-of thing) t))
;; (ty (idris-eval (list :docs-for thing) t))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs-for returns often multi line string which then causes mini-buffer to jump and distracts user.

(result (car ty))
(formatting (cdr ty))
(result-colour (idris-propertize-str (idris-repl-semantic-text-props formatting)
result)))
;; memoize result
(dolist (overlay (overlays-at (point)))
(when (overlay-get overlay 'idris-source-highlight)
(overlay-put overlay 'idris-eldoc result-colour)))
result-colour)
;; Idris 1 using :doc-overview semantic properties extracted from highlights
prop-val)))

(defun idris-pretty-print ()
"Get a term or definition pretty-printed by Idris.
Expand Down
8 changes: 7 additions & 1 deletion idris-common-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ inserted text (that is, relative to point prior to insertion)."
(+ ,start begin length)
props))))))

(defun idris-propertize-str (spans text)
"Add properties indicated by SPANS to the TEXT.
SPANS is a list of (BEGIN LENGTH PROPERTIES) elements."
(dolist (span spans text)
(cl-destructuring-bind (begin length props) span
(set-text-properties begin (+ begin length) props text))))

;;; TODO: Take care of circular dependency issue
(autoload 'idris-eval "inferior-idris.el")

Expand Down Expand Up @@ -224,7 +231,6 @@ inserted text (that is, relative to point prior to insertion)."
(cadr namespace)))
(t nil))))


(defun idris-semantic-properties-help-echo (props)
(let* ((name (assoc :name props))
(decor (assoc :decor props))
Expand Down