lsp-ui icon indicating copy to clipboard operation
lsp-ui copied to clipboard

Display peek in child frame

Open akermu opened this issue 4 years ago • 7 comments

I patch lsp-mode to diplay the peek ui in a childframe:

  (defun lsp-ui-peek--peek-display (src1 src2)
    (-let* ((win-width (frame-width))
            (lsp-ui-peek-list-width (/ (frame-width) 2))
            (string (-some--> (-zip-fill "" src1 src2)
                      (--map (lsp-ui-peek--adjust win-width it) it)
                      (-map-indexed 'lsp-ui-peek--make-line it)
                      (-concat it (lsp-ui-peek--make-footer))))
            )
      (setq lsp-ui-peek--buffer (get-buffer-create " *lsp-peek--buffer*"))
      (posframe-show lsp-ui-peek--buffer
                     :string (mapconcat 'identity string "")
                     :min-width (frame-width)
                     :poshandler #'posframe-poshandler-frame-center)))

  (defun lsp-ui-peek--peek-destroy ()
    (when (bufferp lsp-ui-peek--buffer)
      (posframe-delete lsp-ui-peek--buffer))
    (setq lsp-ui-peek--buffer nil
          lsp-ui-peek--last-xref nil)
    (set-window-start (get-buffer-window) lsp-ui-peek--win-start))

  (advice-add #'lsp-ui-peek--peek-new :override #'lsp-ui-peek--peek-display)
  (advice-add #'lsp-ui-peek--peek-hide :override #'lsp-ui-peek--peek-destroy)

I think the big plus point here is, that the UI can occupy the full frame, instead of just the current window.

If I find the time, I'll make a patch out of it.

akermu avatar May 04 '20 10:05 akermu

I almost never use single window in emacs, so this is what i need. But it does not work :( Are you still using this with current version of lsp-ui? @akermu

KaratasFurkan avatar Aug 23 '20 19:08 KaratasFurkan

@KaratasFurkan , this works for me, do you have de postframe package installed?

marcelino-m avatar Sep 04 '20 03:09 marcelino-m

@marcelino-m it turns out one of the packages in my config blocks this. I configured it and they both works without conflict now, thanks.

KaratasFurkan avatar Sep 04 '20 08:09 KaratasFurkan

Hi @akermu , I noted that de footer is not displayed and I don't know how to solve this.

marcelino-m avatar Sep 05 '20 00:09 marcelino-m

Just wanted to say, thanks for this! @akermu

anonimitoraf avatar Apr 04 '21 10:04 anonimitoraf

Hi y'all, it doesn't seem to be working for me.

(use-package lsp-ui
  :commands lsp-ui-mode
  :requires posframe
  :config
  (defun lsp-ui-peek--peek-display (src1 src2)
  (-let* ((win-width (frame-width))
          (lsp-ui-peek-list-width (/ (frame-width) 2))
          (string (-some--> (-zip-fill "" src1 src2)
                    (--map (lsp-ui-peek--adjust win-width it) it)
                    (-map-indexed 'lsp-ui-peek--make-line it)
                    (-concat it (lsp-ui-peek--make-footer)))))
  (setq lsp-ui-peek--buffer (get-buffer-create " *lsp-peek--buffer*"))
  (posframe-show lsp-ui-peek--buffer
                   :string (mapconcat 'identity string "")
                   :min-width (frame-width)
                   :poshandler #'posframe-poshandler-frame-center)))
  (defun lsp-ui-peek--peek-destroy ()
    (when (bufferp lsp-ui-peek--buffer)
      (posframe-delete lsp-ui-peek--buffer))
    (setq lsp-ui-peek--buffer nil
          lsp-ui-peek--last-xref nil)
    (set-window-start (get-buffer-window) lsp-ui-peek--win-start))

  (advice-add #'lsp-ui-peek--peek-new :override #'lsp-ui-peek--peek-display)
  (advice-add #'lsp-ui-peek--peek-hide :override #'lsp-ui-peek--peek-destroy))

Still results in peek being displayed in another buffer. I may be using use-package incorrectly.

bobbbay avatar Jun 21 '21 15:06 bobbbay

it partially works for me, it shows correctly the buffer, but I can't change/edit/use/quit, any thoughts @akermu ?

ericdallo avatar Jun 21 '21 17:06 ericdallo