bind! -> map!; new minimalistic keybinding macro

This commit is contained in:
Henrik Lissner 2015-11-30 05:31:20 -05:00
parent 2e4a083bbb
commit 81df2830a9
19 changed files with 431 additions and 441 deletions

View file

@ -110,54 +110,52 @@ Examples:
`((add-hook 'find-file-hook ',hook-name))))))))))
(after! evil
;; Register keywords for proper indentation (see `bind!')
;; Register keywords for proper indentation (see `map!')
(put ':prefix 'lisp-indent-function 'defun)
(put ':map 'lisp-indent-function 'defun)
(put ':after 'lisp-indent-function 'defun)
(put ':when 'lisp-indent-function 'defun)
(put ':unless 'lisp-indent-function 'defun)
(put ':leader 'lisp-indent-function 'defun)
(put ':localleader 'lisp-indent-function 'defun)
(defmacro bind! (&rest rest)
(defmacro map! (&rest rest)
(let ((i 0)
key def
first-set
prefix
internal
(default-keymaps '((current-global-map)))
(keymaps (if (boundp 'keymaps) keymaps))
(states (if (boundp 'states) states '()))
(forms '())
(keymaps (if (boundp 'keymaps) keymaps))
(default-keymaps '((current-global-map)))
(state-map '(("n" . normal)
("v" . visual)
("i" . insert)
("e" . emacs)
("o" . operator)
("m" . motion)
("r" . replace))))
("r" . replace)))
key def prefix states)
(unless keymaps
(setq keymaps default-keymaps))
(while rest
(setq key (pop rest))
(add-to-list
'forms
(cond ((eq key '-) nil) ; skip this
((listp key) ; it's a sub exp
`((bind! ,@key)))
(cond ((listp key) ; it's a sub exp
`(,(macroexpand `(map! ,@key))))
((keywordp key)
(when (memq key '(:leader :localleader))
(push (pcase key
(:leader narf-leader-prefix)
(:localleader narf-localleader-prefix))
rest)
(setq key :prefix))
(pcase key
;; TODO: Data checks
(:prefix (setq prefix (kbd (pop rest)))
(if (= i 0) (setq first-set `(:prefix . ,prefix)))
nil)
(:map (setq keymaps (-list (pop rest)))
(if (= i 0) (setq first-set `(:map . ,keymaps)))
nil)
(:unset `((bind! ,(kbd (pop rest)) nil)))
(:after (prog1 `((after! ,(pop rest) (bind! ,@rest))) (setq rest '())))
(:when (prog1 `((if ,(pop rest) (bind! ,@rest))) (setq rest '())))
(:unless (prog1 `((if (not ,(pop rest)) (bind! ,@rest))) (setq rest '())))
(:prefix (setq prefix (kbd (pop rest))) nil)
(:map (setq keymaps (-list (pop rest))) nil)
(:unset `(,(macroexpand `(map! ,(kbd (pop rest)) nil))))
(:after (prog1 `((after! ,(pop rest) ,(macroexpand `(map! ,@rest)))) (setq rest '())))
(:when (prog1 `((if ,(pop rest) ,(macroexpand `(map! ,@rest)))) (setq rest '())))
(:unless (prog1 `((if (not ,(pop rest)) ,(macroexpand `(map! ,@rest)))) (setq rest '())))
(otherwise ; might be a state prefix
(mapc (lambda (letter)
(if (assoc letter state-map)
@ -179,16 +177,12 @@ Examples:
(unless (> (length rest) 0)
(user-error "Map has no definition for %s" key))
(setq def (pop rest))
(let ((first-key (car first-set))
(first-value (cdr first-set))
out-forms)
(let (out-forms)
(dolist (keymap keymaps)
(if (not states)
(add-to-list 'out-forms `(evil-define-key nil ,keymap ,key ,def) t)
(dolist (state states)
(add-to-list 'out-forms `(evil-define-key ',state ,keymap ,key ,def) t))))
(setq prefix (if (eq first-key :prefix) first-value))
(setq keymaps (if (eq first-key :map) first-value default-keymaps))
(setq states '())
out-forms))

View file

@ -11,7 +11,7 @@
flycheck-disabled-checkers '(emacs-lisp-checkdoc make))
:config
(evil-initial-state 'flycheck-error-list-mode 'emacs)
(bind! (:map flycheck-error-list-mode-map
(map! (:map flycheck-error-list-mode-map
:n [escape] 'kill-this-buffer
:n "q" 'kill-this-buffer
:n "C-n" 'flycheck-error-list-next-error

View file

@ -32,7 +32,7 @@
(mapc (lambda (r) (add-to-list 'helm-boring-file-regexp-list r))
(list "\\.projects$" "\\.DS_Store$"))
(bind! (:map (helm-map helm-generic-files-map helm-find-files-map helm-swoop-map helm-projectile-find-file-map)
(map! (:map (helm-map helm-generic-files-map helm-find-files-map helm-swoop-map helm-projectile-find-file-map)
"C-w" 'backward-kill-word
"C-r" 'evil-ex-paste-from-register ; Evil registers in helm! Glorious!
"<escape>" 'helm-keyboard-quit

View file

@ -33,7 +33,7 @@
(ido-vertical-mode 1)
(require 'flx-ido)
(flx-ido-mode 1)
(bind! :map (ido-common-completion-map
(map! :map (ido-common-completion-map
ido-completion-map
ido-file-completion-map)
"C-n" 'ido-next-match
@ -68,7 +68,7 @@
neo-modern-sidebar t)
:config
(defun narf|neotree-init-keymap ()
(bind! :map evil-motion-state-local-map
(map! :map evil-motion-state-local-map
"ESC" 'neotree-hide
"\\\\" 'neotree-hide
"RET" 'neotree-enter

View file

@ -23,7 +23,7 @@
yas-snippet-dirs `(,@narf-snippet-dirs)
yas-prompt-functions '(yas-ido-prompt yas-no-prompt))
(bind! :i [(tab)] 'yas-expand
(map! :i [(tab)] 'yas-expand
:v "<backtab>" 'narf/yas-insert-snippet)
(defvar yas-minor-mode-map
@ -40,11 +40,11 @@
;; Simpler `yas-selected-text' alias for templates
(defvaralias '% 'yas-selected-text)
;; Undo global maps
(bind! :i [(tab)] nil
(map! :i [(tab)] nil
:v "<backtab>" nil)
;; keybinds
(bind! :map yas-keymap
(map! :map yas-keymap
"C-e" 'narf/yas-goto-end-of-field
"C-a" 'narf/yas-goto-start-of-field
"<M-right>" 'narf/yas-goto-end-of-field

View file

@ -18,11 +18,12 @@
:init
(add-hook! csharp-mode '(emr-initialize omnisharp-mode))
:config
(evil-define-key 'normal omnisharp-mode-map
(kbd "gd") 'omnisharp-go-to-definition
(kbd ",tr") (λ (omnisharp-unit-test "fixture"))
(kbd ",ts") (λ (omnisharp-unit-test "single"))
(kbd ",ta") (λ (omnisharp-unit-test "all")))
(map! :map omnisharp-mode-map
"gd" 'omnisharp-go-to-definition
(:prefix "\\"
"tr" (λ (omnisharp-unit-test "fixture"))
"ts" (λ (omnisharp-unit-test "single"))
"ta" (λ (omnisharp-unit-test "all"))))
(after! company
(define-company-backend! csharp-mode (omnisharp))

View file

@ -26,7 +26,7 @@
;; em-prompt
(setq eshell-prompt-function 'narf/eshell-prompt)
(bind! :map eshell-mode-map
(map! :map eshell-mode-map
:n "i" 'narf/eshell-evil-prepend-maybe
:n "I" 'narf/eshell-evil-prepend
:n "a" 'narf/eshell-evil-append-maybe

View file

@ -36,14 +36,14 @@
:config
(define-company-backend! go-mode (go yasnippet)))
(bind!
(:map go-mode-map
(map! :map go-mode-map
:n "gd" 'godef-jump
:n "gD" 'godef-describe
:n ",i" 'helm-go-package
:n ",tr" 'narf:go-test-run-all
:n ",ta" 'narf:go-test-run-all
:n ",ts" 'narf:go-test-run-package)))
(:localleader
:n "p" 'helm-go-package
:n "tr" 'narf:go-test-run-all
:n "ta" 'narf:go-test-run-all
:n "ts" 'narf:go-test-run-package)))
(provide 'module-go)
;;; module-go.el ends here

View file

@ -23,7 +23,7 @@
:functions company-emacs-eclim-setup
:config (company-emacs-eclim-setup)))
(bind! :map java-mode-map :m "gd" 'eclim-java-find-declaration))
(map! :map java-mode-map :m "gd" 'eclim-java-find-declaration))
(use-package android-mode
:commands android-mode

View file

@ -16,7 +16,7 @@
(after! web-beautify
(add-hook! js2-mode (setenv "jsbeautify_indent_size" "4"))
(bind! :map js2-mode-map :m "gQ" 'web-beautify-js))
(map! :map js2-mode-map :m "gQ" 'web-beautify-js))
(use-package js2-refactor
:init (add-hook! js2-mode 'emr-initialize)

View file

@ -22,7 +22,7 @@
;; Highlight extra NARF keywords
(let ((keywords '("add-hook!"
"bind!"
"map!"
"after!"
"λ"
"in!"
@ -38,7 +38,7 @@
'emacs-lisp-mode `(("\\(lambda\\)" (0 (narf/show-as )))))
;; Real go-to-definition for elisp
(bind! :map emacs-lisp-mode-map
(map! :map emacs-lisp-mode-map
:m "gd" 'narf/elisp-find-function-at-pt
:m "gD" 'narf/elisp-find-function-at-pt-other-window)

View file

@ -14,7 +14,7 @@
(add-hook! markdown-mode
(exmap! "preview" 'narf/markdown-preview)
(exmap! "export" 'narf:org-export))
(bind! (:map markdown-mode-map
(map! (:map markdown-mode-map
"<backspace>" nil
"<M-left>" nil
"<M-right>" nil
@ -27,10 +27,11 @@
"M-i" 'markdown-insert-italic
"M-`" 'narf/markdown-insert-del
:nv ",i" 'markdown-insert-image
:nv ",l" 'markdown-insert-link
:nv ",L" 'markdown-insert-reference-link-dwim
:nv ",b" 'markdown-preview
(:localleader
:nv "i" 'markdown-insert-image
:nv "l" 'markdown-insert-link
:nv "L" 'markdown-insert-reference-link-dwim
:nv "b" 'markdown-preview)
;; TODO: Make context sensitive
:n "[p" 'markdown-promote

View file

@ -399,7 +399,7 @@ will function properly."
(define-key org-mode-map (kbd "C-j") nil)
(define-key org-mode-map (kbd "C-k") nil)
;; Keybinds
(bind! (:map org-mode-map
(map! (:map org-mode-map
:i [remap narf/inflate-space-maybe] 'org-self-insert-command
:i "RET" 'org-return-indent)
@ -443,25 +443,36 @@ will function properly."
:v "M-i" "S/"
:v "M-`" "S+"
:n ",;" 'helm-org-in-buffer-headings
:nv ",l" 'org-insert-link
:n ",L" 'org-store-link
;; TODO narf/org-replace-link-by-link-description
:n ",=" 'org-align-all-tags
:n ",f" 'org-sparse-tree
:n ",?" 'org-tags-view
:n ",e" 'org-edit-special
:n ",a" 'org-agenda
:n ",D" 'org-time-stamp-inactive
:n ",i" 'narf/org-toggle-inline-images-at-point
:n ",t" 'org-todo
:n ",T" 'org-show-todo-tree
:n ",d" 'org-time-stamp
:n ",r" 'org-refile
:n ",s" 'org-schedule
:n ",oa" 'narf/org-attachment-reveal
:n ", SPC" 'narf/org-toggle-checkbox
:n ", RET" 'org-archive-subtree
(:leader
:n ";" 'helm-org-in-buffer-headings
:n "oa" 'narf/org-attachment-reveal
)
(:localleader
:n "/" 'org-sparse-tree
:n "?" 'org-tags-view
:n "n" (λ (if (buffer-narrowed-p) (widen) (org-narrow-to-subtree)))
:n "e" 'org-edit-special
:n "=" 'org-align-all-tags
:nv "l" 'org-insert-link
:n "L" 'org-store-link
:n "x" 'narf/org-remove-link
:n "w" 'writing-mode
:n "SPC" 'narf/org-toggle-checkbox
:n "RET" 'org-archive-subtree
:n "a" 'org-agenda
:n "A" 'narf:org-attachment-list
:n "d" 'org-time-stamp
:n "D" 'org-time-stamp-inactive
:n "i" 'narf/org-toggle-inline-images-at-point
:n "t" (λ (org-todo (if (org-entry-is-todo-p) 'none 'todo)))
:n "T" 'org-todo
:n "r" 'org-refile
:n "s" 'org-schedule
)
:n "za" 'org-cycle
:n "zA" 'org-shifttab

View file

@ -22,14 +22,15 @@
:init
(associate! nose-mode :pattern "/test_.+\\.py\\'")
:config
(bind! :map nose-mode-map
:n ",tr" 'nosetests-again
:n ",ta" 'nosetests-all
:n ",ts" 'nosetests-one
:n ",tv" 'nosetests-module
:n ",tA" 'nosetests-pdb-all
:n ",tO" 'nosetests-pdb-one
:n ",tV" 'nosetests-pdb-module))
(map! :map nose-mode-map
(:localleader
:n "tr" 'nosetests-again
:n "ta" 'nosetests-all
:n "ts" 'nosetests-one
:n "tv" 'nosetests-module
:n "tA" 'nosetests-pdb-all
:n "tO" 'nosetests-pdb-one
:n "tV" 'nosetests-pdb-module)))
(use-package anaconda-mode
:diminish anaconda-mode
@ -39,8 +40,8 @@
(add-hook! python-mode '(anaconda-mode eldoc-mode))
(setq anaconda-mode-installation-directory (concat narf-temp-dir "anaconda/"))
:config
(bind! :map anaconda-mode-map :m "gd" 'anaconda-mode-goto-definitions)
(bind! :map anaconda-nav-mode-map :n [escape] 'anaconda-nav-quit)
(map! :map anaconda-mode-map :m "gd" 'anaconda-mode-goto-definitions)
(map! :map anaconda-nav-mode-map :n [escape] 'anaconda-nav-quit)
(advice-add 'anaconda-mode-doc-buffer :after 'narf*anaconda-mode-doc-buffer)

View file

@ -5,11 +5,11 @@
:config
(require 'pcre2el)
(setq reb-re-syntax 'pcre)
(bind! :map rxt-help-mode-map :n [escape] 'kill-buffer-and-window)
(map! :map rxt-help-mode-map :n [escape] 'kill-buffer-and-window)
(add-hook! reb-mode 'narf|reb-cleanup)
(evil-set-initial-state 'reb-mode 'insert)
(bind! :map reb-mode-map
(map! :map reb-mode-map
:n "C-g" 'reb-quit
:n [escape] 'reb-quit
:n [backtab] 'reb-change-syntax))

View file

@ -49,11 +49,12 @@
;; Rake
(("task" "namespace") () "end")))
:config
(bind! (:map rspec-mode-map
:n ",tr" 'rspec-rerun
:n ",ta" 'rspec-verify-all
:n ",ts" 'rspec-verify-single
:n ",tv" 'rspec-verify)))
(map! :map rspec-mode-map
(:localleader
:n "tr" 'rspec-rerun
:n "ta" 'rspec-verify-all
:n "ts" 'rspec-verify-single
:n "tv" 'rspec-verify)))
(use-package inf-ruby
:commands (inf-ruby inf-ruby-console-auto)

View file

@ -14,7 +14,9 @@
:config
(setq racer-cmd "/usr/local/bin/racer"
racer-rust-src-path "~/Dropbox/lib/rust/src/")
(bind! :map rust-mode-map :m "gd" 'racer-find-definition)
(map! :map rust-mode-map :m "gd" 'racer-find-definition)
;; TODO Unit test keybinds
(add-hook! rust-mode '(racer-mode eldoc-mode flycheck-rust-setup))
(define-company-backend! rust-mode (racer))))

View file

@ -14,14 +14,15 @@
(setq-default css-indent-offset 2)
(setq scss-compile-at-save nil)
:config
(bind! :map scss-mode-map
(map! :map scss-mode-map
:n "M-r" 'narf/web-refresh-browser
:n ",;" 'helm-css-scss
:n ",:" 'helm-css-scss-multi)
(:leader
:n ";" 'helm-css-scss
:n ":" 'helm-css-scss-multi))
(after! web-beautify
(add-hook! scss-mode (setenv "jsbeautify_indent_size" "2"))
(bind! :map scss-mode-map :m "gQ" 'web-beautify-css))
(map! :map scss-mode-map :m "gQ" 'web-beautify-css))
(after! emr
(emr-declare-command 'narf/scss-toggle-inline-or-block
@ -36,7 +37,7 @@
:init
(after! css-mode
(add-hook! css-mode (setenv "jsbeautify_indent_size" "2"))
(bind! :map css-mode-map :m "gQ" 'web-beautify-css)))
(map! :map css-mode-map :m "gQ" 'web-beautify-css)))
(use-package jade-mode
:mode "\\.jade$"
@ -56,17 +57,17 @@
:config
(after! web-beautify
(add-hook! web-mode (setenv "jsbeautify_indent_size" "4"))
(bind! :map web-mode-map :m "gQ" 'web-beautify-html))
(map! :map web-mode-map :m "gQ" 'web-beautify-html))
(after! nlinum
;; Fix blank line numbers after unfolding
(advice-add 'web-mode-fold-or-unfold :after 'nlinum--flush))
(bind! :map web-mode-map
(map! :map web-mode-map
"M-/" 'web-mode-comment-or-uncomment
:n "za" 'web-mode-fold-or-unfold
:n ",t" 'web-mode-element-rename
(:localleader :n "t" 'web-mode-element-rename)
:n "M-r" 'narf/web-refresh-browser
@ -85,7 +86,7 @@
(defvar emmet-mode-keymap (make-sparse-keymap))
:config
(setq emmet-move-cursor-between-quotes t)
(bind! :map emmet-mode-keymap
(map! :map emmet-mode-keymap
:v "M-e" 'emmet-wrap-with-markup
:i "M-e" 'emmet-expand-yas
:i "M-E" 'emmet-expand-line))

View file

@ -6,8 +6,9 @@
(eval-when-compile (require 'core-defuns))
(bind!
-
;; See `narf-leader-prefix' & `narf-localleader-prefix' in ../core/core-vars.el
(map!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Global keymaps ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -15,37 +16,25 @@
"M-x" 'helm-M-x
"M-;" 'eval-expression
"M-/" 'evil-commentary-line
"A-x" 'helm-M-x
"A-;" 'eval-expression
"A-/" 'evil-commentary-line
(:when window-system
"M-0" (λ (text-scale-set 0))
"M-=" 'text-scale-increase
"M--" 'text-scale-decrease)
"M--" 'text-scale-decrease
"M-b" 'narf:build
"M-t" 'helm-projectile-find-file
"<f9>" 'what-face
"A-`" 'narf-switch-to-iterm
"C-`" 'narf/popup-toggle
"C-~" 'rtog/toggle-repl
"<f9>" 'what-face
"M-w" 'evil-window-delete
"M-W" 'delete-frame
"M-n" (λ (switch-to-buffer (generate-new-buffer "*new*")))
"M-N" (λ (let ((nlinum-p (and (featurep 'nlinum)
(memq 'nlinum--setup-window window-configuration-change-hook))))
;; Disable nlinum to fix elusive "invalid face linum" bug
(remove-hook 'window-configuration-change-hook 'nlinum--setup-window t)
(let ((frame (new-frame))
(frame-name (format "*new-%s*" (length narf-wg-frames))))
(with-selected-frame frame
(wg-create-workgroup frame-name t)
(add-to-list 'narf-wg-frames (cons frame frame-name))))
(when nlinum-p
(add-hook 'window-configuration-change-hook 'nlinum--setup-window nil t))))
"M-n" 'narf/new-buffer
"M-N" 'narf/new-frame
;; Simpler window navigation
"C-j" 'evil-window-down
@ -72,21 +61,6 @@
:m "M-9" (λ (narf:switch-to-workgroup-at-index 8))
(:when IS-MAC
:ni "M-d" 'dash-at-point
;; Add animated transitions to OSX emacs
"M-w" 'evil-window-delete
"M-W" (λ (let ((data (assq (selected-frame) narf-wg-frames)))
(if data
(progn (wg-delete-workgroup (wg-get-workgroup (cdr data)))
(delete-frame (car data)))
(delete-frame))))
"M-n" (λ (switch-to-buffer (generate-new-buffer "*new*")))
;; Textmate-esque indent shift left/right
:i "M-[" (kbd "C-o m l C-o I DEL C-o ` l")
:i "M-]" (λ (evil-shift-right (point-at-bol) (point-at-eol)))
"<A-left>" 'backward-word
"<A-right>" 'forward-word
"<M-backspace>" 'narf/backward-kill-to-bol-and-indent
@ -98,7 +72,17 @@
"M-q" 'evil-quit-all
"M-z" 'undo
"M-Z" 'redo
"C-M-f" 'narf:toggle-fullscreen)
"C-M-f" 'narf:toggle-fullscreen
:ni "M-d" 'dash-at-point
;; Textmate-esque indent shift left/right
:i "M-[" (kbd "C-o m l C-o I DEL C-o ` l")
:i "M-]" (λ (evil-shift-right (point-at-bol) (point-at-eol)))
;; Restore osx text objects
:i "<A-backspace>" 'evil-delete-backward-word
:i "<A-delete>" (λ (evil-forward-word) (evil-delete-backward-word)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -106,9 +90,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:m ";" 'evil-ex
;; <leader>
(:prefix ","
(:leader
:nv "," (λ (if (narf/project-p) (helm-projectile-switch-to-buffer) (helm-buffers-list)))
:nv "<" 'helm-buffers-list
:nv "." 'helm-find-files
@ -116,19 +98,35 @@
: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 "E" (λ (in! narf-emacs-dir (helm-projectile-find-file)))
:nv "m" 'helm-recentf
:nv "M" 'helm-projectile-recentf ; recent PROJECT files
:nv "p" 'helm-projectile-switch-project
:nv "P" 'helm-projectile-switch-project
:v "=" 'align-regexp
:nv "r" 'emr-show-refactor-menu
:n "R" 'narf/reset-theme
:n "s" (λ (narf:yas-snippets t)) ; ido snippets dir
:n "h" 'diff-hl-diff-goto-hunk
:n "e" 'narf/flycheck-errors
:nv "p" 'helm-show-kill-ring
:n "b" 'helm-bookmarks
:n "w" 'narf:workgroup-display
:n "W" 'narf:helm-wg
:nv "n" 'narf/neotree-toggle
:nv "N" 'narf/neotree-find
:nv "t" 'narf-switch-to-iterm
:nv "l" 'narf/nlinum-toggle
:nv "\\" 'evil-emacs-state
:nv "qq" 'evil-save-and-quit
:nv "QQ" 'narf/kill-all-buffers-do-not-remember
;; Open with O/S
:n "oo" 'narf-open-with
:n "ob" (λ (narf-open-with "Google Chrome"))
:n "of" (λ (narf-open-with "Finder.app" default-directory))
@ -140,33 +138,17 @@
:n "ot" (λ (narf:tmux-chdir nil t))
:n "oT" 'narf:tmux-chdir
;; Org
:nv "n." (λ (in! org-directory (let ((helm-ff-skip-boring-files t)) (helm-find-files-1 org-directory))))
:nv "n/" 'narf/helm-org
:nv "np" 'narf/helm-org-projects
:nv "nc" 'narf/helm-org-contacts
:nv "ni" 'narf/helm-org-invoices
:nv "nw" 'narf/helm-org-writing)
;; Org notes
:nv "x." (λ (in! org-directory (let ((helm-ff-skip-boring-files t)) (helm-find-files-1 org-directory))))
:nv "x/" 'narf/helm-org
:nv "xp" 'narf/helm-org-projects
:nv "xc" 'narf/helm-org-contacts
:nv "xi" 'narf/helm-org-invoices
:nv "xw" 'narf/helm-org-writing)
;; <localleader>
(:prefix "\\"
:nv "\\" 'narf/neotree-toggle
:nv "|" 'narf-switch-to-iterm
:nv "." 'narf/neotree-find
:nv ";" 'narf/nlinum-toggle
:nv "E" 'evil-emacs-state
:n "]" 'next-buffer
:n "[" 'previous-buffer
:n "c" 'narf/reset-theme
:n "s" (λ (narf:yas-snippets t)) ; ido snippets dir
:n "g" 'diff-hl-diff-goto-hunk
:n "e" (λ (call-interactively 'flycheck-buffer) (flycheck-list-errors))
:n "p" 'helm-show-kill-ring
:n "b" 'helm-bookmarks
:n "w" 'narf:helm-wg
:n "W" 'narf:workgroup-display)
(:localleader
:n "\\" 'narf/neotree-toggle
:n "." 'narf/neotree-find)
:nv "K" 'smart-up
@ -195,10 +177,10 @@
:n "g=" 'evil-numbers/inc-at-pt
:n "g-" 'evil-numbers/dec-at-pt
:n "gR" 'narf:eval-buffer
: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 "gl" 'avy-goto-line
:m "g]" 'smart-right
@ -242,15 +224,10 @@
(hs-toggle-hiding)
(call-interactively 'evilmi-jump-items)))))
;; Restore osx text objects
:i "<A-backspace>" 'evil-delete-backward-word
:i "<A-delete>" (λ (evil-forward-word) (evil-delete-backward-word))
;; Newline magic
;; Textmate-esque newlines
:i "<backspace>" 'backward-delete-char-untabify
:i "<M-backspace>" 'narf/backward-kill-to-bol-and-indent
:i "<C-return>" 'evil-ret-and-indent
:i "<C-SPC>" (λ (insert ", "))
;; escape from insert mode (more responsive than using key-chord-define)
:ir "j" 'narf:exit-mode-maybe
@ -262,7 +239,7 @@
:n "!" 'rotate-word-at-point
:v "!" 'rotate-region
:e [escape] 'evil-normal-state
:e "<escape>" 'evil-normal-state
(:map evil-window-map ; prefix "C-w"
"u" 'narf/undo-window-change
@ -290,6 +267,7 @@
;; Vim omni-complete emulation
:i "C-SPC" 'company-complete-common
:i "C-x C-l" 'narf/company-whole-lines
:i "C-x C-k" 'company-dict
:i "C-x C-f" 'company-files
:i "C-x C-]" 'company-tags
@ -313,12 +291,12 @@
"C-SPC" 'company-complete-common-or-cycle
[tab] 'narf/company-complete-common-or-complete-full
"<backtab>" 'company-select-previous
[escape] 'company-abort
[escape] (λ (company-abort) (evil-normal-state 1))
"<C-return>" 'helm-company)
(:map company-search-map
"C-n" 'company-search-repeat-forward
"C-p" 'company-search-repeat-backward
[escape] 'company-abort))
[escape] 'company-search-abort))
(:after help-mode
(:map help-mode-map
@ -354,7 +332,7 @@
;; Restores "dumb" indentation to the tab key. This rustles a lot of
;; peoples' jimmies, apparently, but it's how I like it.
(bind! :i "<tab>" 'narf/dumb-indent
(map! :i "<tab>" 'narf/dumb-indent
:i "<C-tab>" 'indent-for-tab-command
;; No dumb-tab for lisp
@ -410,7 +388,7 @@
:map read-expression-map "C-w" 'backward-kill-word)
(bind! :i "A-o" (λ (insert "ø"))
(map! :i "A-o" (λ (insert "ø"))
:i "A-O" (λ (insert "Ø"))
:i "A--" (λ (insert ""))