Advertisement
sg2002

company and yasnippet

Mar 30th, 2016
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.62 KB | None | 0 0
  1. (defun do-yas-expand ()
  2.   (let ((yas-fallback-behavior 'return-nil))
  3.     (yas-expand)))
  4.  
  5. (defun check-expansion ()
  6.   (save-excursion
  7.     (if (looking-at "\\_>") t
  8.       (backward-char 1)
  9.       (if (looking-at "\\.") t
  10.         (backward-char 1)
  11.         (if (looking-at "->") t nil)))))
  12.  
  13. (defun tab-indent-or-complete ()
  14.   (interactive)
  15.   (if (minibufferp)
  16.       (minibuffer-complete)
  17.     (if (or (not yas-minor-mode)
  18.             (null (do-yas-expand)))
  19.         (if (check-expansion)
  20.             (company-complete-common)
  21.           (yas--fallback)))))
  22.  
  23. (define-key yas-minor-mode-map [tab] 'tab-indent-or-complete)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement