mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
yas-also-auto-indent-first-line = nil
Stop yasnippet from aggressively reindenting the whole snippet; assume the user is expanding the snippet exactly where they want it. Half-fixes #3211
This commit is contained in:
@ -288,16 +288,27 @@ shadow the default snippet)."
|
|||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +snippets-expand-on-region-a (orig-fn &optional no-condition)
|
(defun +snippets-expand-on-region-a (orig-fn &optional no-condition)
|
||||||
"Fix off-by-one issue with expanding snippets on an evil visual region, and
|
"Fix off-by-one when expanding snippets on an evil visual region.
|
||||||
switches to insert mode.
|
|
||||||
|
|
||||||
If evil-local-mode isn't enabled, run ORIG-FN as is."
|
Also strips whitespace out of selection. Also switches to insert mode. If
|
||||||
|
`evil-local-mode' isn't enabled, or we're not in visual mode, run ORIG-FN as
|
||||||
|
is."
|
||||||
(if (not (and (bound-and-true-p evil-local-mode)
|
(if (not (and (bound-and-true-p evil-local-mode)
|
||||||
(evil-visual-state-p)))
|
(evil-visual-state-p)))
|
||||||
(funcall orig-fn no-condition)
|
(funcall orig-fn no-condition)
|
||||||
(evil-visual-select evil-visual-beginning evil-visual-end 'inclusive)
|
;; Trim whitespace in selected region, so as not to introduce extra
|
||||||
(cl-letf (((symbol-function 'region-beginning) (lambda () evil-visual-beginning))
|
;; whitespace into `yas-selected-text'.
|
||||||
((symbol-function 'region-end) (lambda () evil-visual-end)))
|
(evil-visual-select (save-excursion
|
||||||
|
(goto-char evil-visual-beginning)
|
||||||
|
(skip-chars-forward " \t")
|
||||||
|
(point))
|
||||||
|
(save-excursion
|
||||||
|
(goto-char evil-visual-end)
|
||||||
|
(skip-chars-backward " \t")
|
||||||
|
(point))
|
||||||
|
'inclusive)
|
||||||
|
(letf! ((defun region-beginning () evil-visual-beginning)
|
||||||
|
(defun region-end () evil-visual-end))
|
||||||
(funcall orig-fn no-condition)))
|
(funcall orig-fn no-condition)))
|
||||||
(when (and (bound-and-true-p evil-local-mode)
|
(when (and (bound-and-true-p evil-local-mode)
|
||||||
(yas-active-snippets))
|
(yas-active-snippets))
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
;; Reduce verbosity. 3 is too chatty about initializing yasnippet. 2 is just
|
;; Reduce verbosity. 3 is too chatty about initializing yasnippet. 2 is just
|
||||||
;; right (only shows errors).
|
;; right (only shows errors).
|
||||||
(setq yas-verbosity (if doom-debug-mode 3 0))
|
(setq yas-verbosity (if doom-debug-mode 3 0))
|
||||||
;; Ensure the snippet is properly indented
|
|
||||||
(setq yas-also-auto-indent-first-line t)
|
|
||||||
|
|
||||||
;; default snippets library, if available
|
;; default snippets library, if available
|
||||||
(add-to-list 'load-path +snippets-dir)
|
(add-to-list 'load-path +snippets-dir)
|
||||||
|
Reference in New Issue
Block a user