emacs-lsp / lsp-ui

UI integrations for lsp-mode
https://emacs-lsp.github.io/lsp-ui
GNU General Public License v3.0
1.03k stars 141 forks source link

lsp-ui feature wishlist #1

Open vibhavp opened 6 years ago

topisani commented 6 years ago

The origin issue: https://github.com/emacs-lsp/lsp-mode/issues/194 A lot of the features were mentioned there

topisani commented 6 years ago

https://github.com/cpitclaudel/quick-peek That might be great for some features. Its not really useful for xref stuff, but for smaller peeks, like C macro expansions etc this would be great

jaelsasser commented 6 years ago

@topisani eventually I’ll get around to integrating cquery with macrostep. Implementation might end up being generic enough to shift it into here.

TatriX commented 6 years ago

Allow showing sideline on demand. It's a cool feature, but can be really noisy. It could be awesome if I could show it for a current line with hotkey. 2018-01-05-204413_941x138_scrot

sebastiencs commented 6 years ago

@TatriX I have added the function lsp-ui-sideline-toggle-symbols-info

You can do:

;; (require 'lsp-ui)
(define-key lsp-ui-mode-map [f10] 'lsp-ui-sideline-toggle-symbols-info)
TatriX commented 6 years ago

Cool, thank you!

Another 2 features I was thinking about: allow customization of the sideline bg color (not sure if it's possible though) and customize delay before showing the sideline. It's the same as with completion: if I know what I'm doing I just type my code and don't see the completion. But if I'm stuck, I can wait half a second and see a completion or sideline.

Of course I'm not sure it will be actually useful.

sebastiencs commented 6 years ago

@TatriX There is now the face lsp-ui-sideline-global and the variable lsp-ui-sideline-delay

fuxialexander commented 6 years ago

Similar to vscode, I think we should be able to show lsp-ui-doc at the point image

(defun lsp-ui-doc--move-frame (frame)
    "Place our FRAME on screen."
    (lsp-ui-doc--resize-buffer)
    (-let* (((_left top right _bottom) (window-edges nil nil nil t))
            (window (frame-root-window frame))
            ((width . height) (window-text-pixel-size window nil nil 10000 10000))
            (width (+ width (* (frame-char-width frame) 2))) ;; margins
            (frame-resize-pixelwise t)
            (x-and-y (company-childframe-compute-pixel-position
                      (- (point) 1)
                      (frame-pixel-width frame)
                      (frame-pixel-height frame))))
      (set-window-margins window 1 1)
      (set-frame-size frame width (min 300 height) t)
      (set-frame-position frame (car x-and-y) (+ (cdr x-and-y) 1))))

(defun company-childframe-compute-pixel-position (pos tooltip-width tooltip-height)
  "Return bottom-left-corner pixel position of POS in WINDOW.
its returned value is like (X . Y)

If TOOLTIP-WIDTH and TOOLTIP-HEIGHT are given, this function will use
two values to adjust its output position, make sure the *tooltip* at
position not disappear by sticking out of the display."
  (let* ((window (selected-window))
         (frame (window-frame window))
         (xmax (frame-pixel-width frame))
         (ymax (frame-pixel-height frame))
         (header-line-height (window-header-line-height window))
         (posn-top-left (posn-at-point pos window))
         (x (+ (car (window-inside-pixel-edges window))
               (or (car (posn-x-y posn-top-left)) 0)))
         (y-top (+ (cadr (window-pixel-edges window))
                   header-line-height
                   (or (cdr (posn-x-y posn-top-left)) 0)))
         (font-height
          (if (= pos 1)
              (default-line-height)
            (aref (font-info
                   (font-at
                    (if (and (= pos (point-max))) (- pos 1) pos)))
                  3)))
         (y-buttom (+ y-top font-height)))
    (cons (max 0 (min x (- xmax (or tooltip-width 0))))
          (max 0 (if (> (+ y-buttom (or tooltip-height 0)) ymax)
                     (- y-top (or tooltip-height 0))
                   y-buttom)))))

The company-childframe function is from https://github.com/tumashu/company-childframe/blob/master/company-childframe.el

Also the recently added line make the doc non-scrollable

(redirect-frame-focus frame (frame-parent frame))
sebastiencs commented 6 years ago

@fuxialexander Can you test the commit https://github.com/emacs-lsp/lsp-ui/commit/a723db130e0e2cc25c2cd3addd273c17f5439f16 ?

fuxialexander commented 6 years ago

@sebastiencs Thanks for the effort. The positioning works, but the content is not scrollable. (caused by (redirect-frame-focus frame (frame-parent frame)))

Also since sometimes the doc is quite long, I think when display at-point or even Top/Bottom, wee should be able to specify the maximum height of the doc.

(set-frame-size frame width (min lsp-ui-doc-max-height height) t)
Dickby commented 6 years ago

It would be nice to have the function lsp-ui-peek-dwim that uses lsp-ui-peek-find-references if point is on a definition and lsp-ui-peek-find-definitions otherwise.

gagbo commented 5 years ago

Has there been any advancement on a way to quickly toggle / resize the lsp-ui-doc frame ? It is really not practical to use for Rust, where the doc is very very long :

screenshot_rust_doc

In this screenshot, the cursor is actually below the frame, so I'd need a quick shortcut to toggle the ui-doc frame if possible

yyoncho commented 5 years ago

@gagbo did you try lsp-ui-doc-max-width?

gagbo commented 5 years ago

I did not. Am I supposed to change this value each time there's a WM event related to emacs window then ?

ilyaguy commented 4 years ago

Show function name in code snippet in lsp-ui-peek mode if function name is above top line of code snippet. e.g. I have referenced line 143, and function starts at line 125. Referenced line shows in the middle of ui-peek window, that's fine. But function name goes much above top of the window. And it would be nice to have function definition under the top margin.