2020-11-01 02:56:34 +01:00
|
|
|
* Hydra
|
|
|
|
** Base
|
2020-11-04 21:09:36 +01:00
|
|
|
#+NAME: hydra-base
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
|
|
|
(defhydra magic_rb/hydra-base (:color red :body-pre (setq hydra-stack nil))
|
|
|
|
("w" (progn
|
|
|
|
(magic_rb/hydra-window-sub/body)
|
|
|
|
(hydra-push '(magic_rb/hydra-launcher)))
|
|
|
|
"visit magic_rb/hydra-window-sub" :color teal)
|
|
|
|
("d" (progn
|
|
|
|
(magic_rb/hydra-digraph-sub/body)
|
|
|
|
(hydra-push '(magic_rb/hydra-launcher)))
|
|
|
|
"visit magic_rb/hydra-window-sub" :color teal)
|
|
|
|
("s" treemacs-switch-workspace)
|
|
|
|
("S" treemacs-edit-workspaces)
|
|
|
|
("t" treemacs-select-window)
|
|
|
|
("T" treemacs)
|
|
|
|
("v" vterm)
|
|
|
|
("m" magit)
|
|
|
|
("RET" (progn (setq hydra-stack nil)) "Cancel" :color blue)
|
|
|
|
("SPC" (progn (setq hydra-stack nil)) "Cancel" :color blue))
|
2020-11-01 02:56:34 +01:00
|
|
|
|
2020-11-04 21:09:36 +01:00
|
|
|
(defhydra magic_rb/hydra-rust (:color red :inherit (magic_rb/hydra-base/heads))
|
|
|
|
("r" (progn
|
|
|
|
(magic_rb/hydra-rust-sub/body)
|
|
|
|
(hydra-push '(magic_rb/hydra-launcher)))
|
|
|
|
"visit magic_rb/hydra-rust-sub" :color teal)
|
|
|
|
("e" lsp-execute-code-action))
|
2020-11-01 02:56:34 +01:00
|
|
|
|
2020-11-04 21:09:36 +01:00
|
|
|
(defhydra magic_rb/hydra-lsp (:color red :inherit (magic_rb/hydra-base/heads))
|
|
|
|
("e" lsp-execute-code-action))
|
2020-11-02 01:45:52 +01:00
|
|
|
|
2020-11-04 21:09:36 +01:00
|
|
|
(defhydra magic_rb/hydra-org (:color red :inherit (magic_rb/hydra-base/heads))
|
|
|
|
("'" org-cycle-agenda-files :color blue))
|
|
|
|
#+END_SRC
|
2020-11-01 02:56:34 +01:00
|
|
|
** Subs
|
|
|
|
*** Window
|
|
|
|
#+NAME: hydra-window
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
|
|
|
(defhydra magic_rb/hydra-window-sub (:color red)
|
|
|
|
("a" ace-window)
|
|
|
|
("j" windmove-left)
|
|
|
|
("k" windmove-up)
|
|
|
|
("l" windmove-down)
|
|
|
|
(";" windmove-right)
|
|
|
|
("x" delete-window)
|
|
|
|
("RET" hydra-pop "exit" :color blue)
|
|
|
|
("SPC" hydra-pop "exit" :color blue)
|
|
|
|
("q" (progn (setq hydra-stack nil)) "Cancel" :color blue))
|
|
|
|
#+END_SRC
|
2020-11-04 21:09:36 +01:00
|
|
|
*** Window
|
|
|
|
#+NAME: hydra-window
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
|
|
|
(defmacro create-digraph (char keyseq)
|
|
|
|
(list `(char (lambda () (interactive) (insert keyseq)))))
|
|
|
|
|
|
|
|
(macroexpand '(create-digraph "a" "aa"))
|
|
|
|
|
|
|
|
(defhydra magic_rb/hydra-digraph-sub (:color red)
|
|
|
|
(create-digraph "()" "◊")
|
|
|
|
("RET" hydra-pop "exit" :color blue)
|
|
|
|
("SPC" hydra-pop "exit" :color blue)
|
|
|
|
("q" (progn (setq hydra-stack nil)) "Cancel" :color blue))
|
|
|
|
#+END_SRC
|
2020-11-01 02:56:34 +01:00
|
|
|
*** Rust
|
|
|
|
#+NAME: hydra-rust-sub
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
|
|
|
(defhydra magic_rb/hydra-rust-sub ()
|
|
|
|
("b" rustic-cargo-build)
|
|
|
|
("r" rustic-cargo-run)
|
|
|
|
("t" rustic-cargo-test)
|
|
|
|
("f" rustic-format-buffer)
|
|
|
|
("RET" hydra-pop "exit" :color blue)
|
|
|
|
("SPC" hydra-pop "exit" :color blue)
|
|
|
|
("q" (progn (setq hydra-stack nil)) "Cancel" :color blue))
|
|
|
|
#+END_SRC
|
|
|
|
*** LSP
|
2020-11-04 21:09:36 +01:00
|
|
|
#+NAME: hydra
|
|
|
|
#+BEGIN_SRC emacs-lisp :noweb yes :tangle yes
|
|
|
|
(use-package hydra
|
|
|
|
:ensure t
|
|
|
|
:after (vterm magit treemacs lsp-mode) ; rustic
|
|
|
|
:config
|
|
|
|
(defvar hydra-stack nil)
|
|
|
|
:bind (("C-'" . magic_rb/hydra-launcher)
|
|
|
|
:map org-mode-map
|
|
|
|
("C-'" . magic_rb/hydra-launcher)))
|
2020-11-01 02:56:34 +01:00
|
|
|
|
|
|
|
(defun hydra-push (expr)
|
|
|
|
(push `(lambda () ,expr) hydra-stack))
|
|
|
|
|
|
|
|
(defun hydra-pop ()
|
|
|
|
(interactive)
|
|
|
|
(let ((x (pop hydra-stack)))
|
|
|
|
(when x
|
|
|
|
(funcall x))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun magic_rb/hydra-launcher ()
|
|
|
|
"A launcher for hydras based on current context."
|
|
|
|
(interactive)
|
|
|
|
(cl-case major-mode
|
|
|
|
('rustic-mode (magic_rb/hydra-rust/body))
|
|
|
|
('lsp-mode (magic_rb/hydra-rust/body))
|
2020-11-02 01:45:52 +01:00
|
|
|
('org-mode (magic_rb/hydra-org/body))
|
|
|
|
(t (magic_rb/hydra-base/body))))
|
2020-11-01 02:56:34 +01:00
|
|
|
|
2020-11-04 21:09:36 +01:00
|
|
|
<<digraph>>
|
|
|
|
|
2020-11-01 02:56:34 +01:00
|
|
|
<<hydra-base>>
|
|
|
|
|
|
|
|
<<hydra-window>>
|
|
|
|
|
|
|
|
<<hydra-rust>>
|
2020-11-04 21:09:36 +01:00
|
|
|
#+END_SRC
|
2020-11-02 01:45:52 +01:00
|
|
|
|