final tt updates
[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 "build")
16                            (file-name-as-directory "bin"))))
17
18 (require 'rtags)
19
20 ;; ;; ensure that we use only rtags checking
21 ;; ;; https://github.com/Andersbakken/rtags#optional-1
22 ;; (defun setup-flycheck-rtags ()
23 ;;   (interactive)
24 ;;   (flycheck-select-checker 'rtags)
25 ;;   ;; RTags creates more accurate overlays.
26 ;;   (setq-local flycheck-highlighting-mode nil)
27 ;;   (setq-local flycheck-check-syntax-automatically nil))
28
29 ;; only run this if rtags is installed
30 (when (require 'rtags nil :noerror)
31   ;; make sure you have company-mode installed
32   (require 'company)
33   (define-key c-mode-base-map (kbd "\C-c.")
34     (function rtags-find-symbol-at-point))
35   (define-key c-mode-base-map (kbd "\C-c,")
36     (function rtags-find-references-at-point))
37   (define-key c-mode-base-map (kbd "\C-cn")
38     (function rtags-next-diag))
39   ;; disable prelude's use of C-c r, as this is the rtags keyboard prefix
40   ;; (define-key prelude-mode-map (kbd "C-c r") nil)
41   ;; install standard rtags keybindings. Do M-. on the symbol below to
42   ;; jump to definition and see the keybindings.
43   (rtags-enable-standard-keybindings)
44   ;; comment this out if you don't have or don't use helm
45   (setq rtags-use-helm t)
46   ;; company completion setup
47   (setq rtags-autostart-diagnostics t)
48   (rtags-diagnostics)
49   (setq rtags-completions-enabled t)
50   (push 'company-rtags company-backends)
51   (global-company-mode)
52   (define-key c-mode-base-map (kbd "<C-tab>") (function company-complete))
53   ;; use rtags flycheck mode -- clang warnings shown inline
54   ;; (require 'flycheck-rtags)
55   ;; c-mode-common-hook is also called by c++-mode
56   ;; (add-hook 'c-mode-common-hook #'setup-flycheck-rtags)
57   )