From 15cd2d5e0c169cb5336bfc81724726e19e05163e Mon Sep 17 00:00:00 2001 From: Benjamin Andresen Date: Mon, 26 Jun 2017 20:32:28 +0200 Subject: [PATCH] Add: feature/hydra: initial commit --- init.example.el | 1 + modules/feature/hydra/autoload/evil.el | 2 + modules/feature/hydra/autoload/hydras.el | 2 + modules/feature/hydra/config.el | 94 ++++++++++++++++++++++++ modules/feature/hydra/packages.el | 7 ++ 5 files changed, 106 insertions(+) create mode 100644 modules/feature/hydra/autoload/evil.el create mode 100644 modules/feature/hydra/autoload/hydras.el create mode 100644 modules/feature/hydra/config.el create mode 100644 modules/feature/hydra/packages.el diff --git a/init.example.el b/init.example.el index dfb909fff..8ed76bc60 100644 --- a/init.example.el +++ b/init.example.el @@ -34,6 +34,7 @@ jump ; helping you get around snippets ; my elves. They type so I don't have to file-templates ; auto-snippets for empty files + hydra ; keybindings that stick around spellcheck ; tasing you for misspelling mispelling syntax-checker ; tasing you for every semicolon you forget version-control ; remember, remember that commit in November diff --git a/modules/feature/hydra/autoload/evil.el b/modules/feature/hydra/autoload/evil.el new file mode 100644 index 000000000..92aa9cdef --- /dev/null +++ b/modules/feature/hydra/autoload/evil.el @@ -0,0 +1,2 @@ +;;; feature/hydra/autoload/evil.el -*- lexical-binding: t; -*- + diff --git a/modules/feature/hydra/autoload/hydras.el b/modules/feature/hydra/autoload/hydras.el new file mode 100644 index 000000000..002f91420 --- /dev/null +++ b/modules/feature/hydra/autoload/hydras.el @@ -0,0 +1,2 @@ +;;; feature/hydra/autoload/hydras.el -*- lexical-binding: t; -*- + diff --git a/modules/feature/hydra/config.el b/modules/feature/hydra/config.el new file mode 100644 index 000000000..51dc55260 --- /dev/null +++ b/modules/feature/hydra/config.el @@ -0,0 +1,94 @@ +;;; feature/hydra/config.el -*- lexical-binding: t; -*- + +(def-package! hydra + :commands (+hydra-zoom/body +hydra-window/body) + :config + (defhydra +hydra-zoom (:hint t :color red) + "zoom" + ("j" text-scale-increase "in") + ("k" text-scale-decrease "out") + ("0" (text-scale-set 0) "reset")) + + (defhydra +hydra-window (:hint nil) + " + Split: _v_ert _s_:horz + Delete: _c_lose _o_nly + Switch Window: _h_:left _j_:down _k_:up _l_:right + Buffers: _p_revious _n_ext _b_:select _f_ind-file + Resize: _H_:splitter left _J_:splitter down _K_:splitter up _L_:splitter right + Move: _a_:up _z_:down _i_menu" + + + ("z" scroll-up-line) + ("a" scroll-down-line) + ("i" idomenu) + + ("h" windmove-left) + ("j" windmove-down) + ("k" windmove-up) + ("l" windmove-right) + + ("p" previous-buffer) + ("n" next-buffer) + ("b" ido-switch-buffer) + ("f" ido-find-file) + + ("s" split-window-below) + ("v" split-window-right) + + ("c" delete-window) + ("o" delete-other-windows) + + ("H" hydra-move-splitter-left) + ("J" hydra-move-splitter-down) + ("K" hydra-move-splitter-up) + ("L" hydra-move-splitter-right) + + ("q" nil))) + + +(when (featurep! :completion ivy) + (def-package! ivy-hydra + :config + (define-key ivy-mode-map (kbd "C-o") + (defhydra coo-ivy (:hint nil :color pink) + " + Move ^^^^^^^^^^ | Call ^^^^ | Cancel^^ | Options^^ | Action _w_/_s_/_a_: %s(ivy-action-name) +----------^^^^^^^^^^-+--------------^^^^-+-------^^-+--------^^-+--------------------------------- + _g_ ^ ^ _k_ ^ ^ _u_ | _f_orward _o_ccur | _i_nsert | _c_alling: %-7s(if ivy-calling \"on\" \"off\") _C_ase-fold: %-10`ivy-case-fold-search + ^↨^ _h_ ^+^ _l_ ^↕^ | _RET_ done ^^ | _q_uit | _m_atcher: %-7s(ivy--matcher-desc) _t_runcate: %-11`truncate-lines + _G_ ^ ^ _j_ ^ ^ _d_ | _TAB_ alt-done ^^ | ^ ^ | _<_/_>_: shrink/grow +" + ;; arrows + ("j" ivy-next-line) + ("k" ivy-previous-line) + ("l" ivy-alt-done) + ("h" ivy-backward-delete-char) + ("g" ivy-beginning-of-buffer) + ("G" ivy-end-of-buffer) + ("d" ivy-scroll-up-command) + ("u" ivy-scroll-down-command) + ("e" ivy-scroll-down-command) + ;; actions + ("q" keyboard-escape-quit :exit t) + ("C-g" keyboard-escape-quit :exit t) + ("" keyboard-escape-quit :exit t) + ("C-o" nil) + ("i" nil) + ("TAB" ivy-alt-done :exit nil) + ("C-j" ivy-alt-done :exit nil) + ;; ("d" ivy-done :exit t) + ("RET" ivy-done :exit t) + ("C-m" ivy-done :exit t) + ("f" ivy-call) + ("c" ivy-toggle-calling) + ("m" ivy-toggle-fuzzy) + (">" ivy-minibuffer-grow) + ("<" ivy-minibuffer-shrink) + ("w" ivy-prev-action) + ("s" ivy-next-action) + ("a" ivy-read-action) + ("t" (setq truncate-lines (not truncate-lines))) + ("C" ivy-toggle-case-fold) + + ("o" ivy-occur :exit t))))) diff --git a/modules/feature/hydra/packages.el b/modules/feature/hydra/packages.el new file mode 100644 index 000000000..08cbb525d --- /dev/null +++ b/modules/feature/hydra/packages.el @@ -0,0 +1,7 @@ +;; -*- no-byte-compile: t; -*- +;;; feature/hydra/packages.el + +(package! hydra) +(when (featurep! :completion ivy) + (package! ivy-hydra)) +