From 674e7dc5aab4bbab0497bf161a03c9bf1c801915 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 26 May 2021 00:51:23 -0400 Subject: [PATCH] Try to place lsp-ui-doc popups in less annoying places --- .emacs.d/init.el | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 4bde264..585772d 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -597,9 +597,21 @@ ([remap xref-find-references] . lsp-ui-peek-find-references)) :config (setq lsp-ui-sideline-ignore-duplicate t - lsp-ui-doc-max-height 10 + lsp-ui-doc-max-height 5 + lsp-ui-doc-max-width 70 ;; lsp-ui-sideline-update-mode 'point - )) + ) + + (defun adjust-lsp-ui-doc-frame-pos (orig-fun &rest args) + (let* ((y-position-in-window (nth 1 (pos-visible-in-window-p (point) nil t))) + (edges (window-absolute-body-pixel-edges)) + (bottom-edge (- (nth 3 edges) (nth 1 edges))) + (lsp-ui-doc-max-height (/ (window-height) 5)) + (lsp-ui-doc-position (if (< (/ (float y-position-in-window) bottom-edge) 0.5) 'bottom 'top))) + (when (lsp-ui-doc--get-frame) + (lsp-ui-doc--move-frame (lsp-ui-doc--get-frame))) + (apply orig-fun args))) + (advice-add 'lsp-ui-doc--display :around #'adjust-lsp-ui-doc-frame-pos)) (use-package lsp-python-ms :demand :if (package-installed-p 'lsp-python-ms))