lang/cc: refactor (nest configs and chain packages)

Allows users to disable irony and/or rtags only, then their dependent
packages won't be loaded.
This commit is contained in:
Henrik Lissner 2018-05-16 00:16:05 +02:00
parent e7a1e0b4a2
commit 63fdc3530c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 41 additions and 42 deletions

View file

@ -136,23 +136,29 @@ compilation database is present in the project.")
(defun +cc|init-irony-mode ()
(when (memq major-mode '(c-mode c++-mode objc-mode))
(irony-mode +1)))
(add-hook! (c-mode c++-mode objc-mode) #'+cc|init-irony-mode)
(add-hook 'c-mode-common-hook #'+cc|init-irony-mode)
:config
(setq irony-cdb-search-directory-list '("." "build" "build-conda"))
;; Initialize compilation database, if present. Otherwise, fall back on
;; `+cc-default-compiler-options'.
(add-hook 'irony-mode-hook #'+cc|irony-init-compile-options))
(add-hook 'irony-mode-hook #'+cc|irony-init-compile-options)
(def-package! irony-eldoc
:hook (irony-mode . irony-eldoc))
(def-package! irony-eldoc :hook (irony-mode . irony-eldoc))
(def-package! flycheck-irony
:when (featurep! :feature syntax-checker)
:after irony
:config
(add-hook 'irony-mode-hook #'flycheck-mode)
(flycheck-irony-setup))
(def-package! company-irony
:when (featurep! :completion company)
:after irony)
(def-package! company-irony-c-headers
:when (featurep! :completion company)
:after company-irony))
;;
;; Tools
@ -193,14 +199,6 @@ compilation database is present in the project.")
:when (featurep! :completion company)
:after cmake-mode)
(def-package! company-irony
:when (featurep! :completion company)
:after irony)
(def-package! company-irony-c-headers
:when (featurep! :completion company)
:after company-irony)
(def-package! company-glsl
:when (featurep! :completion company)
:after glsl-mode
@ -213,7 +211,7 @@ compilation database is present in the project.")
;;
(def-package! rtags
:commands (rtags-restart-process rtags-start-process-unless-running rtags-executable-find)
:commands rtags-executable-find
:init
(add-hook! (c-mode c++-mode) #'+cc|init-rtags)
:config
@ -237,7 +235,7 @@ compilation database is present in the project.")
(map! :map (c-mode-map c++-mode-map) [remap imenu] #'rtags-imenu)
(when (featurep 'evil) (add-hook 'rtags-jump-hook #'evil-set-jump))
(add-hook 'rtags-after-find-file-hook #'recenter))
(add-hook 'rtags-after-find-file-hook #'recenter)
(def-package! ivy-rtags
:when (featurep! :completion ivy)
@ -247,4 +245,4 @@ compilation database is present in the project.")
(def-package! helm-rtags
:when (featurep! :completion helm)
:after rtags
:config (setq rtags-display-result-backend 'helm))
:config (setq rtags-display-result-backend 'helm)))

View file

@ -5,22 +5,23 @@
(package! cuda-mode)
(package! demangle-mode)
(package! disaster)
(package! glsl-mode)
(package! irony)
(package! irony-eldoc)
(package! modern-cpp-font-lock)
(package! opencl-mode)
(when (package! glsl-mode)
(when (featurep! :completion company)
(package! company-glsl :recipe (:fetcher github :repo "Kaali/company-glsl"))))
(when (package! irony)
(package! irony-eldoc)
(when (featurep! :feature syntax-checker)
(package! flycheck-irony))
(when (featurep! :completion company)
(package! company-glsl :recipe (:fetcher github :repo "Kaali/company-glsl"))
(package! company-irony)
(package! company-irony-c-headers))
(package! company-irony-c-headers)))
(package! rtags)
(when (package! rtags)
(when (featurep! :completion ivy)
(package! ivy-rtags))
(when (featurep! :completion helm)
(package! helm-rtags))
(package! helm-rtags)))