cofi / evil-leader

<leader> key for evil
GNU General Public License v3.0
317 stars 23 forks source link

Cannot bind <leader> <SPC>. #32

Open gregory-nisbet opened 8 years ago

gregory-nisbet commented 8 years ago

Using the below configuration file (and the latest version of evil-mode and evil-leader as a submodule in my .emacs/modules directory), I am able to reproduce a bug where <leader> b is defined, but <leader> <SPC> is not. The same weirdness occurs with a leader key of ",".

(require 'cl-lib)
(cl-pushnew "~/.emacs.d/modules/evil-mode" load-path)
(cl-pushnew "~/.emacs.d/modules/evil-leader" load-path)

(require 'evil)
(require 'evil-leader)

(global-evil-leader-mode +1)
(evil-mode +1)
(global-evil-leader-mode +1)
;; set-leader is finicky and doesn't reject keys it doesn't understand
(evil-leader/set-leader "<SPC>")

(evil-leader/set-key (kbd "<SPC>") #'backward-word)
(evil-leader/set-key (kbd "b") #'backward-word)

Here is the section of the output of C-h b related to evil-leader bindings.

`evil-normal-state-local-minor-mode' Minor Mode Bindings:
key             binding
---             -------

SPC     Prefix Command

SPC b       backward-word

Note: as a workaround, modifying the default map directly fixes the problem.

(define-key evil-leader--default-map (kbd "<SPC>") #'backward-word)

Ah! okay. It turns out you have to do

(evil-leader/set-key "SPC" #'backward-word)
redeemefy commented 3 years ago

I know this is old but thought to share my snippet.

(use-package evil-leader ; ----------------------------------- Set your VIM leader key
  :config
  (global-evil-leader-mode)
  (evil-leader/set-leader "<SPC>") ; ------------------------- Spacebar as leader key
  (evil-leader/set-key
    "cff" 'counsel-find-file ; ------------------------------- Default file search
    "cfz" 'counsel-fzf ; ------------------------------------- Recursive search by file name with fuzzy matching
    "crg" 'counsel-rg ; -------------------------------------- Recursive search by string content with ripgrep
    "csb" 'counsel-switch-buffer ; --------------------------- List buffers with counsel
    "cdf" 'counsel-describe-function ; ----------------------- Describe functions with counsel
    "cdv" 'counsel-describe-variable ; ----------------------- Describe variables with counsel
    "kb" 'kill-buffer ; -------------------------------------- Default kill buffer
    "i" 'swiper ; -------------------------------------------- Isearch current buffer with swiper
    "zsh" 'shell ; ------------------------------------------- Default open shell buffer
    "sb" 'save-buffer ; -------------------------------------- Default save current buffer
    "mx" 'counsel-M-x ; -------------------------------------- Easier access to M-x
    ))