2020-11-01 02:56:34 +01:00
|
|
|
* Hydra
|
|
|
|
** Base
|
|
|
|
#+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)
|
|
|
|
("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))
|
|
|
|
|
|
|
|
(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))
|
|
|
|
|
|
|
|
(defhydra magic_rb/hydra-lsp (:color red :inherit (magic_rb/hydra-base/heads))
|
2020-11-02 01:45:52 +01:00
|
|
|
("e" lsp-execute-code-action))
|
|
|
|
|
|
|
|
(defhydra magic_rb/hydra-org (:color red :inherit (magic_rb/hydra-base/heads))
|
|
|
|
("'" org-cycle-agenda-files :color blue))
|
2020-11-01 02:56:34 +01:00
|
|
|
#+END_SRC
|
|
|
|
** 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
|
|
|
|
*** 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
|
|
|
|
#+NAME: hydra
|
2020-11-02 01:45:52 +01:00
|
|
|
#+BEGIN_SRC emacs-lisp :noweb yes :tangle yes
|
2020-11-01 02:56:34 +01:00
|
|
|
(use-package hydra
|
|
|
|
:ensure t
|
2020-11-02 01:45:52 +01:00
|
|
|
:after (vterm magit treemacs lsp-mode) ; rustic
|
2020-11-01 02:56:34 +01:00
|
|
|
:config
|
|
|
|
(defvar hydra-stack nil)
|
2020-11-02 01:45:52 +01:00
|
|
|
: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
|
|
|
|
|
|
|
<<hydra-base>>
|
|
|
|
|
|
|
|
<<hydra-window>>
|
|
|
|
|
|
|
|
<<hydra-rust>>
|
|
|
|
#+END_SRC
|
2020-11-02 01:45:52 +01:00
|
|
|
|