doomemacs/private/my-bindings.el

437 lines
13 KiB
EmacsLisp
Raw Normal View History

2015-06-06 06:40:33 -04:00
;;; my-bindings.el
;; Minimalistic key mapping! Why go so far for this?
;; ...
;; Uh. Good question.
2015-06-15 09:10:28 +02:00
(eval-when-compile (require 'core-defuns))
;; See `narf-leader-prefix' & `narf-localleader-prefix' in ../core/core-vars.el
(map!
2015-06-06 06:40:33 -04:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Global keymaps ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
"M-x" 'helm-M-x
"M-;" 'eval-expression
"M-/" 'evil-commentary-line
"A-x" 'helm-M-x
"A-;" 'eval-expression
"A-/" 'evil-commentary-line
2015-12-11 22:43:31 -05:00
"M-0" (λ! (text-scale-set 0))
"M-=" 'text-scale-increase
"M--" 'text-scale-decrease
2015-12-09 02:10:27 -05:00
;; debug
"<f9>" 'what-face
"M-b" 'narf:build
2015-12-29 23:37:43 -05:00
"M-t" 'narf:tab-create
"M-T" 'narf/tab-display
"A-`" 'os-switch-to-term
"C-`" 'narf/popup-messages
"C-~" 'rtog/toggle-repl
2015-12-09 02:10:27 -05:00
"M-`" 'narf/popup-toggle
2015-12-29 23:37:43 -05:00
"M-w" 'narf/close-window-or-tab
"M-W" 'delete-frame
"M-n" 'narf/new-buffer
"M-N" 'narf/new-frame
2015-09-30 13:49:37 -04:00
;; Simpler window navigation
"C-j" 'evil-window-down
"C-k" 'evil-window-up
"C-h" 'evil-window-left
2016-02-04 19:00:03 -05:00
"C-l" 'evil-window-right
2015-09-30 13:49:37 -04:00
2015-12-09 02:10:27 -05:00
"C-<escape>" 'evil-emacs-state
:e "C-<escape>" 'evil-normal-state
2015-11-10 18:10:32 -05:00
:m "M-j" 'narf/multi-next-line
:m "M-k" 'narf/multi-previous-line
2015-06-06 06:40:33 -04:00
2015-06-15 09:10:28 +02:00
:n "M-r" 'narf:eval-buffer
:v "M-r" 'narf:eval-region
:n "M-o" 'narf/ido-find-file
:n "M-O" 'narf/ido-find-project-file
2015-06-06 06:40:33 -04:00
2015-12-29 23:37:43 -05:00
:m "M-1" (λ! (narf:switch-to-tab 0))
:m "M-2" (λ! (narf:switch-to-tab 1))
:m "M-3" (λ! (narf:switch-to-tab 2))
:m "M-4" (λ! (narf:switch-to-tab 3))
:m "M-5" (λ! (narf:switch-to-tab 4))
:m "M-6" (λ! (narf:switch-to-tab 5))
:m "M-7" (λ! (narf:switch-to-tab 6))
:m "M-8" (λ! (narf:switch-to-tab 7))
:m "M-9" (λ! (narf:switch-to-tab 8))
2015-10-05 03:43:00 -04:00
2015-06-06 06:40:33 -04:00
(:when IS-MAC
"<A-left>" 'backward-word
"<A-right>" 'forward-word
2015-06-15 09:10:28 +02:00
"<M-backspace>" 'narf/backward-kill-to-bol-and-indent
2015-06-06 06:40:33 -04:00
"A-SPC" 'just-one-space
"M-a" 'mark-whole-buffer
"M-c" 'evil-yank
2015-12-23 03:46:42 -05:00
"M-s" 'evil-write
2015-06-06 06:40:33 -04:00
"M-v" 'clipboard-yank
"M-q" 'evil-quit-all
"M-z" 'undo
"M-Z" 'redo
"C-M-f" 'narf:toggle-fullscreen
2016-02-20 16:16:44 -05:00
:ni "<M-f1>" 'narf/dash-at-pt
;; Textmate-esque indent shift left/right
2016-01-07 01:11:32 -05:00
:i "M-]" 'narf/smart-indent
:i "M-[" 'narf/dumb-dedent
;; Restore osx text objects
:i "<A-backspace>" 'evil-delete-backward-word
2015-12-11 22:43:31 -05:00
:i "<A-delete>" (λ! (evil-forward-word) (evil-delete-backward-word)))
2015-06-06 06:40:33 -04:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Local keymaps ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2015-08-21 12:40:04 -04:00
:m ";" 'evil-ex
(:leader
2015-12-09 02:10:27 -05:00
:nv "," 'narf/helm-buffers-dwim
:nv "<" 'helm-buffers-list
:nv "." 'helm-find-files
:nv ">" 'helm-projectile-find-file-in-known-projects
:nv "/" 'helm-projectile-find-file
:nv ";" 'helm-semantic-or-imenu
:nv ":" 'helm-imenu-in-all-buffers
:nv "]" 'helm-etags-select
:nv "a" 'helm-projectile-find-other-file
:nv "m" 'helm-recentf
:nv "M" 'helm-projectile-recentf ; recent PROJECT files
:nv "P" 'helm-projectile-switch-project
:v "=" 'align-regexp
2015-12-23 03:46:42 -05:00
:n "k" 'narf/helm-descbinds-leader
2015-12-09 02:10:27 -05:00
:n "h" 'help-command
:nv "p" 'helm-show-kill-ring
:n "R" 'narf/reset-theme
:n "e" 'narf/flycheck-errors
:n "s" 'yas-visit-snippet-file
:n "S" 'narf/yas-find-file
NARF v0.7.0 vcs: + +git-gutter to conf-modes; -git-gutter from evil-insert-state-exit + switch github-browse-file for browse-at-remote + fix <leader>ob; add <leader>d[./sr] vc bindings + vc-annotate bindings and initial state Workgroups2 integration: + don't mess with buffers (speeds up emacs a lot!) + unicode numbers in display + single display function + remember workgroup uid instead (and smarter :tabrename) + clean up after wg update Org-mode + give highlight precedence to links in org-mode + enable encryption + config clean up + use different font for org + exclude attachments in recentf + redo latex and inline-image config + add narf/org-open-notes + update file templates for org CRM Mode-line + polish mode-line + decouple from spaceline-segments.el + refactor narf|spaceline-env-update + add macro-recording and buffer-size indicators to mode-line + python: '2>&1' in env-command + flycheck fringe indicator: change to arrow Aesthetics + update narf-dark-theme + add narf-minibuffer-active face + change writing indicator in writing-mode Misc + fix whitespace in display-startup-echo-area-message + reset fonts for more unicode characters + custom imenu entries + helm-imenu fontification + enable yascroll-bar in REPLs + reorganize my-commands.el + force quit iedit on ESC in normal mode + update snippets submodule + remove ido init (helm handles it all) [EXPERIMENTAL] + back to Terminus(TTF) font + popwin: update config for git-gutter and vc-diff windows + highlight :g[lobal] and :al[ign] matches + decouple narf/get-buffers+narf/get-all-buffers from wg-mess-with-buffer-list + fix narf/helm-buffers-dwim (add interactive form)
2015-12-11 16:51:04 -05:00
:n "D" 'vc-annotate
(:prefix "d"
:n "." 'narf/vcs-show-hunk
:n "/" 'vc-diff
:n "s" 'narf/vcs-stage-hunk
:n "r" 'narf/vcs-revert-hunk)
2015-12-09 02:10:27 -05:00
:n "b" 'helm-bookmarks
2015-12-29 23:37:43 -05:00
:n "w" 'narf/tab-display
:n "W" 'narf/helm-tabs
2015-12-09 02:10:27 -05:00
2015-12-23 03:46:42 -05:00
:n "n" 'narf/neotree
2015-12-09 02:10:27 -05:00
:nv "l" 'narf/nlinum-toggle
:nv "qq" 'evil-save-and-quit
:nv "QQ" 'narf/kill-all-buffers-do-not-remember
2015-12-10 16:15:09 -05:00
:nv "E" 'narf/helm-find-in-emacsd
:nv "\\" 'narf/helm-find-in-dotfiles
2015-12-09 02:10:27 -05:00
;; Tmux
(:prefix "t"
:n "." 'narf/tmux-cd-to-here
:n "/" 'narf/tmux-cd-to-project
:n "s" 'narf/tmux-split-window
:n "v" 'narf/tmux-vsplit-window
:n "c" 'narf/tmux-new-window
:v "r" 'narf:tmux)
;; Open with O/S
:n "O" 'os-reveal
(:prefix "o"
:n "o" 'os-open-in-default-program
:n "p" 'os-reveal-project
NARF v0.7.0 vcs: + +git-gutter to conf-modes; -git-gutter from evil-insert-state-exit + switch github-browse-file for browse-at-remote + fix <leader>ob; add <leader>d[./sr] vc bindings + vc-annotate bindings and initial state Workgroups2 integration: + don't mess with buffers (speeds up emacs a lot!) + unicode numbers in display + single display function + remember workgroup uid instead (and smarter :tabrename) + clean up after wg update Org-mode + give highlight precedence to links in org-mode + enable encryption + config clean up + use different font for org + exclude attachments in recentf + redo latex and inline-image config + add narf/org-open-notes + update file templates for org CRM Mode-line + polish mode-line + decouple from spaceline-segments.el + refactor narf|spaceline-env-update + add macro-recording and buffer-size indicators to mode-line + python: '2>&1' in env-command + flycheck fringe indicator: change to arrow Aesthetics + update narf-dark-theme + add narf-minibuffer-active face + change writing indicator in writing-mode Misc + fix whitespace in display-startup-echo-area-message + reset fonts for more unicode characters + custom imenu entries + helm-imenu fontification + enable yascroll-bar in REPLs + reorganize my-commands.el + force quit iedit on ESC in normal mode + update snippets submodule + remove ido init (helm handles it all) [EXPERIMENTAL] + back to Terminus(TTF) font + popwin: update config for git-gutter and vc-diff windows + highlight :g[lobal] and :al[ign] matches + decouple narf/get-buffers+narf/get-all-buffers from wg-mess-with-buffer-list + fix narf/helm-buffers-dwim (add interactive form)
2015-12-11 16:51:04 -05:00
:n "b" 'os-open-in-browser
2015-12-09 02:10:27 -05:00
:n "u" 'os-upload
:n "U" 'os-upload-folder
:n "l" 'os-send-to-launchbar
:n "L" 'os-send-project-to-launchbar
:n "t" 'os-switch-to-term
:n "T" 'os-switch-to-term-and-cd)
;; Org notes
(:prefix "x"
:n "." 'narf/helm-org-find-files
:n "/" 'narf/helm-org
2016-02-13 01:13:23 -05:00
:n "x" 'narf/org-open-notes
2015-12-09 02:10:27 -05:00
:n "p" 'narf/helm-org-crm-projects
:n "c" 'narf/helm-org-crm-contacts
:n "i" 'narf/helm-org-crm-invoices
:n "w" 'narf/helm-org-writing))
(:localleader
2015-12-23 03:46:42 -05:00
:n "k" 'narf/helm-descbinds-localleader
2015-12-09 02:10:27 -05:00
:n "b" 'narf:build
:n "R" 'narf:repl
:v "R" 'narf:repl-eval
:v "r" 'narf:eval-region
(:prefix "r"
:n "e" 'emr-show-refactor-menu
2015-12-25 21:08:08 -05:00
:n "r" 'narf:eval-buffer)
2015-12-09 02:10:27 -05:00
;; :n "t" unit tests prefix
)
:nv "K" 'smart-up
2015-06-06 06:40:33 -04:00
2015-10-05 03:43:00 -04:00
;; Don't move cursor on indent
2015-12-11 22:43:31 -05:00
:n "=" (λ! (save-excursion (call-interactively 'evil-indent)))
2015-12-09 02:10:27 -05:00
:v "=" 'evil-indent
:n "zr" 'narf/evil-open-folds
:n "zm" 'narf/evil-close-folds
:n "zx" 'narf/kill-real-buffer
2015-12-09 02:10:27 -05:00
:n "ZX" 'bury-buffer
;; These are intentionally reversed
:n "]b" 'narf/previous-real-buffer
:n "[b" 'narf/next-real-buffer
2015-12-09 02:10:27 -05:00
:m "]d" 'narf/vcs-next-hunk
:m "[d" 'narf/vcs-prev-hunk
:m "]e" 'narf/flycheck-next-error
:m "[e" 'narf/flycheck-previous-error
2015-12-29 23:37:43 -05:00
;; Switch tabs
:n "]w" 'narf:switch-to-tab-right
:n "[w" 'narf:switch-to-tab-left
:m "gt" 'narf:switch-to-tab-right
:m "gT" 'narf:switch-to-tab-left
2015-06-06 06:40:33 -04:00
;; Increment/decrement number under cursor
2015-12-09 02:10:27 -05:00
:n "g=" 'evil-numbers/inc-at-pt
:n "g-" 'evil-numbers/dec-at-pt
2016-02-18 05:09:59 -05:00
;; NOTE: Helm is too bulky for ffap (which I use for quick file navigation)
2015-12-23 03:46:42 -05:00
:n "gf" (λ! (helm-mode -1)
(call-interactively 'find-file-at-point)
2016-02-18 05:09:59 -05:00
(helm-mode 1))
2015-12-23 03:46:42 -05:00
2015-12-09 02:10:27 -05:00
:n "gc" 'evil-commentary
:n "gx" 'evil-exchange
:n "gr" 'narf:eval-region
:n "gR" 'narf:eval-buffer
:v "gR" 'narf:eval-region-and-replace
:m "g]" 'smart-right
:m "g[" 'smart-left
:v "@" 'narf/evil-macro-on-all-lines
:n "g@" 'narf/evil-macro-on-all-lines
:v "." 'evil-repeat
2015-06-06 06:40:33 -04:00
;; vnoremap < <gv
2015-12-11 22:43:31 -05:00
:v "<" (λ! (evil-shift-left (region-beginning) (region-end))
(evil-normal-state)
(evil-visual-restore))
2015-06-06 06:40:33 -04:00
;; vnoremap > >gv
2015-12-11 22:43:31 -05:00
:v ">" (λ! (evil-shift-right (region-beginning) (region-end))
(evil-normal-state)
(evil-visual-restore))
2015-06-06 06:40:33 -04:00
2016-02-18 05:09:59 -05:00
;; undo/redo for regions (NOTE: Buggy!)
:nv "u" 'undo-tree-undo
:nv "C-r" 'undo-tree-redo
2015-06-06 06:40:33 -04:00
2015-12-09 02:10:27 -05:00
:v "*" 'evil-visualstar/begin-search-forward
:v "#" 'evil-visualstar/begin-search-backward
2015-06-06 06:40:33 -04:00
2016-02-18 05:09:59 -05:00
:n "Y" "y$"
2015-06-06 06:40:33 -04:00
;; paste from recent yank register; which isn't overwritten by deletes or
;; other operations.
2016-02-18 05:09:59 -05:00
:v "C-p" "\"0p"
2015-06-06 06:40:33 -04:00
2015-12-09 02:10:27 -05:00
:v "S" 'evil-surround-region
:v "v" 'er/expand-region
:v "V" 'er/contract-region
2015-06-06 06:40:33 -04:00
;; aliases for %
2015-12-09 02:10:27 -05:00
:m "%" 'evilmi-jump-items
2015-12-11 22:43:31 -05:00
:m [tab] (λ! (cond ((eq major-mode 'org-mode)
(org-cycle))
(t (if (ignore-errors (hs-already-hidden-p))
(hs-toggle-hiding)
(call-interactively 'evilmi-jump-items)))))
2015-06-06 06:40:33 -04:00
;; Textmate-esque newlines
2015-12-09 02:10:27 -05:00
:i "<backspace>" 'backward-delete-char-untabify
:i "<M-backspace>" 'narf/backward-kill-to-bol-and-indent
:i "<C-return>" 'evil-ret-and-indent
2015-06-06 06:40:33 -04:00
;; escape from insert mode (more responsive than using key-chord-define)
:ir "j" 'narf:exit-mode-maybe
2015-06-15 09:10:28 +02:00
:ir "J" 'narf:exit-mode-maybe
2015-06-06 06:40:33 -04:00
:irv "C-g" 'evil-normal-state
2015-12-09 02:10:27 -05:00
:o "s" 'evil-surround-edit
:o "S" 'evil-Surround-edit
2015-06-06 06:40:33 -04:00
2016-02-04 19:00:03 -05:00
:n "!" 'rotate-text
2015-06-06 06:40:33 -04:00
2015-06-15 09:10:28 +02:00
(:map evil-window-map ; prefix "C-w"
"u" 'narf/undo-window-change
2015-11-10 18:10:32 -05:00
;; Jump to new splits
"s" 'narf/evil-window-split
"v" 'narf/evil-window-vsplit
;; Move window in one step
"H" 'narf/evil-window-move-left
"J" 'narf/evil-window-move-down
"K" 'narf/evil-window-move-up
"L" 'narf/evil-window-move-right
"C-u" 'narf/undo-window-change
"C-r" 'narf/redo-window-change
2015-12-23 03:46:42 -05:00
"C-h" 'evil-window-left
"C-j" 'evil-window-down
"C-k" 'evil-window-up
2016-01-07 01:11:02 -05:00
"C-l" 'evil-window-right
2015-06-15 09:10:28 +02:00
"C-w" 'ace-window
2015-12-11 22:43:31 -05:00
"C-S-w" (λ! (ace-window 4)) ; swap windows
"C-C" (λ! (ace-window 16))) ; delete windows
2015-06-15 09:10:28 +02:00
;; Vim omni-complete emulation
2015-06-06 06:40:33 -04:00
:i "C-SPC" 'company-complete-common
2015-12-09 02:10:27 -05:00
(:prefix "C-x"
:i "C-l" 'narf/company-whole-lines
2016-02-22 12:41:45 -05:00
:i "C-k" 'narf/company-dict-or-keywords
2015-12-09 02:10:27 -05:00
:i "C-f" 'company-files
:i "C-]" 'company-tags
:i "s" 'company-ispell
:i "C-s" 'company-yasnippet
:i "C-o" 'company-semantic
:i "C-n" 'company-dabbrev-code
2015-12-11 22:43:31 -05:00
:i "C-p" (λ! (let ((company-selection-wrap-around t))
(call-interactively 'company-dabbrev-code)
(company-select-previous-or-abort))))
2015-06-06 06:40:33 -04:00
2015-06-15 09:10:28 +02:00
(:after company
(:map company-active-map
"C-o" 'company-search-kill-others
2015-11-17 02:13:57 -05:00
"C-n" 'company-select-next
"C-p" 'company-select-previous
"C-h" 'company-show-doc-buffer
2015-06-15 09:10:28 +02:00
"C-S-h" 'company-show-location
"C-S-s" 'company-search-candidates
"C-s" 'company-filter-candidates
2015-10-14 03:39:32 -04:00
"C-SPC" 'company-complete-common-or-cycle
[tab] 'narf/company-complete-common-or-complete-full
2015-06-15 09:10:28 +02:00
"<backtab>" 'company-select-previous
2015-12-11 22:43:31 -05:00
[escape] (λ! (company-abort) (evil-normal-state 1))
2015-08-01 14:40:19 +02:00
"<C-return>" 'helm-company)
2015-06-15 09:10:28 +02:00
(:map company-search-map
"C-n" 'company-search-repeat-forward
"C-p" 'company-search-repeat-backward
[escape] 'company-search-abort))
2015-06-06 06:40:33 -04:00
(:after help-mode
2015-12-09 02:10:27 -05:00
(:map help-map
"e" 'narf/popup-messages
2015-12-09 02:10:27 -05:00
;; Remove slow/annoying help subsections
"h" nil
"g" nil)
2015-06-06 06:40:33 -04:00
(:map help-mode-map
:n "]]" 'help-go-forward
:n "[[" 'help-go-back
:n "<escape>" 'narf/popup-close)))
2015-06-06 06:40:33 -04:00
;; Line-wise mouse selection on margin
(global-set-key (kbd "<left-margin> <down-mouse-1>") 'narf/mouse-drag-line)
(global-set-key (kbd "<left-margin> <mouse-1>") 'narf/mouse-select-line)
(global-set-key (kbd "<left-margin> <drag-mouse-1>") 'narf/mouse-select-line)
2015-06-06 06:40:33 -04:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Keymap fixes ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This section is dedicated to keymaps that "fix" certain keys so
;; that they behave more like vim (or how I like it).
;; Restores "dumb" indentation to the tab key. This rustles a lot of
;; peoples' jimmies, apparently, but it's how I like it.
2015-12-23 03:46:42 -05:00
(map! "C-b" 'backward-word
2016-01-07 01:11:32 -05:00
:i "<tab>" 'narf/dumb-indent
:i "<backtab>" 'narf/dumb-dedent
:i "<C-tab>" 'indent-for-tab-command
;; No dumb-tab for lisp
2015-12-09 02:10:27 -05:00
(:map lisp-mode-map :i [remap narf/dumb-indent] 'indent-for-tab-command)
(:map emacs-lisp-mode-map :i [remap narf/dumb-indent] 'indent-for-tab-command)
;; Highjacks space/backspace to:
;; a) delete spaces on either side of the cursor, if present ( | ) -> (|)
;; b) allow backspace to delete space-indented blocks intelligently
;; c) and not do any of this magic when inside a string
:i "SPC" 'narf/inflate-space-maybe
:i [remap backward-delete-char-untabify] 'narf/deflate-space-maybe
:i [remap newline] 'narf/newline-and-indent
;; Smarter move-to-beginning-of-line
:i [remap move-beginning-of-line] 'narf/move-to-bol
;; Restore bash-esque keymaps in insert mode; C-w and C-a already exist
:i "C-e" 'narf/move-to-eol
:i "C-u" 'narf/backward-kill-to-bol-and-indent
;; Fixes delete
:i "<kp-delete>" 'delete-char
;; Fix osx keymappings and then some
:i "<M-left>" 'narf/move-to-bol
:i "<M-right>" 'narf/move-to-eol
:i "<M-up>" 'beginning-of-buffer
:i "<M-down>" 'end-of-buffer
:i "<C-up>" 'smart-up
:i "<C-down>" 'smart-down
;; Fix emacs motion keys
:i "A-b" 'evil-backward-word-begin
:i "A-w" 'evil-forward-word-begin
:i "A-e" 'evil-forward-word-end
;; Textmate-esque insert-line before/after
:i "<M-return>" 'evil-open-below
:i "<S-M-return>" 'evil-open-above
;; insert lines in-place)
2015-12-11 22:43:31 -05:00
:n "<M-return>" (λ! (save-excursion (evil-insert-newline-below)))
:n "<S-M-return>" (λ! (save-excursion (evil-insert-newline-above)))
;; Make ESC quit all the things
(:map (minibuffer-local-map
minibuffer-local-ns-map
minibuffer-local-completion-map
minibuffer-local-must-match-map
minibuffer-local-isearch-map)
[escape] 'narf-minibuffer-quit
"C-r" 'evil-paste-from-register)
2015-12-09 02:10:27 -05:00
(:map read-expression-map "C-w" 'backward-kill-word)
(:map view-mode-map "<escape>" 'View-quit-all)
(:map evil-ex-completion-map "C-a" 'move-beginning-of-line))
2015-12-09 02:10:27 -05:00
;; Common unicode characters
2015-12-11 22:43:31 -05:00
(map! :i "A-o" (λ! (insert "ø"))
:i "A-O" (λ! (insert "Ø"))
2015-12-11 22:43:31 -05:00
:i "A--" (λ! (insert ""))
:i "A-_" (λ! (insert "")))
2015-10-13 00:47:40 -04:00
2015-06-06 06:40:33 -04:00
(provide 'my-bindings)
;;; my-bindings.el ends here