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:
Henrik Lissner 2019-07-12 20:41:50 +02:00
parent f90c0b8040
commit 05eb333a0c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 190 additions and 27 deletions

View file

@ -793,14 +793,16 @@
;;; <leader> s --- snippets
(:when (featurep! :editor snippets)
(:prefix-map ("s" . "snippets")
:desc "New snippet" "n" #'yas-new-snippet
:desc "View snippet for mode" "/" #'+snippets/find-for-current-mode
:desc "View snippet (global)" "?" #'+snippets/find
:desc "Edit snippet" "c" #'+snippet/edit
:desc "View private snippet" "f" #'+snippets/find-private
:desc "Insert snippet" "i" #'yas-insert-snippet
:desc "Jump to mode snippet" "/" #'yas-visit-snippet-file
:desc "Jump to snippet" "s" #'+snippets/find-file
:desc "Browse snippets" "S" #'+snippets/browse
:desc "New snippet" "n" #'+snippet/new
:desc "New snippet alias" "N" #'+snippet/new-alias
:desc "Reload snippets" "r" #'yas-reload-all
:desc "Create temporary snippet" "c" #'aya-create
:desc "Use temporary snippet" "e" #'aya-expand))
:desc "Create temporary snippet" "s" #'aya-create
:desc "Expand temporary snippet" "e" #'aya-expand))
;;; <leader> t --- toggle
(:prefix-map ("t" . "toggle")