-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
excessive delays inside which-key--maybe-replace when using lsp layer #12455
Comments
Your investigation is awesome. I can also reproduce this bug with |
add an internal variable for `lsp` layer `lsp-layer--active-mode-list` to keep track of active major modes using lsp, `spacemacs//lsp-declare-prefixes-for-mode` will check this variable to decide whether to add prefix to which-key or not
add an internal variable for `lsp` layer `lsp-layer--active-mode-list` to keep track of active major modes using lsp, `spacemacs//lsp-declare-prefixes-for-mode` will check this variable to decide whether to add prefix to which-key or not
add an internal variable for `lsp` layer `lsp-layer--active-mode-list` to keep track of active major modes using lsp, `spacemacs//lsp-declare-prefixes-for-mode` will check this variable to decide whether to add prefix to which-key or not
commit 653a38b doesn't seem to work. I am still experiencing this. |
@vv111y can you describe how to reproduce this bug in your case? thanks |
This does seem to be fixed for me. Thanks @thanhvg! |
add an internal variable for `lsp` layer `lsp-layer--active-mode-list` to keep track of active major modes using lsp, `spacemacs//lsp-declare-prefixes-for-mode` will check this variable to decide whether to add prefix to which-key or not
add an internal variable for `lsp` layer `lsp-layer--active-mode-list` to keep track of active major modes using lsp, `spacemacs//lsp-declare-prefixes-for-mode` will check this variable to decide whether to add prefix to which-key or not
First - my apologies for not responding. I wasn't sure what to report. The correct response would have been: "just use spacemacs". This issue was never resolved and the relevant information is upstream: Proposed solution: This requires spacemacs to modify how which-key is used (I don't know what that is, I haven't had the time to learn how this works). Shall I open a new issue? Is there anything I can do to help? |
This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is syl20bnr#12455 which led to my hack in syl20bnr#12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")"
This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is syl20bnr#12455 which led to my hack in syl20bnr#12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")"
This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is syl20bnr#12455 which led to my hack in syl20bnr#12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")"
This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is syl20bnr#12455 which led to my hack in syl20bnr#12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")"
…d apply it to tide and lsp layers (#14141) * [core][keybinng] improve minor mode binding This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is #12455 which led to my hack in #12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")" * [tide] improve prefix * [lsp] improve prefix
Observing a similar issue, but also
|
Interesting, do you see the same behaviour on latest develop @opsxcq? This should not longer be the case. |
…d apply it to tide and lsp layers (syl20bnr#14141) * [core][keybinng] improve minor mode binding This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is syl20bnr#12455 which led to my hack in syl20bnr#12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")" * [tide] improve prefix * [lsp] improve prefix
…d apply it to tide and lsp layers (syl20bnr#14141) * [core][keybinng] improve minor mode binding This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is syl20bnr#12455 which led to my hack in syl20bnr#12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")" * [tide] improve prefix * [lsp] improve prefix
I will test with the latest develop and validate |
@smile13241324 no, got the last version from
|
fwiw the situation has improved for me except now it's
|
…d apply it to tide and lsp layers (syl20bnr#14141) * [core][keybinng] improve minor mode binding This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is syl20bnr#12455 which led to my hack in syl20bnr#12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")" * [tide] improve prefix * [lsp] improve prefix
…d apply it to tide and lsp layers (syl20bnr#14141) * [core][keybinng] improve minor mode binding This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is syl20bnr#12455 which led to my hack in syl20bnr#12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")" * [tide] improve prefix * [lsp] improve prefix
Description
I have observed performance degradation in which-key after a day's worth of development with spacemacs. Specifically, pressing the leader key and waiting for the menu to appear takes longer and longer.
Using the emacs profiler, I determined that almost all cpu time was being spent inside
which-key--maybe-replace
. Investigating further, it seems that the delays are due to growth of thewhich-key-replacement-alist
variable, and this is in turn due to thelsp
layer.In the lsp layer, there is a call to
(spacemacs//lsp-declare-prefixes-for-mode major-mode)
as a hook attached tolsp-after-open-hook
. This adds to thewhich-key-replacement-alist
variable. Growth of this variable is correlated with the delays in showing the spacemacs menu.Reproduction guide 🪲
SPC b R
to revert this bufferObserved behaviour: 👀 💔
The more files opened, or the more times each buffer is reverted, the longer it takes to the menu to appear. This is observed to be correlated with the increasing value of
(length (assoc major-mode which-key-replacement-alist))
.Expected behaviour: ❤️ 😄
The menu appears instantateously. Also the value of
(length (assoc major-mode which-key-replacement-alist))
is stable.System Info 💻
Backtrace 🐾
The text was updated successfully, but these errors were encountered: