mirror of
https://github.com/Foltik/dotfiles
synced 2024-11-24 04:22:50 -05:00
Add which-key helper
This commit is contained in:
parent
adb3d0ce0c
commit
680ff99579
@ -98,44 +98,49 @@ keybindings following incomplete commands.
|
|||||||
#+END_SRC
|
#+END_SRC
|
||||||
** General
|
** General
|
||||||
[[https://github.com/noctuid/general.el][General]] is an excellent keybind manager that adds *tons* of useful macros.
|
[[https://github.com/noctuid/general.el][General]] is an excellent keybind manager that adds *tons* of useful macros.
|
||||||
|
Also set up a leader key and prefixes, like =\= in Vim.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package general)
|
(use-package general
|
||||||
#+END_SRC
|
:config
|
||||||
** Leaders
|
(general-create-definer jf-leader-def
|
||||||
Create a leader key, =SPC=, like =\= in vim.
|
:keymaps 'override
|
||||||
Different button presses after the leader bring you to different options.
|
:states '(normal insert emacs)
|
||||||
#+BEGIN_SRC emacs-lisp
|
:prefix "SPC"
|
||||||
(general-create-definer jf-leader-def
|
:non-normal-prefix "M-SPC")
|
||||||
:keymaps 'override
|
|
||||||
:states '(normal insert emacs)
|
|
||||||
:prefix "SPC"
|
|
||||||
:non-normal-prefix "M-SPC")
|
|
||||||
|
|
||||||
(defmacro jf-create-definers (definitions)
|
(defun jf-create-wk-prefix (desc)
|
||||||
"A wrapper for general-create-definer.
|
"Helper for creating which-key prefix descriptions.
|
||||||
For every pair in DEFINITIONS, creates a leader
|
Bind to a key with general to make which-key show DESC
|
||||||
with name jf-NAME-def and keybind SPC KEY or M-SPC KEY in normal mode."
|
as the prefix's description"
|
||||||
`(progn
|
`(:ignore t :wk ,desc))
|
||||||
,@(mapcan
|
|
||||||
(lambda (def)
|
|
||||||
(let ((key (car def))
|
|
||||||
(name (cdr def)))
|
|
||||||
`((general-create-definer ,(intern (concat "jf-" name "-def"))
|
|
||||||
:keymaps 'override
|
|
||||||
:states '(normal insert emacs)
|
|
||||||
:prefix ,(concat "SPC " key)
|
|
||||||
:non-normal-prefix ,(concat "M-SPC " key))
|
|
||||||
(jf-leader-def ,key '(:ignore t :wk ,name)))))
|
|
||||||
definitions)))
|
|
||||||
|
|
||||||
(jf-create-definers
|
(defmacro jf-create-definers (definitions)
|
||||||
(("b" . "buffers")
|
"A wrapper for general-create-definer.
|
||||||
("f" . "files")
|
For every pair in DEFINITIONS, creates a leader
|
||||||
("g" . "git")
|
with name jf-NAME-def and keybind SPC KEY or M-SPC KEY in normal mode."
|
||||||
("h" . "help")
|
`(progn
|
||||||
("o" . "org")
|
,@(mapcan
|
||||||
("p" . "projects")
|
(lambda (def)
|
||||||
("w" . "windows")))
|
(let ((key (car def))
|
||||||
|
(name (cdr def)))
|
||||||
|
`((general-create-definer ,(intern (concat "jf-" name "-def"))
|
||||||
|
:keymaps 'override
|
||||||
|
:states '(normal insert emacs)
|
||||||
|
:prefix ,(concat "SPC " key)
|
||||||
|
:non-normal-prefix ,(concat "M-SPC " key))
|
||||||
|
(jf-leader-def ,key ',(jf-create-wk-prefix name)))))
|
||||||
|
definitions)))
|
||||||
|
|
||||||
|
(jf-create-definers
|
||||||
|
(("a" . "apps")
|
||||||
|
("b" . "buffers")
|
||||||
|
("f" . "files")
|
||||||
|
("g" . "git")
|
||||||
|
("h" . "help")
|
||||||
|
("m" . "major")
|
||||||
|
("o" . "org")
|
||||||
|
("p" . "projects")
|
||||||
|
("w" . "windows"))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
* Vim Emulation
|
* Vim Emulation
|
||||||
** Evil
|
** Evil
|
||||||
|
Loading…
Reference in New Issue
Block a user