             ((equal ocamlformat-enable 'enable-outside-detected-project)
              (list "--enable-outside-detected-project"))
             (t
-             '()))))
+             '())))
+          (extension-args
+           (cond
+            ((eq ocamlformat-file-kind 'implementation)
+             (list "--impl"))
+            ((eq ocamlformat-file-kind 'interface)
+             (list "--intf")))))
      (unwind-protect
          (save-restriction
            (widen)

           (if (zerop
                 (apply 'call-process
                   ocamlformat-command nil (list :file errorfile) nil
                   (append margin-args
                     (append enable-args
                       (list
                         "--name" buffer-file-name
                         "--output" outputfile bufferfile)))))
             (progn
               (if ocamlformat--support-replace-buffer-contents
                   (ocamlformat--replace-buffer-contents outputfile)

          (const :tag "Fill column" fill)
          (const :tag "None" nil))
  :group 'ocamlformat)

(defcustom ocamlformat-file-kind nil
  "Add a parse argument to ocamlformat if using an unrecognized extension. It
    can either be set to 'implementation, 'interface or nil (default)."
    :type '(choice
            (const :tag "implementation" 'implementation)
            (const :tag "interface" 'interface)
            (const :tag "none" nil))
    :group 'ocamlformat)

;;;###autoload
(defun ocamlformat-before-save ()
