lang/cc: fix rtags in other c*-mode derived modes; fix cleanup hook
Also fixed rtags cleanup in doom-cleanup-hook to only kill the server if there are no more C/C++ buffers open.
This commit is contained in:
parent
cde3a3ee78
commit
28adf5825f
2 changed files with 21 additions and 8 deletions
|
@ -88,3 +88,14 @@ compilation dbs."
|
||||||
nconc (list "-I" path)))
|
nconc (list "-I" path)))
|
||||||
(doom-project-root)))))
|
(doom-project-root)))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +cc|init-rtags ()
|
||||||
|
"Start an rtags server in c-mode and c++-mode buffers."
|
||||||
|
(when (memq major-mode '(c-mode c++-mode))
|
||||||
|
(rtags-start-process-unless-running)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +cc|cleanup-rtags ()
|
||||||
|
"Kill rtags server(s) if there are no C/C++ buffers open."
|
||||||
|
(unless (doom-buffers-in-mode '(c-mode c++-mode) (buffer-list))
|
||||||
|
(rtags-cancel-process)))
|
||||||
|
|
|
@ -215,7 +215,9 @@ compilation database is present in the project.")
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(def-package! rtags
|
(def-package! rtags
|
||||||
:after cc-mode
|
:commands (rtags-restart-process rtags-start-process-unless-running)
|
||||||
|
:init
|
||||||
|
(add-hook! (c-mode c++-mode) #'+cc|init-rtags)
|
||||||
:config
|
:config
|
||||||
(setq rtags-autostart-diagnostics t
|
(setq rtags-autostart-diagnostics t
|
||||||
rtags-use-bookmarks nil
|
rtags-use-bookmarks nil
|
||||||
|
@ -227,14 +229,14 @@ compilation database is present in the project.")
|
||||||
rtags-jump-to-first-match nil)
|
rtags-jump-to-first-match nil)
|
||||||
|
|
||||||
(let ((bins (cl-remove-if #'executable-find '("rdm" "rc"))))
|
(let ((bins (cl-remove-if #'executable-find '("rdm" "rc"))))
|
||||||
(if (/= (length bins) 0)
|
(when (/= (length bins) 0)
|
||||||
(warn! "Couldn't find the rtag client and/or server programs %s. Disabling rtags support" bins)
|
(warn! "Couldn't find the rtag client and/or server programs %s. Disabling rtags support" bins)))
|
||||||
(add-hook! (c-mode c++-mode) #'rtags-start-process-unless-running)
|
|
||||||
(set! :lookup '(c-mode c++-mode)
|
(set! :lookup '(c-mode c++-mode)
|
||||||
:definition #'rtags-find-symbol-at-point
|
:definition #'rtags-find-symbol-at-point
|
||||||
:references #'rtags-find-references-at-point)))
|
:references #'rtags-find-references-at-point)
|
||||||
|
|
||||||
(add-hook 'doom-cleanup-hook #'rtags-cancel-process)
|
(add-hook 'doom-cleanup-hook #'+cc|cleanup-rtags)
|
||||||
(add-hook! kill-emacs (ignore-errors (rtags-cancel-process)))
|
(add-hook! kill-emacs (ignore-errors (rtags-cancel-process)))
|
||||||
|
|
||||||
;; Use rtags-imenu instead of imenu/counsel-imenu
|
;; Use rtags-imenu instead of imenu/counsel-imenu
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue