     ("go" 'company-ycmd--construct-candidate-go)
     ("python" 'company-ycmd--construct-candidate-python)
     ("rust" 'company-ycmd--construct-candidate-rust)
+    ("swift" 'company-ycmd--construct-candidate-swift)
     ("javascript" 'company-ycmd--construct-candidate-javascript)
     ("typescript" 'company-ycmd--construct-candidate-typescript)
     (_ 'company-ycmd--construct-candidate-generic)))

    go-mode
    objc-mode
    rust-mode
    python-mode
    js-mode
    typescript-mode)


(defun company-ycmd--post-completion (candidate)
  "Insert function arguments after completion for CANDIDATE."
  (if (eq major-mode 'swift-mode)
      (company-ycmd--post-completion-swift candidate)
    (--when-let (and (company-ycmd--extended-features-p)
                     company-ycmd-insert-arguments
                     (get-text-property 0 'params candidate))
      (when (memq major-mode '(python-mode rust-mode))
        (setq it (company-ycmd--remove-self-from-function-args it))
        (when (eq major-mode 'rust-mode)
          (setq it (company-ycmd--remove-template-args-from-function-args it))))
      (insert it)
      (if (string-match "\\`:[^:]" it)
          (company-template-objc-templatify it)
        (company-template-c-like-templatify
         (concat candidate it))))))

(declare-function yas-expand-snippet "yasnippet")
(defun company-ycmd--post-completion-swift (candidate)
  "Insert function arguments after completion for CANDIDATE in
swift mode."
  (let ((template (company-ycmd--build-yasnippet-sourcekit
                   (get-text-property 0 'sourcetext candidate))))
    (yas-expand-snippet template (- (point) (length candidate)) (point))))

(defun company-ycmd--doc-buffer (candidate)
  "Return buffer with docstring for CANDIDATE if it is available."
