0d47656476bd3e1784a58825ad2759c7c492be00
[emacs-init.git] / setup / rtags.el
1 (let ((base (file-name-directory
2              (directory-file-name
3               (file-name-directory (or load-file-name
4                                        (when (boundp 'bytecomp-filename) bytecomp-filename)
5                                        buffer-file-name))))))
6   (add-to-list 'load-path (concat base
7                                   (file-name-as-directory "rtags")
8                                   (file-name-as-directory "src")))
9   (add-to-list 'load-path (concat base
10                                   (file-name-as-directory "elpa")
11                                   (file-name-as-directory "company-0.9.2")))
12
13   (setq rtags-path (concat base
14                            (file-name-as-directory "rtags")
15                            (file-name-as-directory "bin"))))
16
17 (require 'rtags)
18
19 ;; ;; ensure that we use only rtags checking
20 ;; ;; https://github.com/Andersbakken/rtags#optional-1
21 ;; (defun setup-flycheck-rtags ()
22 ;;   (interactive)
23 ;;   (flycheck-select-checker 'rtags)
24 ;;   ;; RTags creates more accurate overlays.
25 ;;   (setq-local flycheck-highlighting-mode nil)
26 ;;   (setq-local flycheck-check-syntax-automatically nil))
27
28 ;; only run this if rtags is installed
29 (when (require 'rtags nil :noerror)
30   ;; make sure you have company-mode installed
31   (require 'company)
32   (define-key c-mode-base-map (kbd "\C-c.")
33     (function rtags-find-symbol-at-point))
34   (define-key c-mode-base-map (kbd "\C-c,")
35     (function rtags-find-references-at-point))
36   ;; disable prelude's use of C-c r, as this is the rtags keyboard prefix
37   ;; (define-key prelude-mode-map (kbd "C-c r") nil)
38   ;; install standard rtags keybindings. Do M-. on the symbol below to
39   ;; jump to definition and see the keybindings.
40   (rtags-enable-standard-keybindings)
41   ;; comment this out if you don't have or don't use helm
42   (setq rtags-use-helm t)
43   ;; company completion setup
44   (setq rtags-autostart-diagnostics t)
45   (rtags-diagnostics)
46   (setq rtags-completions-enabled t)
47   (push 'company-rtags company-backends)
48   (global-company-mode)
49   (define-key c-mode-base-map (kbd "<C-tab>") (function company-complete))
50   ;; use rtags flycheck mode -- clang warnings shown inline
51   ;; (require 'flycheck-rtags)
52   ;; c-mode-common-hook is also called by c++-mode
53   ;; (add-hook 'c-mode-common-hook #'setup-flycheck-rtags)
54   )