Reduce def-package magic; explicitly use :when property

This commit is contained in:
Henrik Lissner 2017-03-19 22:47:50 -04:00
parent e4b5cf5a56
commit 3e63d2d23b
19 changed files with 55 additions and 37 deletions

View file

@ -283,14 +283,8 @@ byte-compilation."
;; Benchmark ;; Benchmark
(add-hook 'after-init-hook 'doom--display-benchmark t)))) (add-hook 'after-init-hook 'doom--display-benchmark t))))
(defmacro def-package! (name &rest plist) (defalias 'def-package! 'use-package
"Defines and configures a package using `use-package'. Packages are deferred "An alias for `use-package'. Note that packages are deferred by default.")
by default. If the package isn't installed or loaded, `def-package!' is
ignored."
(when (or (featurep name)
(progn (doom-initialize)
(package-installed-p name)))
`(use-package ,name ,@plist)))
(defmacro load! (filesym &optional path noerror) (defmacro load! (filesym &optional path noerror)
"Loads a file relative to the current module (or PATH). FILESYM is a file path "Loads a file relative to the current module (or PATH). FILESYM is a file path

View file

@ -15,17 +15,14 @@
(def-package! flyspell-correct (def-package! flyspell-correct
:commands (flyspell-correct-word-generic :commands (flyspell-correct-word-generic
flyspell-correct-previous-word-generic)) flyspell-correct-previous-word-generic)
(def-package! flyspell-correct-popup
:after flyspell-correct
:config :config
(cond ((featurep! :completion helm)
(require 'flyspell-correct-helm))
((featurep! :completion ivy)
(require 'flyspell-correct-ivy))
(t
(require 'flyspell-correct-popup)
(setq flyspell-popup-correct-delay 0.8) (setq flyspell-popup-correct-delay 0.8)
(define-key popup-menu-keymap [escape] 'keyboard-quit)) (define-key popup-menu-keymap [escape] 'keyboard-quit))))
(def-package! flyspell-correct-helm :after flyspell-correct)
(def-package! flyspell-correct-ivy :after flyspell-correct)

View file

@ -39,6 +39,7 @@
(def-package! evil-magit (def-package! evil-magit
:when (featurep! :feature evil)
:after magit :after magit
:config :config
;; evil-snipe conflicts with magit ;; evil-snipe conflicts with magit

View file

@ -116,7 +116,10 @@
(def-package! irony-eldoc :after irony) (def-package! irony-eldoc :after irony)
(def-package! flycheck-irony :after irony :config (flycheck-irony-setup)) (def-package! flycheck-irony
:when (featurep! :feature syntax-checker)
:after irony
:config (flycheck-irony-setup))
;; ;;
@ -130,11 +133,12 @@
;; Plugins ;; Plugins
;; ;;
(def-package! company-cmake :after cmake-mode) (when (featurep! :completion company)
(def-package! company-cmake :after cmake-mode)
(def-package! company-irony :after irony) (def-package! company-irony :after irony)
(def-package! company-irony-c-headers :after company-irony) (def-package! company-irony-c-headers :after company-irony))
;; ;;

View file

@ -29,6 +29,7 @@
(def-package! company-go (def-package! company-go
:when (featurep! :completion company)
:after go-mode :after go-mode
:config (set! :company-backend 'go-mode '(company-go company-yasnippet))) :config (set! :company-backend 'go-mode '(company-go company-yasnippet)))

View file

@ -79,6 +79,7 @@
(def-package! company-tern (def-package! company-tern
:when (featurep! :completion company)
:after tern :after tern
:config :config
(set! :company-backend 'js2-mode '(company-tern))) (set! :company-backend 'js2-mode '(company-tern)))

View file

@ -38,6 +38,7 @@
(map! :map LaTeX-mode-map "C-j" nil) (map! :map LaTeX-mode-map "C-j" nil)
(def-package! company-auctex (def-package! company-auctex
:when (featurep! :completion company)
:init :init
(set! :company-backend 'LaTeX-mode '(company-auctex)))) (set! :company-backend 'LaTeX-mode '(company-auctex))))
@ -74,8 +75,10 @@
(map! :map bibtex-mode-map "C-c \\" 'bibtex-fill-entry)) (map! :map bibtex-mode-map "C-c \\" 'bibtex-fill-entry))
(def-package! ivy-bibtex (def-package! ivy-bibtex
:when (featurep! :completion ivy)
:commands ivy-bibtex) :commands ivy-bibtex)
(def-package! helm-bibtex (def-package! helm-bibtex
:when (featurep! :completion helm)
:commands helm-bibtex) :commands helm-bibtex)

View file

@ -6,7 +6,6 @@
:init :init
(add-hook 'lua-mode-hook 'flycheck-mode) (add-hook 'lua-mode-hook 'flycheck-mode)
:config :config
(set! :company-backend 'lua-mode '(company-lua company-yasnippet))
(set! :electric 'lua-mode :words '("else" "end")) (set! :electric 'lua-mode :words '("else" "end"))
(set! :repl 'lua-mode '+lua/repl) (set! :repl 'lua-mode '+lua/repl)
@ -15,7 +14,10 @@
(def-package! company-lua (def-package! company-lua
:after lua-mode) :when (featurep! :completion company)
:after lua-mode
:config
(set! :company-backend 'lua-mode '(company-lua company-yasnippet)))
(def-package! moonscript (def-package! moonscript

View file

@ -15,7 +15,7 @@
(setq php-template-compatibility nil) (setq php-template-compatibility nil)
(set! :repl 'php-mode 'php-boris) (set! :repl 'php-mode 'php-boris)
(set! :company-bakend 'php-mode '(php-extras-company company-yasnippet))
(add-hook! php-mode (setq-local sp-max-pair-length 6)) (add-hook! php-mode (setq-local sp-max-pair-length 6))
@ -51,6 +51,8 @@
:config :config
(setq php-extras-eldoc-functions-file (concat doom-etc-dir "php-extras-eldoc-functions")) (setq php-extras-eldoc-functions-file (concat doom-etc-dir "php-extras-eldoc-functions"))
(set! :company-bakend 'php-mode '(php-extras-company company-yasnippet))
;; company will set up itself ;; company will set up itself
(advice-add 'php-extras-company-setup :override 'ignore) (advice-add 'php-extras-company-setup :override 'ignore)

View file

@ -35,15 +35,17 @@
:config :config
(set! :popup "*anaconda-mode*" :size 10 :noselect t :autoclose t :autokill t) (set! :popup "*anaconda-mode*" :size 10 :noselect t :autoclose t :autokill t)
(set! :company-backend 'python-mode '(company-anaconda))
(map! :map anaconda-mode-map :m "gd" 'anaconda-mode-find-definitions) (map! :map anaconda-mode-map :m "gd" 'anaconda-mode-find-definitions)
(advice-add 'anaconda-mode-doc-buffer :after 'doom*anaconda-mode-doc-buffer)) (advice-add 'anaconda-mode-doc-buffer :after 'doom*anaconda-mode-doc-buffer))
(def-package! company-anaconda (def-package! company-anaconda
:when (featurep! :completion company)
:after anaconda-mode :after anaconda-mode
:config :config
(set! :company-backend 'python-mode '(company-anaconda))
(map! :map python-mode-map (map! :map python-mode-map
:m "gd" 'anaconda-mode-find-definitions :m "gd" 'anaconda-mode-find-definitions
:localleader :localleader

View file

@ -4,6 +4,8 @@
:commands restclient-mode :commands restclient-mode
:mode ("\\.http$" . restclient-mode)) :mode ("\\.http$" . restclient-mode))
(def-package! company-restclient (def-package! company-restclient
:when (featurep! :completion company)
:after restclient :after restclient
:config (set! :company-backend 'restclient-mode '(company-restclient))) :config (set! :company-backend 'restclient-mode '(company-restclient)))

View file

@ -63,14 +63,13 @@
(def-package! inf-ruby (def-package! inf-ruby
:commands (inf-ruby inf-ruby-console-auto) :commands (inf-ruby inf-ruby-console-auto)
:init :init (set! :repl 'ruby-mode 'inf-ruby))
(set! :repl 'ruby-mode 'inf-ruby)
:config
(set! :company-backend 'inf-ruby-mode '(company-inf-ruby)))
(def-package! company-inf-ruby (def-package! company-inf-ruby
:after inf-ruby) :when (featurep! :completion company)
:after inf-ruby
:config (set! :company-backend 'inf-ruby-mode '(company-inf-ruby)))
;; ;;

View file

@ -22,14 +22,16 @@
racer-rust-src-path (expand-file-name "rust/src/" +rust-cache-dir)) racer-rust-src-path (expand-file-name "rust/src/" +rust-cache-dir))
;; TODO Unit test keybinds ;; TODO Unit test keybinds
(set! :company-backend 'rust-mode '(company-racer))
(map! :map rust-mode-map :m "gd" 'racer-find-definition)) (map! :map rust-mode-map :m "gd" 'racer-find-definition))
(def-package! company-racer (def-package! company-racer
:after racer) :when (featurep! :completion company)
:after racer
:config (set! :company-backend 'rust-mode '(company-racer)))
(def-package! flycheck-rust (def-package! flycheck-rust
:when (featurep! :feature syntax-checker)
:after rust-mode) :after rust-mode)

View file

@ -6,5 +6,6 @@
(when (featurep! :feature syntax-checker) (when (featurep! :feature syntax-checker)
(package! flycheck-rust)) (package! flycheck-rust))
(when (featurep! :completion company) (when (featurep! :completion company)
(package! company-racer)) (package! company-racer))

View file

@ -21,6 +21,7 @@
(def-package! company-shell (def-package! company-shell
:when (featurep! :completion company)
:after sh-script :after sh-script
:config (setq company-shell-delete-duplicates t)) :config (setq company-shell-delete-duplicates t))

View file

@ -12,6 +12,7 @@
(def-package! company-sourcekit (def-package! company-sourcekit
:when (featurep! :completion company)
:after swift-mode :after swift-mode
:config :config
(set! :company-backend 'swift-mode '(company-sourcekit company-yasnippet))) (set! :company-backend 'swift-mode '(company-sourcekit company-yasnippet)))

View file

@ -19,6 +19,7 @@
;; ;;
(def-package! counsel-css (def-package! counsel-css
:when (featurep! :completion ivy)
:commands (counsel-css counsel-css-imenu-setup) :commands (counsel-css counsel-css-imenu-setup)
:init :init
(add-hook 'css-mode-hook 'counsel-css-imenu-setup) (add-hook 'css-mode-hook 'counsel-css-imenu-setup)

View file

@ -29,9 +29,12 @@
:nv "]t" 'web-mode-tag-next :nv "]t" 'web-mode-tag-next
:nv "[t" 'web-mode-tag-previous :nv "[t" 'web-mode-tag-previous
:nv "]T" 'web-mode-element-child :nv "]T" 'web-mode-element-child
:nv "[T" 'web-mode-element-parent) :nv "[T" 'web-mode-element-parent))
(def-package! company-web :after company))
(def-package! company-web
:when (featurep! :completion company)
:after web-mode)
(def-package! haml-mode :mode "\\.haml$") (def-package! haml-mode :mode "\\.haml$")

View file

@ -32,6 +32,7 @@
;; anzu and evil-anzu make it possible to display current/total in the ;; anzu and evil-anzu make it possible to display current/total in the
;; mode-line. ;; mode-line.
(def-package! evil-anzu (def-package! evil-anzu
:when (featurep! :feature evil)
:init :init
(add-transient-hook! evil-ex-start-search (require 'evil-anzu)) (add-transient-hook! evil-ex-start-search (require 'evil-anzu))
:config :config