How do I remap the lsp-mode prefix key to "s-k" using the use-package package?

I tried the following

(use-package lsp-mode
  :ensure t
  (setq lsp-keymap-prefix (kbd "s-k")

 ("s-k" . lsp-keymap-prefix)

 :bind (:map lsp-command-map
 ("s-k" . lsp-keymap-prefix))

I don't seem to understand how this works. What am I doing wrong?

EDIT 1: I am not sure if I should open a new issue for this. I followed the suggested solutions without success, when another issue occured:

Error (use-package): Failed to parse package lsp-mode: Wrong type argument: listp, lsp-keymap-prefix

Whene using emacs --debug-init, I get

Debugger entered--Lisp error: (void-variable personal-keybindings)
  byte-code("\3061\247\0\307\310N\206\13\0\311\307\312\"\210\313\310N\206\26\0\311\313\10\"\210\313\310N\206!\0\311\313\11\"\210\314\315!\2042\0\316\315\317\320\321$\210..." [read-process-output-max lsp-idle-delay name key kmap kdesc (debug error) gc-cons-threshold custom-set set-default 100000000 setq fboundp lsp autoload "lsp-mode" nil t lsp-command-map add-hook c++-mode-hook "s-k" vectorp read-kbd-macro key-description lookup-key assoc add-to-list personal-keybindings define-key :catch global-map binding details entry err use-package--warning1] 6)
  eval-buffer(#<buffer  *load*> nil "/home/nry/.emacs" nil t)  ; Reading at buffer position 1076
  load-with-code-conversion("/home/nry/.emacs" "/home/nry/.emacs" t t)
  load("~/.emacs" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x158e8a4509ed>) #f(compiled-function () #<bytecode 0x158e8a450a01>) t)

After a little more investigations, it turns out that this happens every time I use :bind, I had to comment out the :bind- statements from other packages as well to get rid of the error message. This was not the case before I started to change the prefix key! All I did was playing around with the bind-statements, like

(setq lsp-keymap-prefix (kbd "s-k")


  ("s-k" . lsp-command-map) ;; not working

  ("s-k" . lsp-command-map)

I set everything back as it was, but the error message stays (if I use :bind in other packages like e.g. company). But it ONLY stays, if I byte compile my directory. If I only use the .el files, no error occurs. It feels like I broke my config or the use-package package. Any sugggestions?

EDIT 2: I found the solution to the issue describe in EDIT 1. I had to add

  (require 'use-package))

to my .emacs file. Also, changing the prefix-key was solved as well with:

  ("s-k" . lsp-command-map)


2 Answers 2


You want to set that variable to a string. This ought to work:

(use-package lsp-mode
  (setq lsp-keymap-prefix "s-k"))

You had :ensure t in there as well, but it doesn't have anything to do with configuring the package; instead it causes use-package to try to install lsp-mode if it isn't available. You might want to include it, or you might not.

The second form might in principle also work, with a little adjustment:

  ("s-k" . lsp-command-map)

However, when lsp-mode is loaded it will still use the lsp-command-prefix variable to set up a key binding that loads lsp-command-map as the active keyboard map; it's likely that you would end up with two prefix keys that lead to this same set of commands. Not fatal, but potentially confusing.

  • Thanks for your comment! Unfortunately, another error occurred (see edit) and I cannot 100% confirm if any of the provided solutions work for me.
    – Andi
    Sep 22, 2020 at 12:09
  • :bind-keymap ("s-k" . lsp-command-map) did the trick :)
    – Andi
    Sep 22, 2020 at 21:05
  • 1
    For me, setting lsp-keymap-prefix successfully changes the variable, with no error message, but it doesn't affect the binding. My key combination remains unbound. Sep 13, 2021 at 17:20
  • @NormanRamsey, you should create a new question with all relevant details.
    – db48x
    Sep 13, 2021 at 18:54

According to this GitHub issue, you need to use bind-keymap and not just bind because this is really a keymap you are binding, not a function.

The following worked for me:

  ("<f11>" . lsp-command-map)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.