emacs-lsp / lsp-ui

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

lsp-ui-imenu auto-refresh #511

Closed ulises closed 3 years ago

ulises commented 3 years ago

lsp-ui-imenu is great to quickly see the layout of a Java class however the buffer is not updated once the accompanying buffer changes, i.e. visiting a different class.

The imenu buffer should auto-update when this happens (like its treemacs counterpart).

brotzeit commented 3 years ago

Duplicate of #295

brotzeit commented 3 years ago

I think we should set imenu-auto-rescan to t by default for lsp-ui.

jcs090218 commented 3 years ago

Sounds like a good idea! :)

brotzeit commented 3 years ago

But I'm not sure which hook we should use to reload the imenu entries.

jcs090218 commented 3 years ago

It feel like we have to setup the rule for this... feature?

brotzeit commented 3 years ago

there is one implementation in lsp-treemacs-symbols which uses a timer. IMO it should be reworked to use lsp-on-idle-hook

Maybe we can add a generic solution that can be used for different use cases.

minikN commented 3 years ago

Should setting imenu-auto-rescan to t manually fix this? Because for me doesn't have any effect. Still not auto refreshing.

jcs090218 commented 3 years ago

Should setting imenu-auto-rescan to t manually fix this? Because for me doesn't have any effect. Still not auto refreshing.

Would calling lsp-ui-imenu again do the trick? 😕 The current implementation should work in this scenario.

vrx commented 3 years ago

yes it does

it is possible to launch it when file is saved in a specific mode (cpp in this case) note the last argument set to true of add-hook in order to apply it to the local-mode and select-window to reset keyboard focus where it was originally

(add-hook 'c++-mode-hook
            '(lambda ()
               (add-hook 'after-save-hook (lambda ()
                                            (let ((cur-window (selected-window)))
                                              (lsp-ui-imenu)
                                              (select-window cur-window)
                                              )
                                            ) 0 t)))
jcs090218 commented 3 years ago

Got it! Thanks for confirming.

I'm working on #515. I think this issue would be resolved after this PR is merged!

jcs090218 commented 3 years ago

After commit 982b4669721c8bcd4dcf2fc100d07824b5d89437. Please customize variable to lsp-ui-imenu-auto-refresh for this feature! Thanks!

failable commented 2 years ago

Does lsp-ui-imenu-auto-refresh care about switching between buffers?