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)
- (define-key map (kbd "") 'lsp-ui-flycheck-list--view)
-(define-key map (kbd "") 'lsp-ui-flycheck-list--visit)
- (define-key map (kbd "") 'lsp-ui-flycheck-list--view)
-(define-key map (kbd "") 'lsp-ui-flycheck-list--visit)
https://www.fromkk.com/posts/c-m-ret-and-return-key-in-emacs/