Skip to content
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

lsp-ui-peek-find-[definitions|references] keybindings get overridden by lsp-mode #702

Open
aconchillo opened this issue Apr 21, 2022 · 2 comments
Labels

Comments

@aconchillo
Copy link
Contributor

Hi! I'm trying to keep lsp-ui-peek-find-definitions and lsp-ui-peek-find-references to the original bindings M-. and M-?.

I have the following code:

(use-package lsp-ui
  :ensure t
  :bind (([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
         ([remap xref-find-references] . lsp-ui-peek-find-references))
  :config
  ;; Don't show sidelines
  (setq lsp-ui-sideline-enable nil))

And I have also tried the lsp-ui setup from here https://github.com/CSRaghunandan/.emacs.d/blob/master/setup-files/setup-lsp.el which uses

  (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
  (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)

This seem to work outside of an LSP buffer (I can see those two functions have the right key binding). However, when I open the first LSP buffer (a JS one) the key bindings get changed to LSP default ones (s-l g g and s-l g r).

Is there a way keep the original key bindings?

@krfantasy
Copy link

I have the same issue with Emacs 28.2 and lsp-ui-20230116.2024 from MELPA.

My configuration:

(use-package lsp-ui
  :ensure t
  :config
  (setq lsp-ui-sideline-enable t
	lsp-ui-peek-enable t
	lsp-ui-doc-enable t
        lsp-ui-imenu-auto-refresh t)
  (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
  (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references))

@s4swani
Copy link

s4swani commented Aug 5, 2023

I faced the same issue with Emacs 28.2 on Macos 12.6.8. Instead of lsp-ui-mode-map, I used the variable lsp-mode-map and the xref keybindings worked for me.

So this is what those configuration lines look like:

;; remap xref-find-definitions(M-.) and xref-find-references(M-?) to lsp-ui-peek
(define-key lsp-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
(define-key lsp-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)

I’m not sure if this is helpful as I'm still an Elisp noob, but it’s worth a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants