machine_setup/ansible/roles/emacs/files/lang-yaml.el

25 lines
753 B
EmacsLisp
Raw Normal View History

2022-10-20 04:03:56 +00:00
(defun yaml-format-buffer ()
"Run prettier."
(interactive)
(run-command-on-buffer "prettier" "--stdin-filepath" buffer-file-name)
)
(use-package yaml-mode
:mode
(("playbook\\.tmp\\'" . yaml-ts-mode)
("environments/[^/]*/group_vars/[^/]*\\'" . yaml-ts-mode)
("environments/[^/]*/host_vars/[^/]*\\'" . yaml-ts-mode)
2022-10-20 04:03:56 +00:00
)
:hook (
(yaml-ts-mode . (lambda ()
2022-10-20 04:03:56 +00:00
(add-hook 'before-save-hook 'yaml-format-buffer nil 'local)
))
)
:init
(add-to-list 'major-mode-remap-alist '(yaml-mode . yaml-ts-mode))
(add-to-list 'treesit-language-source-alist '(yaml "https://github.com/ikatyang/tree-sitter-yaml"))
(treesit-install-language-grammar 'yaml)
2022-10-20 04:03:56 +00:00
)
(provide 'lang-yaml)