General cleanup + refactor

This commit is contained in:
Henrik Lissner 2016-05-11 05:36:49 -04:00
parent c427842a04
commit 91a87e7ee1
14 changed files with 74 additions and 76 deletions

View file

@ -27,10 +27,7 @@
(global-company-mode +1))
(use-package company-dabbrev :commands company-dabbrev)
(use-package company-dabbrev-code :commands company-dabbrev-code)
;; NOTE: Doesn't look pretty outside of emacs-mac
(use-package company-quickhelp
:after company
:config (company-quickhelp-mode +1))
@ -39,6 +36,10 @@
:after company
:config (company-statistics-mode +1))
(use-package company-dabbrev :commands company-dabbrev)
(use-package company-dabbrev-code :commands company-dabbrev-code)
(use-package company-files
:commands company-files)

View file

@ -39,29 +39,15 @@ during compilation."
HOOK can be one hook or a list of hooks. If the hook(s) are not quoted, -hook is
appended to them automatically. If they are quoted, they are used verbatim.
FUNC-OR-FORMS can be one quoted symbol, a list of quoted symbols, or a series of
forms. Forms will be wrapped in one lambda. A list of symbols will expand into a
series of add-hook calls.
FUNC-OR-FORMS can be a quoted symbol, a list of quoted symbols, or forms. Forms will be
wrapped in a lambda. A list of symbols will expand into a series of add-hook calls.
Examples:
(add-hook! 'some-mode-hook 'enable-something)
=> (add-hook 'some-mode-hook 'enable-something)
(add-hook! some-mode '(enable-something and-another))
=> (add-hook 'some-mode-hook 'enable-something)
(add-hook 'some-mode-hook 'and-another)
(add-hook! '(one-mode-hook second-mode-hook) 'enable-something)
=> (add-hook 'one-mode-hook 'enable-something)
(add-hook 'second-mode-hook 'enable-something)
(add-hook! (one-mode second-mode) 'enable-something)
=> (add-hook 'one-mode-hook 'enable-something)
(add-hook 'second-mode-hook 'enable-something)
(add-hook! (one-mode second-mode) (setq v 5) (setq a 2))
=> (add-hook 'one-mode-hook (lambda () (setq v 5) (setq a 2)))
(add-hook 'second-mode-hook (lambda () (setq v 5) (setq a 2)))"
(add-hook! (one-mode second-mode) (setq v 5) (setq a 2))"
(declare (indent defun) (debug t))
(unless func-or-forms
(error "add-hook!: FUNC-OR-FORMS is empty"))
@ -259,7 +245,10 @@ Examples:
(concat "" (abbreviate-file-name default-directory)))))))
;;;; Global Defuns ;;;;;;;;;;;;;;;;;;;;;
;;
;; Global Defuns
;;
(defun narf-reload ()
"Reload `load-path', in case you updated cask while emacs was open!"
(interactive)

View file

@ -9,10 +9,12 @@
flycheck-disabled-checkers '(emacs-lisp emacs-lisp-checkdoc make))
:config
;; fixes Unknown defun property `interactive-only' error by compiling flycheck
(unless (> emacs-major-version 24)
;; Fixes Unknown defun property `interactive-only' error (in emacs <25) by compiling
;; flycheck source files
(let ((path (locate-library "flycheck")))
(unless (f-ext? path "elc")
(byte-compile-file path)))
(byte-compile-file path))))
(map! :map flycheck-error-list-mode-map
:n "C-n" 'flycheck-error-list-next-error

View file

@ -111,20 +111,20 @@
"r" 'neotree-rename-node
"R" 'neotree-change-root))
;; Shorter pwd in neotree
(defun narf*neotree-shorten-pwd (node)
"Shorter pwd in neotree"
(list (abbreviate-file-name (car node))))
(advice-add 'neo-buffer--insert-root-entry :filter-args 'narf*neotree-shorten-pwd)
;; Don't ask for confirmation when creating files
(defun narf*neotree-create-node (orig-fun &rest args)
"Don't ask for confirmation when creating files"
(cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) t)))
(apply orig-fun args)))
(advice-add 'neotree-create-node :around 'narf*neotree-create-node)
(defun narf*save-neotree (orig-fun &rest args)
"Prevents messing up the neotree buffer on window changes"
(narf/neotree-save (apply orig-fun args)))
;; Prevents messing up the neotree buffer on window changes
(advice-add 'narf--evil-window-move :around 'narf*save-neotree)
(advice-add 'narf--evil-swap-windows :around 'narf*save-neotree)

