aboutsummaryrefslogtreecommitdiffstats
path: root/oni-lsp.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2019-10-21 00:41:19 -0700
committerGravatar Tom Willemse2019-10-21 00:42:30 -0700
commitd4e4a25cde3067578be94cdf4e125ecdd2b7770c (patch)
treef0dbfe377acd7e89e0d1c1e6b64c4152aa9d0cac /oni-lsp.el
parent220ad644dd31cdeb7017a16286f5f95c7063e26c (diff)
downloademacs-config-d4e4a25cde3067578be94cdf4e125ecdd2b7770c.tar.gz
emacs-config-d4e4a25cde3067578be94cdf4e125ecdd2b7770c.zip
Add documentation command for LSP
The default way lsp (at least for Java) is displayed is annoying. I’m used to calling documentation with a keybinding like in Emacs Lisp. This command makes it more like that.
Diffstat (limited to 'oni-lsp.el')
-rw-r--r--oni-lsp.el21
1 files changed, 17 insertions, 4 deletions
diff --git a/oni-lsp.el b/oni-lsp.el
index 78581a4..312e294 100644
--- a/oni-lsp.el
+++ b/oni-lsp.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2019.1016.231222
+;; Version: 2019.1021.004102
;; Package-Requires: (lsp-mode lsp-ui)
;; This program is free software; you can redistribute it and/or modify
@@ -29,12 +29,25 @@
(require 'lsp)
(require 'lsp-ui)
+(defun oni-lsp-show-doc ()
+ "Show documentation string in a help buffer."
+ (interactive)
+ (let* ((position-params (lsp--text-document-position-params))
+ (response (lsp-request "textDocument/hover" position-params))
+ (contents (gethash "contents" response))
+ (help-string (lsp-ui-doc--extract contents))
+ (symbol (gethash "value" (pcase contents
+ ((pred arrayp) (aref contents 0))
+ (_ contents)))))
+ (with-help-window (help-buffer)
+ (princ symbol)
+ (princ "\n\n")
+ (princ help-string))))
+
(setq lsp-prefer-flymake nil)
-(setq lsp-ui-doc-enable t)
+(setq lsp-ui-doc-enable nil)
(setq lsp-ui-sideline-enable nil)
-(setq lsp-ui-doc-position 'at-point)
-(setq lsp-ui-doc-delay 1)
(add-hook 'lsp-mode-hook 'lsp-lens-mode)