Update modules/feature/snippets
This commit is contained in:
parent
2f87987803
commit
aaf2314d9d
3 changed files with 71 additions and 64 deletions
18
modules/feature/snippets/autoload/evil.el
Normal file
18
modules/feature/snippets/autoload/evil.el
Normal file
|
@ -0,0 +1,18 @@
|
|||
;;; feature/snippets/autoload/evil.el
|
||||
|
||||
;;;###autoload
|
||||
(defun +snippets/expand-on-region ()
|
||||
"Only use this with `evil-mode'. Expands a snippet around a selected region
|
||||
and switches to insert mode if there are editable fields."
|
||||
(interactive)
|
||||
(when (evil-visual-state-p)
|
||||
(let ((end (region-end)))
|
||||
(evil-visual-select
|
||||
(region-beginning)
|
||||
(if (eq evil-this-type 'line) end (1+ end))
|
||||
'inclusive)))
|
||||
(yas-insert-snippet)
|
||||
(let* ((snippet (first (yas--snippets-at-point)))
|
||||
(fields (yas--snippet-fields snippet)))
|
||||
(evil-insert-state +1)
|
||||
(unless fields (evil-change-state 'normal))))
|
Loading…
Add table
Add a link
Reference in a new issue