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 139 forks source link

lsp-ui-doc with is not unfocused. #579

Open qoor opened 3 years ago

qoor commented 3 years ago

When I call lsp-ui-doc-focus-frame manually, Then I can focus to doc frame.

After I read document and press q key, starting record key mode from evil.

if I want unfocus doc, always need to call lsp-ui-doc-unfocus-frame this situation?

And I have one more question. lsp-ui-doc example image is showing when press the key Shift+K. But in my case My emacs launched man page search mode. How can I see doc with Shift+K hotkey?

Here is my init.el.

theCow61 commented 3 years ago

Same here wondering how to get the Shift+K or some toggle thing for focusing and unfocusing doc frames.

qoor commented 3 years ago

Same here wondering how to get the Shift+K or some toggle thing for focusing and unfocusing doc frames.

Ok, I got it. However, I basically know that the q key is used to unfocus the focused hover document. In my case it doesn't work that way.

It's not a bug? Then I must bind the key q?

theCow61 commented 3 years ago

Ok, I got it.

What did you do to get the Shift+K thing working?

qoor commented 3 years ago

Ok, I got it.

What did you do to get the Shift+K thing working?

I'm skip that. I think binding the key using general seems to solve it. What I really want is to close the document with the q key.

theCow61 commented 3 years ago

Yea but I don't really want to have 2 separate bindings for focusing and unfocusing I kinda want a toggle kinda thing.

jcs090218 commented 3 years ago

Can you try the following function?

(defun lsp-ui-doc-toggle-focus-frame ()
  "Toggle focus and unfocus `lsp-ui-doc-frame'."
  (interactive)
  (if (lsp-ui-doc--frame-visible-p) (lsp-ui-doc-unfocus-frame)
    (lsp-ui-doc-focus-frame)))
theCow61 commented 3 years ago

Doesn't work when I run it while there is a doc buffer in the corner of screen.

qoor commented 3 years ago

Can you try the following function?


(defun lsp-ui-doc-toggle-focus-frame ()

  "Toggle focus and unfocus `lsp-ui-doc-frame'."

  (interactive)

  (if (lsp-ui-doc--frame-visible-p) (lsp-ui-doc-unfocus-frame)

    (lsp-ui-doc-focus-frame)))

No, it is not working.

kiennq commented 3 years ago

@qoor Can you try adding this key binding into your init?

(evil-define-key 'normal 'lsp-ui-doc-frame-mode
      [?q] #'lsp-ui-doc-unfocus-frame)
(evil-normalize-keymaps)

Alternatively you can go into edit mode when inside doc frame and press q (default keybind for hiding doc frame).

theCow61 commented 3 years ago

@kiennq thanks it worked, with that I can know unfocus frame with q. Do you know how to make it focus with Shift+K?

kiennq commented 3 years ago

@theCow61 Actually in the image in lsp-ui, the Shift + K is used to make the doc frame appeared on demand (lsp-ui-doc-glance), and the doc frame is focused with tab key.

If you want to bind the Shift + K to make it focus into doc frame. The easiest is

(evil-define-key 'normal 'lsp-ui-doc-mode
      [?K] #'lsp-ui-doc-focus-frame)
theCow61 commented 3 years ago

Thank you for the help.

qoor commented 3 years ago

@theCow61 Actually in the image in lsp-ui, the Shift + K is used to make the doc frame appeared on demand (lsp-ui-doc-glance), and the doc frame is focused with tab key.

If you want to bind the Shift + K to make it focus into doc frame. The easiest is


(evil-define-key 'normal 'lsp-ui-doc-mode

      [?K] #'lsp-ui-doc-focus-frame)

Why my Emacs does not work lsp-ui-doc-glance? If I call lsp-ui-doc-glance after cursor position to symbol, Nothing happen. Only work lsp-ui-doc-show

My Emacs version is 28.0.x (with native-compilation)

qoor commented 3 years ago

@qoor

Can you try adding this key binding into your init?


(evil-define-key 'normal 'lsp-ui-doc-frame-mode

      [?q] #'lsp-ui-doc-unfocus-frame)

(evil-normalize-keymaps)

Alternatively you can go into edit mode when inside doc frame and press q (default keybind for hiding doc frame).

That's work. But why I should bind the key manually? In lsp-ui-doc.el, q key to hide frame bind is already defined at lsp-ui-doc-frame-mode.

kiennq commented 3 years ago

That's work. But why I should bind the key manually? In lsp-ui-doc.el, q key to hide frame bind is already defined at lsp-ui-doc-frame-mode.

That's emacs binding, not evil-mode binding. If you press i to enter edit mode for evil-mode, you can press q and have the doc frame unfocused. The key bind I posted if for binding q to lsp-ui-unfocus-frame for normal mode. So you can press q right away without entering insert mode

qoor commented 3 years ago

@theCow61 Actually in the image in lsp-ui, the Shift + K is used to make the doc frame appeared on demand (lsp-ui-doc-glance), and the doc frame is focused with tab key.

If you want to bind the Shift + K to make it focus into doc frame. The easiest is


(evil-define-key 'normal 'lsp-ui-doc-mode

      [?K] #'lsp-ui-doc-focus-frame)

Why my Emacs does not work lsp-ui-doc-glance? If I call lsp-ui-doc-glance after cursor position to symbol, Nothing happen. Only work lsp-ui-doc-show

My Emacs version is 28.0.x (with native-compilation)

@kiennq And this, Why lsp-ui-doc-glance is not working on my Emacs? When I call the lsp-ui-doc-show before lsp-ui-doc-glance, it work. glance feature is just 'have effect what already OPENED that'?