lang/cc: add rtags support #305

This commit is contained in:
Henrik Lissner 2017-12-26 18:12:36 -05:00
parent a02edc1d01
commit 750b74379d
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395
2 changed files with 51 additions and 4 deletions

View File

@ -188,3 +188,48 @@ compilation database is present in the project.")
(set! :company-backend 'glsl-mode '(company-glsl))))
;;
;; Rtags Support
;;
(def-package! rtags
:after cc-mode
:config
(if (not (executable-find "rdm"))
(warn "cc-mode: couldn't find rdm, disabling rtags support")
(add-hook! (c-mode c++-mode) #'rtags-start-process-unless-running)
(set! :jump '(c-mode c++-mode)
:definition #'rtags-find-symbol-at-point
:references #'rtags-find-references-at-point))
(setq rtags-autostart-diagnostics t
rtags-use-bookmarks nil
rtags-jump-to-first-match nil
rtags-results-buffer-other-window t)
(defun +cc|cleanup-rdm-maybe ()
"Shut down the rtags daemon, if it's running."
(when (and (processp rtags-rdm-process)
(not (memq (process-status rtags-rdm-process) '(exit signal)))
(not (doom-buffers-in-mode '(c-mode c++-mode))))
(rtags-cancel-process)))
(add-hook 'doom-cleanup-hook #'+cc|cleanup-rdm-maybe)
(add-hook 'rtags-jump-hook #'evil-set-jump)
(add-hook 'rtags-after-find-file-hook #'recenter))
(def-package! ivy-rtags
:when (featurep! :completion ivy)
:after rtags
:init
;; NOTE Ivy integration breaks when rtags is byte-compiled with Emacs 26 or
;; later, so we un-byte-compile it before we load it.
(eval-when-compile
(when (>= emacs-major-version 26)
(when-let* ((elc-file (locate-library "rtags.elc" t doom--package-load-path)))
(delete-file elc-file))))
:config (setq rtags-display-result-backend 'ivy))
(def-package! helm-rtags
:when (featurep! :completion helm)
:after rtags
:config (setq rtags-display-result-backend 'helm))

View File

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