 (use-package company
   :diminish company-mode
   :pin melpa
-  :config
-  (global-company-mode)
+  :preface
+  ;; enable yasnippet everywhere
+  ;; https://onze.io/emacs/c++/2017/03/16/emacs-cpp.html
+  (defvar company-mode/enable-yas t
+    "Enable yasnippet for all backends.")
+  (defun company-mode/backend-with-yas (backend)
+    (if (or
+         (not company-mode/enable-yas)
+         (and (listp backend) (member 'company-yasnippet backend)))
+        backend
+      (append (if (consp backend) backend (list backend))
+              '(:with company-yasnippet))))
+  :config (global-company-mode t)
   (setq-local company-dabbrev-downcase nil)
   (setq company-minimum-prefix-length 2
 	company-show-numbers t
         company-idle-delay 0)
   (add-to-list 'company-transformers #'company-sort-by-occurrence)
+  (setq company-backends
+	(mapcar #'company-mode/backend-with-yas company-backends))
   )
 
 (use-package magit
   :bind ("C-x g" . magit-status)
   :defer t
+  :diminish auto-revert-mode
   )
 
 (load-file "~/.emacs.d/custom-functions.el") ;; Loads my custom-functions

;; Install ymcd by installing build.py, do "python build.py -h" for help
;; Set Environment variable YMCD to the root folder of the repo
(use-package ycmd
  :init
  (add-hook 'c++-mode-hook 'ycmd-mode)
  (set 'ycmd-server-command `("python" "-u" ,(expand-file-name "ycmd" (getenv "YCMD"))))


(use-package company-ycmd
  :after company
  :init (add-hook 'ycmd-mode-hook 'company-ycmd-setup)
  :config (add-to-list 'company-backends (company-mode/backend-with-yas 'company-ycmd))
  )

(use-package flycheck-ycmd
  :after company
  :init (add-hook 'ycmd-mode-hook 'flycheck-ycmd-setup)
  )

(use-package eldoc
  :diminish eldoc-mode
  :init (add-hook 'ycmd-mode-hook 'ycmd-eldoc-setup)
  )

(use-package ggtags
