diff --git a/core/core-company.el b/core/core-company.el index 8b3477e24..29a4687cb 100644 --- a/core/core-company.el +++ b/core/core-company.el @@ -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) diff --git a/core/core-defuns.el b/core/core-defuns.el index 9ff55ad0a..f8cabfda8 100644 --- a/core/core-defuns.el +++ b/core/core-defuns.el @@ -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) diff --git a/core/core-flycheck.el b/core/core-flycheck.el index f5e32576a..c5d8eda07 100644 --- a/core/core-flycheck.el +++ b/core/core-flycheck.el @@ -9,10 +9,12 @@ flycheck-disabled-checkers '(emacs-lisp emacs-lisp-checkdoc make)) :config - ;; fixes Unknown defun property `interactive-only' error by compiling flycheck - (let ((path (locate-library "flycheck"))) - (unless (f-ext? path "elc") - (byte-compile-file path))) + (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)))) (map! :map flycheck-error-list-mode-map :n "C-n" 'flycheck-error-list-next-error diff --git a/core/core-project.el b/core/core-project.el index 2de952ca4..ffd1618ee 100644 --- a/core/core-project.el +++ b/core/core-project.el @@ -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) diff --git a/core/core-ui.el b/core/core-ui.el index 0a182f334..3dc571da0 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -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 diff --git a/core/core.el b/core/core.el index c4ae2e7dd..0317b1663 100644 --- a/core/core.el +++ b/core/core.el @@ -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) diff --git a/init.el b/init.el index 2e4ff6efe..0d38e1a2b 100644 --- a/init.el +++ b/init.el @@ -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 diff --git a/modules/module-data.el b/modules/module-data.el index 39b04a907..e1b83c846 100644 --- a/modules/module-data.el +++ b/modules/module-data.el @@ -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 ?: ?{ ?}))) diff --git a/modules/module-lisp.el b/modules/module-lisp.el index 3fb71787e..9df859f9c 100644 --- a/modules/module-lisp.el +++ b/modules/module-lisp.el @@ -30,38 +30,38 @@ ;; Real go-to-definition for elisp (map! :map emacs-lisp-mode-map :m "gd" 'narf/elisp-find-function-at-pt) - (font-lock-add-keywords - 'emacs-lisp-mode `(("(\\(lambda\\)" - (1 (narf/show-as ?λ))) - ;; Highlight narf macros (macros are fontified in emacs 25+) - (,(concat - "(\\(def-" - (regexp-opt '("electric" "project-type" "company-backend" - "builder" "repl" "textobj" "tmp-excmd" "rotate" - "repeat" "yas-mode" "env-command" "docset")) - "!\\)") - (1 font-lock-keyword-face append)) - (,(concat - "(\\(" - (regexp-opt '("λ" "in" "map" "after" "shut-up" "add-hook" - "associate" "open-with" "define-org-link" - "define-org-section")) - "!\\)") - (1 font-lock-keyword-face append)) - ;; Ert - (,(concat - "(" - (regexp-opt '("ert-deftest") t) - " \\([^ ]+\\)") - (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] + (font-lock-add-keywords + nil `(("(\\(lambda\\)" + (1 (narf/show-as ?λ))) + ;; Highlight narf macros (macros are fontified in emacs 25+) + (,(concat + "(\\(def-" + (regexp-opt '("electric" "project-type" "company-backend" + "builder" "repl" "textobj" "tmp-excmd" "rotate" + "repeat" "yas-mode" "env-command" "docset")) + "!\\)") + (1 font-lock-keyword-face append)) + (,(concat + "(\\(" + (regexp-opt '("λ" "in" "map" "after" "shut-up" "add-hook" + "associate" "open-with" "define-org-link" + "define-org-section")) + "!\\)") + (1 font-lock-keyword-face append)) + ;; Ert + (,(concat + "(" + (regexp-opt '("ert-deftest") t) + " \\([^ ]+\\)") + (1 font-lock-keyword-face) + (2 font-lock-function-name-face)))) + (add-hook 'before-save-hook 'delete-trailing-whitespace nil t) (add-hook 'after-save-hook 'narf/elisp-auto-compile nil t) diff --git a/modules/module-python.el b/modules/module-python.el index ac1c232bd..9b3025bf2 100644 --- a/modules/module-python.el +++ b/modules/module-python.el @@ -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 diff --git a/modules/module-ruby.el b/modules/module-ruby.el index 05ffe2edf..85b0ae98e 100644 --- a/modules/module-ruby.el +++ b/modules/module-ruby.el @@ -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) diff --git a/modules/module-rust.el b/modules/module-rust.el index 99f35f911..920fe1556 100644 --- a/modules/module-rust.el +++ b/modules/module-rust.el @@ -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)) diff --git a/modules/module-web.el b/modules/module-web.el index 5ccccd080..3802d3c59 100644 --- a/modules/module-web.el +++ b/modules/module-web.el @@ -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 diff --git a/private/my-bindings.el b/private/my-bindings.el index 426107503..98c541bf3 100644 --- a/private/my-bindings.el +++ b/private/my-bindings.el @@ -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))