]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/company/company-yasnippet.el
Merge commit 'f4edea201bc4c38d082ec3143ceec87d2dcadb37' from diff-hl
[gnu-emacs-elpa] / packages / company / company-yasnippet.el
index ae370c78feca440e0eb64cc024604e3fd88fb111..f0a7c380d9d4c9a69599bf9c9a87131aebd5892b 100644 (file)
 
 ;;; Code:
 
-(require 'yasnippet)
+(require 'company)
+(require 'cl-lib)
+
+(declare-function yas--table-hash "yasnippet")
+(declare-function yas--get-snippet-tables "yasnippet")
+(declare-function yas-expand-snippet "yasnippet")
+(declare-function yas--template-content "yasnippet")
+(declare-function yas--template-expand-env "yasnippet")
 
 (defun company-yasnippet--candidates (prefix)
-  (mapcan
+  (cl-mapcan
    (lambda (table)
      (let ((keyhash (yas--table-hash table))
            res)
@@ -74,14 +81,17 @@ shadow back-ends that come after it.  Recommended usages:
   (global-set-key (kbd \"C-c y\") 'company-yasnippet)
 "
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-yasnippet))
     (prefix
      ;; Should probably use `yas--current-key', but that's bound to be slower.
      ;; How many trigger keys start with non-symbol characters anyway?
-     (and yas-minor-mode
+     (and (bound-and-true-p yas-minor-mode)
           (company-grab-symbol)))
-    (annotation (concat " -> " (get-text-property 0 'yas-annotation arg)))
+    (annotation
+     (concat
+      (unless company-tooltip-align-annotations " -> ")
+      (get-text-property 0 'yas-annotation arg)))
     (candidates (company-yasnippet--candidates arg))
     (post-completion
      (let ((template (get-text-property 0 'yas-template arg)))