Update hack

This commit is contained in:
Yuan Fu 2019-01-01 01:44:57 -05:00
parent 0278b46f7e
commit c00c447ac5
No known key found for this signature in database
GPG Key ID: 1CF5ECABEC37A901

View File

@ -30,8 +30,14 @@ As of writing this README, eglot doesn't have a public mode hook, use this hook:
(add-hook 'eglot--managed-mode-hook #'eldoc-box-hover-mode t) (add-hook 'eglot--managed-mode-hook #'eldoc-box-hover-mode t)
#+END_SRC #+END_SRC
** Help at point hack ** Help at point hack
If all you need is a "help at point" popup to be used with eglot, here is my hack. You don't need to enable any minor mode, just call this command on the symbol. If all you need is a "help at point" popup to be used with eglot, here is my hack. You don't need to enable any minor mode, just call this command on the symbol. (In fact, I dont even use =eldoc-box-hover-mode= anymore. I bind this hack to =C-h C-h= and lived happily ever after.)
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun eldoc-box-hack-cleanup ()
"Try to clean up the childframe made by eldoc-box hack."
(if (eq (point) eldoc-box-hack-last-point)
(run-with-timer 0.1 nil #'eldoc-box-hack-cleanup)
(eldoc-box-quit-frame)))
(defun moon-help-at-point () (defun moon-help-at-point ()
(interactive) (interactive)
(when eglot--managed-mode (when eglot--managed-mode
@ -43,7 +49,8 @@ If all you need is a "help at point" popup to be used with eglot, here is my hac
(eglot--TextDocumentPositionParams)) (eglot--TextDocumentPositionParams))
(when (seq-empty-p contents) (eglot--error "No hover info here")) (when (seq-empty-p contents) (eglot--error "No hover info here"))
(eglot--hover-info contents range)))) (eglot--hover-info contents range))))
(add-hook 'pre-command-hook #'eldoc-box-quit-frame t t))) (setq eldoc-box-hack-last-point (point))
(run-with-timer 0.1 nil #'eldoc-box-hack-cleanup)))
#+END_SRC #+END_SRC
* Contributors * Contributors