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

Wrong key bindings in LSP UI flycheck <M-return> <return> #765

Open farazshaikh opened 4 months ago

farazshaikh commented 4 months ago

RET and return are different keys in emacs. Binding such a M- don't work if emacs is in terminal mode.

For bindings to work both in terminal and UI. The correct binding is RET and M-RET

https://github.com/emacs-lsp/lsp-ui/blame/bc58c6664577d1d79060c6b32b7ad20e70ee19d0/lsp-ui-flycheck.el#L158 (let ((map (make-sparse-keymap))) (define-key map (kbd "q") 'lsp-ui-flycheck-list--quit)

https://www.fromkk.com/posts/c-m-ret-and-return-key-in-emacs/

farazshaikh commented 4 months ago
From 7035599fff1fcf69d45ee466b9a8541dfd199a86 Mon Sep 17 00:00:00 2001
From: faraz <faraz.shaikh@gmail.com>
Date: Fri, 1 Mar 2024 16:42:53 -0800
Subject: [PATCH] Fix lsp-ui-flycheck-list--visit binding to M-RET

RET and return are different keys in emacs.
Binding such a M- don't work if emacs is in terminal mode.

For bindings to work both in terminal and UI. The correct binding is RET and M-RET

https://github.com/emacs-lsp/lsp-ui/blame/bc58c6664577d1d79060c6b32b7ad20e70ee19d0/lsp-ui-flycheck.el#L158
https://www.fromkk.com/posts/c-m-ret-and-return-key-in-emacs/
(cherry picked from commit 2c66ab8fd8715623bef0fdebd21aca2da706e51d)
---
 lsp-ui-flycheck.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lsp-ui-flycheck.el b/lsp-ui-flycheck.el
index e3ac831..e9a6dc6 100644
--- a/lsp-ui-flycheck.el
+++ b/lsp-ui-flycheck.el
@@ -154,8 +154,8 @@ Use `lsp-diagnostics' to receive diagnostics from your LSP server."
 (defvar lsp-ui-flycheck-list-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "q") 'lsp-ui-flycheck-list--quit)
-    (define-key map (kbd "<return>") 'lsp-ui-flycheck-list--view)
-    (define-key map (kbd "<M-return>") 'lsp-ui-flycheck-list--visit)
+    (define-key map (kbd "<RET>") 'lsp-ui-flycheck-list--view)
+    (define-key map (kbd "<M-RET>") 'lsp-ui-flycheck-list--visit)
     map)
   "Keymap for ‘lsp-ui-flycheck-list-mode’.")

-- 
2.34.1