Emacs: Solve company-yasnippet tab-interference.

This commit is contained in:
tastytea 2019-12-23 03:52:07 +01:00
parent 8a57dfc62f
commit 1527e1cc0f
2 changed files with 20 additions and 4 deletions

View File

@ -1,6 +1,6 @@
;;; common.el --- Common programming settings. -*- lexical-binding: t; -*-
;; Time-stamp: <2019-12-01T06:11:27+00:00>
;; Time-stamp: <2019-12-23T02:50:34+00:00>
;;; Commentary:
@ -70,8 +70,9 @@
(:map company-active-map
("<return>" . nil) ; Disable completion on return.
("RET" . nil) ; https://emacs.stackexchange.com/a/13290
("<tab>" . company-complete-selection) ; Make tab work in lists.
("TAB" . company-complete-selection))
("<tab>" . company-complete-selection) ; Make tab work in lists (GUI).
("TAB" . company-complete-selection) ; Same in terminals.
)
:hook
(after-init . global-company-mode)

View File

@ -1,6 +1,6 @@
;;; common.el --- Common settings for text files. -*- lexical-binding: t; -*-
;; Time-stamp: <2019-12-18T23:44:03+00:00>
;; Time-stamp: <2019-12-23T02:48:05+00:00>
;;; Commentary:
@ -113,11 +113,26 @@
;; A template system.
(use-package yasnippet
:after (company)
:defines (company-candidates)
:functions (yas-reload-all yas-expand-snippet)
:config
(defun my/tab-yas-or-company ()
"Complete with company if possible, jump to next field otherwise."
(interactive)
(if company-candidates
(company-complete-selection)
(yas-next-field)))
(yas-reload-all)
:bind
(:map yas-keymap
("<tab>" . my/tab-yas-or-company)
("TAB" . my/tab-yas-or-company)
)
:hook
(prog-mode . yas-minor-mode)
)