Commit a96a1dfd authored by Bogdan Popa's avatar Bogdan Popa

add eldoc support

Fixes #77
parent d3adee53
......@@ -849,26 +849,44 @@ Runs `elm-reactor' first."
(elt candidates 0)
nil)))
(defun elm-oracle--completion-at-point ()
"Get the Oracle completion object at point."
(defun elm-oracle--function-at-point ()
"Get the name of the function at point."
(save-excursion
(forward-word)
(let* ((_ (re-search-backward elm-oracle--pattern nil t))
(beg (1+ (match-beginning 0)))
(end (match-end 0))
(item (s-trim (buffer-substring-no-properties beg end))))
(elm-oracle--get-first-completion item))))
item)))
(defun elm-oracle--completion-at-point ()
"Get the Oracle completion object at point."
(elm-oracle--get-first-completion (elm-oracle--function-at-point)))
(defun elm-oracle--type-at-point ()
"Get the type of the function at point."
(let ((completion (elm-oracle--completion-at-point)))
(when completion
(let-alist completion
(concat
(propertize .name 'face 'font-lock-function-name-face)
": "
.signature)))))
;;;###autoload
(defun elm-oracle-type-at-point ()
"Print the type of the function at point to the minibuffer."
(interactive)
(let ((completion (elm-oracle--completion-at-point)))
(if completion
(let-alist completion
(message .signature))
(let ((type (elm-oracle--type-at-point)))
(if type
(message type)
(message "Unknown type"))))
;;;###autoload
(defun elm-eldoc ()
"Get the type of the function at point for eldoc."
(elm-oracle--type-at-point))
;;;###autoload
(defun elm-oracle-doc-at-point ()
"Show the documentation of the value at point."
......
......@@ -87,6 +87,9 @@
(setq-local comment-end "")
(setq-local imenu-create-index-function #'elm-imenu-create-index)
(add-function :before-until (local 'eldoc-documentation-function) #'elm-eldoc)
(setq-local eldoc-idle-delay 0.75)
(add-hook 'after-save-hook #'elm-mode-after-save-handler nil t)
(turn-on-elm-font-lock)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment