dotfiles/emacs/.emacs.d/config/init-yaml.el

32 lines
1.5 KiB
EmacsLisp

;; -*- lexical-binding: t; -*-
;; YAML - literally the worst but still holds an important place in my life
(use-package yaml-ts-mode
:mode ("\\.yaml\\'" "\\.yml\\'")
:config
(add-hook 'yaml-ts-mode-hook #'highlight-indent-guides-mode))
(use-package yaml-pro
:hook (yaml-ts-mode . yaml-pro-ts-mode)
:config
(defun yaml-pro-edit-initialize-buffer-filter-args-advice (args)
(if-let ((mode (language-detection-detect-mode (buffer-string))))
(cl-destructuring-bind (parent-buffer buffer initial-text type initialize path) args
(let ((init-func (lambda ()
(funcall mode)
(when initialize
(call-interactively initialize)))))
(list parent-buffer buffer initial-text type init-func path)))
args))
(advice-add 'yaml-pro-edit-initialize-buffer :filter-args #'yaml-pro-edit-initialize-buffer-filter-args-advice)
:general
(yaml-pro-ts-mode-map [remap evil-backward-section-begin] #'yaml-pro-ts-prev-subtree
[remap evil-forward-section-begin] #'yaml-pro-ts-next-subtree
[remap evil-shift-right] #'yaml-pro-ts-indent-subtree
[remap evil-shift-left] #'yaml-pro-ts-unindent-subtree
"C-c j" #'yaml-pro-ts-move-subtree-down
"C-c k" #'yaml-pro-ts-move-subtree-up
"C-c f" #'yaml-pro-format))
(provide 'init-yaml)