help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode wit


From: Hongyi Zhao
Subject: Re: Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with advice function.
Date: Sat, 9 Oct 2021 15:42:02 +0800

On Wed, Oct 6, 2021 at 4:09 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with
> advice function.
>
> I'm experiencing the bugs reported here [1]. To be specific, there is
> a confliction between `lsp-ui-doc-mode' and `dap-tooltip-mode' when
> both of them are enabled, which will cause the debugger not to display
> the variable value when the mouse hovers over the corresponding
> variable name. And the expedient is to define an advice function which
> do the following:
>
> Once I try to run `dap-debug', disable the `lsp-ui-doc-mode' if it has
> already been enabled for the current buffer; and enable it when the
> `dap-disconnect' command is issued.
>
> I tried the suggested functions here [2], as shown below, but it doesn't work:
>
> (define-advice dap-debug (:after (orig-func &rest args)
> disable-lsp-ui-doc) (lsp-ui-doc-mode -1))
> (define-advice dap-disconnect (:after (orig-func &rest args)
> enable-lsp-ui-doc) (lsp-ui-doc-mode t))
>
> [1] https://github.com/emacs-lsp/dap-mode/issues/372
> [2] https://github.com/emacs-lsp/dap-mode/issues/372#issuecomment-848784686
>
> Any hints for adapting or writing a working lisp code snippet for
> solving the above problem?

Based on the document here [1], I figured out the following code
snippet, and it works:

  (defun disable-lsp-ui-doc (orig-fun &rest args)
     (lsp-ui-doc-mode -1))

  (advice-add 'dap-debug :after #'disable-lsp-ui-doc)

  (defun enable-lsp-ui-doc (orig-fun &rest args)
     (lsp-ui-doc-mode))

  (advice-add 'dap-disconnect :after #'enable-lsp-ui-doc)

[1]  
https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Advising-Functions

Regards, HZ



reply via email to

[Prev in Thread] Current Thread [Next in Thread]