     (ycmd--log-content "HTTP RESPONSE CONTENT" response)
     response))
 
+(defun ycmd--on-find-file ()
+  (when (ycmd--major-mode-to-file-types major-mode)
+    (unless (ycmd-running?) (ycmd-open))
+    (ycmd-notify-file-ready-to-parse)))
+
+(add-hook 'find-file-hook 'ycmd--on-find-file)
+(add-hook 'kill-emacs-hook 'ycmd-close)
+
 (provide 'ycmd)
 
 ;;; ycmd.el ends here

    (ycmd--start-server hmac-secret)
    (setq ycmd--hmac-secret hmac-secret))

  (ycmd--start-notification-timer)

  (add-hook 'find-file-hook 'ycmd-notify-file-ready-to-parse)
  (add-hook 'kill-emacs-hook 'ycmd-close))

(defun ycmd-close ()
  "Shutdown any running ycmd server.

;;
;;   (set-variable 'ycmd-extra-conf-whitelist '("~/projects/*"))
;;
;; Now, the first time you open a file for which ycmd can perform
;; completions, a ycmd server will be automatically started.
;;
;; Use 'ycmd-get-completions to get completions at some point in a
;; file. For example:
;;
;;   (ycmd-get-completions)
;;
;; You can use 'ycmd-display-completions to toy around with completion
