 (defun ycmd-parse-buffer ()
   "Parse buffer."
   (interactive)
-  (ycmd--set-buffer-needs-parse))
+  (ycmd--conditional-parse))
 
 (defun ycmd-notify-file-ready-to-parse ()
   (when (ycmd--major-mode-to-file-types major-mode)


(defun ycmd--on-save ()
  "Function to run when the buffer has been saved."
  (ycmd--set-buffer-needs-parse 'save))

(defun ycmd--on-idle-change ()
  "Function to run on idle-change."
  (ycmd--kill-notification-timer)
  (ycmd--set-buffer-needs-parse 'idle-change))

(defun ycmd--on-change (beg end _len)
  "Function to run when a buffer change between BEG and END."

    (when (and ycmd-mode (not (eq beg end)))
      (ycmd--kill-notification-timer)
      (if (string-match-p "\n" (buffer-substring beg end))
          (ycmd--conditional-parse 'new-line)
        (setq ycmd--notification-timer
              (run-at-time ycmd-idle-change-delay nil
                           #'ycmd--on-idle-change))))))
