Enable read-only-mode for built-in snippets
Because they shouldn't be edited out of ~/.emacs.d/.local -- if a snippet in ~/.doom.d/snippets has the same name, built-in snippets will be ignored.
This commit is contained in:
parent
c399c07694
commit
a4f9eb6f6c
2 changed files with 10 additions and 0 deletions
|
@ -102,6 +102,13 @@ buggy behavior when <delete> is pressed in an empty field."
|
||||||
(yas-activate-extra-mode mode)
|
(yas-activate-extra-mode mode)
|
||||||
(yas-deactivate-extra-mode mode)))
|
(yas-deactivate-extra-mode mode)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +snippets|read-only-maybe ()
|
||||||
|
"Enable `read-only-mode' if snippet is built-in."
|
||||||
|
(when (file-in-directory-p default-directory doom-local-dir)
|
||||||
|
(read-only-mode 1)
|
||||||
|
(message "This is a built-in snippet, enabling read only mode. Use `yas-new-snippet' to redefine snippets")))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Commands
|
;; Commands
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
;; tell smartparens overlays not to interfere with yasnippet keybinds
|
;; tell smartparens overlays not to interfere with yasnippet keybinds
|
||||||
(advice-add #'yas-expand :before #'sp-remove-active-pair-overlay))
|
(advice-add #'yas-expand :before #'sp-remove-active-pair-overlay))
|
||||||
|
|
||||||
|
;; Enable `read-only-mode' for built-in snippets (in `doom-local-dir')
|
||||||
|
(add-hook 'snippet-mode-hook #'+snippets|read-only-maybe)
|
||||||
|
|
||||||
(when (featurep! :editor evil)
|
(when (featurep! :editor evil)
|
||||||
;; evil visual-mode integration for `yas-insert-snippet'
|
;; evil visual-mode integration for `yas-insert-snippet'
|
||||||
(define-key yas-minor-mode-map [remap yas-insert-snippet] #'+snippets/expand-on-region)))
|
(define-key yas-minor-mode-map [remap yas-insert-snippet] #'+snippets/expand-on-region)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue