editor/snippets: expand on snippet commands & keybinds
- Introduces the +snippets/new (SPC s n) command for creating a new private snippet - Introduces the +snippets/new-lias (SPC s N) command for creating a new private snippet alias, which will invoke another snippet (you will be prompted to select one). This will only work with the emacs-snippets library bundled with Doom Emacs, however, as it depends on its API. - Introduces +snippets/edit (SPC s c) for modifying existing snippets. How this differs from yas-visit-snippet-file is it will copy the contents of built-in snippets into a buffer primed for your private snippets (in DOOMDIR/snippets), while yas-visit-snippet-file will simply open the originating snippet. - Introduces the +snippets/find (SPC s ?), +snippets/find-for-current-mode (SPC s /) and +snippets/find-private (SPC s f) commands for, respectively, finding a snippet file among *all* directories in yas-snippet-dirs, finding a snippet for the current major mode (plus parents), and finding a snippet from among your private library. This opens built-in snippets in read-only mode, but you can press C-c C-e to open it in +snippets/edit.
This commit is contained in:
parent
f90c0b8040
commit
05eb333a0c
3 changed files with 190 additions and 27 deletions
|
@ -48,9 +48,19 @@
|
|||
;; Enable `read-only-mode' for built-in snippets (in `doom-local-dir')
|
||||
(add-hook 'snippet-mode-hook #'+snippets|read-only-maybe)
|
||||
|
||||
;; (Evil only) fix off-by-one issue with visual-mode selections in
|
||||
;; (Evil only) fix off-by-one issue with line-wise visual selections in
|
||||
;; `yas-insert-snippet', and switches to insert mode afterwards.
|
||||
(advice-add #'yas-insert-snippet :around #'+snippets*expand-on-region))
|
||||
(advice-add #'yas-insert-snippet :around #'+snippets*expand-on-region)
|
||||
|
||||
(define-key! snippet-mode-map
|
||||
"C-c C-k" #'+snippet--abort
|
||||
"C-c C-e" #'+snippet--edit)
|
||||
(add-hook 'snippet-mode-hook #'+snippets|show-hints-in-header-line)
|
||||
|
||||
;; Replace commands with superior alternatives
|
||||
(define-key! yas-minor-mode-map
|
||||
[remap yas-new-snippet] #'+snippets/new
|
||||
[remap yas-visit-snippet-file] #'+snippets/edit))
|
||||
|
||||
|
||||
;; `auto-yasnippet'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue