emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.76k stars 874 forks source link

yas-minor-mode cannot hook after lsp-mode if re-bind `lsp-keymap-prefix` #3184

Open ccqpein opened 2 years ago

ccqpein commented 2 years ago

Thank you for the bug report

Bug description

My lsp-mode configuration is

(use-package lsp-mode
  :hook
  (;; for yas
   (lsp-mode . yas-minor-mode)

   ;; for change prefix keys
   ;; get from this issue https://github.com/emacs-lsp/lsp-mode/issues/1532
   (lsp-mode . (lambda ()
                 (let ((lsp-keymap-prefix "C-c l"))
                   (lsp-enable-which-key-integration))))
   )

  :commands (lsp lsp-deferred))

Then after I open my rust project, lsp-mode load fine but yas hasn't loaded.

If I change config to

(use-package lsp-mode
  :hook
  (;; for yas
   (lsp-mode . yas-minor-mode)

   ;; for change prefix keys
   ;; get from this issue https://github.com/emacs-lsp/lsp-mode/issues/1532
   ;;(lsp-mode . (lambda ()
   ;;              (let ((lsp-keymap-prefix "C-c l"))
   ;;                (lsp-enable-which-key-integration))))
   )

  :commands (lsp lsp-deferred))

Yas loaded well.

Steps to reproduce

Just as the config in bug description.

Expected behavior

Expect yas mode load after lsp-mode load.

Which Language Server did you use?

rust-analyzer

OS

MacOS

Error callstack

No response

Anything else?

before today, I use :init (setq lsp-keymap-prefix "C-c l") to set lsp-keymap-prefix, but it doesn't work anymore. So I found https://github.com/emacs-lsp/lsp-mode/issues/1532 and make the change as the config I post upper. lsp-keymap-prefix works fine now, but then the yas doesn't load.

ccqpein commented 2 years ago

Arrive my expectation with:

(use-package lsp-mode
  :init
  (setq lsp-keymap-prefix "C-c l")

  :hook
  (;; for yas
   (lsp-mode . yas-minor-mode)
   )

  :commands (lsp lsp-deferred)

  :bind
  (:map lsp-mode-map
        ("C-c l g d" . lsp-find-definition) ;; I like d => definition rather than g
        )

  :config
  (define-key lsp-mode-map (kbd "C-c l") lsp-command-map))

Still don't know why the hook config upper doesn't work.