Improve YASnippet configuration

This commit is contained in:
Dimitri Lozeve 2019-12-24 16:12:21 +01:00
parent 6b8ed24b0c
commit b87c387302

20
init.el
View file

@ -158,8 +158,26 @@
(use-package yasnippet (use-package yasnippet
:ensure t :ensure t
:diminish yas-minor-mode
:init
(use-package yasnippet-snippets :ensure t :after yasnippet)
:hook ((prog-mode LaTeX-mode org-mode) . yas-minor-mode)
:bind
(:map yas-minor-mode-map ("C-c C-n" . yas-expand-from-trigger-key))
(:map yas-keymap
(("TAB" . smarter-yas-expand-next-field)
([(tab)] . smarter-yas-expand-next-field)))
:config :config
(yas-global-mode 1)) (yas-reload-all)
(defun smarter-yas-expand-next-field ()
"Try to `yas-expand' then `yas-next-field' at current cursor position."
(interactive)
(let ((old-point (point))
(old-tick (buffer-chars-modified-tick)))
(yas-expand)
(when (and (eq old-point (point))
(eq old-tick (buffer-chars-modified-tick)))
(ignore-errors (yas-next-field))))))
(use-package flycheck (use-package flycheck
:ensure t :ensure t