View file

@ -62,8 +62,8 @@
(fringe-mode narf-fringe-size)
;; Show tilde in margin on empty lines
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
(set-fringe-bitmap-face 'tilde 'font-lock-comment-face)
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
;; Brighter minibuffer when active + no fringe in minibuffer
(defface narf-minibuffer-active '((t (:inherit mode-line)))
"Face for active minibuffer")
@ -155,16 +155,13 @@
(add-hook! (emacs-lisp-mode lisp-mode js2-mode scss-mode c-mode-common)
'rainbow-delimiters-mode)
:config
(setq rainbow-delimiters-max-face-count 4))
(setq rainbow-delimiters-max-face-count 3))
(use-package rainbow-mode
:commands (rainbow-mode)
:init
(add-hook! (sass-mode scss-mode less-css-mode) 'rainbow-mode)
;; hl-line-mode and rainbow-mode don't play well together
(add-hook! rainbow-mode
(when narf--hl-line-mode
(hl-line-mode (if rainbow-mode -1 1)))))
;; NOTE: hl-line-mode and rainbow-mode don't play well together
(add-hook! (sass-mode scss-mode less-css-mode) '(rainbow-mode narf|hl-line-off)))
(use-package nlinum
:commands nlinum-mode
@ -405,6 +402,7 @@ anzu to be enabled."
:tight t)
(spaceline-compile
'main
;; Left side
'(((*macro-recording *anzu *iedit *evil-substitute *flycheck)
:skip-alternate t

View file

@ -103,7 +103,7 @@ buffer to display.")
"*Buffer List*" "*Ibuffer*" "*esh command on file*"
"*WoMan-Log*" "*compilation*" "*use-package*"
"*quickrun*" "*eclim: problems*" "*Flycheck errors*"
"*popwin-dummy*" " *NeoTree*"
"*popwin-dummy*" "*NeoTree*" " *NeoTree*"
;; Helm
"*helm*" "*helm recentf*" "*helm projectile*" "*helm imenu*"
"*helm company*" "*helm buffers*" "*Helm Css SCSS*"
@ -139,6 +139,7 @@ gets killed.")
;; Bootstrap
;;
(require 'f)
(autoload 'awhen "anaphora" "" nil 'macro)
(autoload 'aif "anaphora" "" nil 'macro)
(autoload 'use-package "use-package" "" nil 'macro)

View file

@ -101,7 +101,7 @@
;; Extra libraries
extra-demo ; allow me to demonstrate...
extra-tags ; if you liked it you should've generated a tag for it
extra-tmux ; closing the rift between GUI & terminal
extra-tmux ; close the rift between GUI & terminal
extra-write ; for writing fiction in Emacs
;; Customization

View file

@ -7,7 +7,7 @@
(use-package toml-mode :mode "\\.toml$")
(use-package yaml-mode :mode "\\.ya?ml$"
:config (def-electric! yaml-mode :chars (?\n ?: ?-)))
:config (def-electric! yaml-mode :chars (?\n ?\: ?\-)))
(use-package json-mode :mode "\\.js\\(on\\|hintrc\\)$"
:config (def-electric! json-mode :chars (?\n ?: ?{ ?})))

View file

@ -30,8 +30,14 @@
;; Real go-to-definition for elisp
(map! :map emacs-lisp-mode-map :m "gd" 'narf/elisp-find-function-at-pt)
(remove-hook 'emacs-lisp-mode-hook 'narf/elisp-init))
(add-hook 'emacs-lisp-mode-hook 'narf/elisp-hook)
(defun narf/elisp-hook ()
(setq mode-name "Elisp") ; [pedantry intensifies]
(font-lock-add-keywords
'emacs-lisp-mode `(("(\\(lambda\\)"
nil `(("(\\(lambda\\)"
(1 (narf/show-as )))
;; Highlight narf macros (macros are fontified in emacs 25+)
(,(concat
@ -56,12 +62,6 @@
(1 font-lock-keyword-face)
(2 font-lock-function-name-face))))
(remove-hook 'emacs-lisp-mode-hook 'narf/elisp-init))
(add-hook 'emacs-lisp-mode-hook 'narf/elisp-hook)
(defun narf/elisp-hook ()
(setq mode-name "Elisp") ; [pedantry intensifies]
(add-hook 'before-save-hook 'delete-trailing-whitespace nil t)
(add-hook 'after-save-hook 'narf/elisp-auto-compile nil t)

View file

@ -67,8 +67,7 @@
(use-package nose
:commands nose-mode
:preface (defvar nose-mode-map (make-sparse-keymap))
:init
(associate! nose-mode :match "/test_.+\\.py$" :in (python-mode))
:init (associate! nose-mode :match "/test_.+\\.py$" :in (python-mode))
:config
(def-yas-mode! 'nose-mode)
(map! :map nose-mode-map

View file

@ -4,7 +4,7 @@
:mode ("\\.rb$" "\\.rake$" "\\.gemspec$" "\\.?pryrc$"
"/\\(Gem\\|Cap\\|Vagrant\\|Rake\\)file$")
:interpreter "ruby"
:init (add-hook! ruby-mode '(flycheck-mode yard-mode))
:init (add-hook 'ruby-mode-hook 'flycheck-mode)
:config
(def-builder! ruby-mode "rake %s" "Rakefile")
(def-company-backend! ruby-mode (dabbrev-code))
@ -42,7 +42,9 @@
(refactor-convert-post-conditional "convert post conditional" t))))
;; Highlight doc comments
(use-package yard-mode :commands yard-mode)
(use-package yard-mode
:commands yard-mode
:init (add-hook 'ruby-mode-hook 'yard-mode))
(use-package rspec-mode
:mode ("/\\.rspec$" . text-mode)

View file

@ -14,9 +14,8 @@
:preface
(setq racer-cmd (concat narf-ext-dir "/racer")
racer-rust-src-path (concat narf-ext-dir "/rust/src/"))
:when (file-exists-p racer-cmd)
:init
(add-hook! rust-mode '(racer-mode eldoc-mode flycheck-rust-setup))
:when (f-exists? racer-cmd)
:init (add-hook! rust-mode '(racer-mode eldoc-mode flycheck-rust-setup))
:config
;; TODO Unit test keybinds
(def-company-backend! rust-mode (racer))

View file

@ -55,6 +55,7 @@
:mode ("\\.p?html?$"
"\\.\\(tpl\\|blade\\)\\(\\.php\\)?$"
"\\.erb$"
"\\.jsp$"
"\\.as[cp]x$"
"\\.mustache$"
"wp-content/themes/.+/.+\\.php$")
@ -85,7 +86,11 @@
:nv "]T" 'web-mode-element-child
:nv "[T" 'web-mode-element-parent))
;;
;; Tools
;;
(use-package emmet-mode
:commands (emmet-mode)
:init
@ -98,7 +103,11 @@
:i "M-e" 'emmet-expand-yas
:i "M-E" 'emmet-expand-line))
;;
;; Project types
;;
(def-project-type! jekyll ":{"
:modes (web-mode scss-mode html-mode markdown-mode yaml-mode)
:match "/\\(\\(css\\|_\\(layouts\\|posts\\|sass\\)\\)/.+\\|.+.html\\)$"
@ -112,7 +121,5 @@
:match "/wp-\\(\\(content\\|admin\\|includes\\)/\\)?.+$"
:files ("wp-config.php" "wp-content/"))
;; TODO Add stylus-mode
(provide 'module-web)
;;; module-web.el ends here

View file

@ -14,10 +14,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
"M-x" 'helm-M-x
"M-;" 'eval-expression
"M-/" 'evil-commentary-line
"A-x" 'helm-M-x
"M-;" 'eval-expression
"A-;" 'eval-expression
"M-/" 'evil-commentary-line
"A-/" 'evil-commentary-line
"M-0" (λ! (text-scale-set 0))