 ;; rtags setup ;;
 ;;;;;;;;;;;;;;;;;
 
-(require 'rtags)
-(require 'company)
-(require 'flycheck-rtags)
-
-(condition-case nil ; The following commands will fail if rtags is not installed.
+(if (executable-find "rc")
+  (condition-case nil ; The following commands will fail if rtags is not installed.
     (progn
+      (require 'rtags)
+      (require 'company)
+      (require 'flycheck-rtags)
+
       (setq rtags-autostart-diagnostics t)
       (rtags-diagnostics)
       (setq rtags-completions-enabled t)

        (define-key-multimap maps (kbd "M-p") 'rtags-previous-match)
        (define-key-multimap maps (kbd "M-f") 'rtags-location-stack-forward)
        (define-key-multimap maps (kbd "M-b") 'rtags-location-stack-back)
        (define-key-multimap maps (kbd "M-SPC") (function company-complete))   ; Force company completion with M-space
        (define-key-multimap maps (kbd "M-SPC") (function company-complete))))
  (error (message "rtags could not be initialized.")))

(global-company-mode)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; rust setup using racer ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq racer-rust-src-path "~/Documents/rust-src/src/")
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)
(add-hook 'racer-mode-hook #'company-mode)

(require 'rust-mode)
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
(setq company-tooltip-align-annotations t)

(setq company-idle-delay .3)
(setq company-minimum-prefix-length 2)

;;;;;;;;;;;;;;;;;;;;;;
;; MELPA over HTTPS ;;

;; (Cisco Aurora specific)                                                          ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; (setenv "PATH"
;;   (concat
;;    "/home/wvanders/pkgs/bin" ":"
;;    (getenv "PATH")))

;; (setenv "LD_LIBRARY_PATH"
;;   (concat
;;    "/home/wvanders/pkgs/lib" ":"
;;    "/home/wvanders/pkgs/lib64" ":"
;;    (getenv "PATH")))

;;;;;;;;;;;;;;;;;;;;;;;
;; Utility functions ;;
