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)
|
|
|
|
)
|
|
|
|
|
2023-05-27 19:46:28 +00:00
|
|
|
(use-package yaml-ts-mode
|
2022-10-20 04:03:56 +00:00
|
|
|
:mode
|
2023-05-27 19:46:28 +00:00
|
|
|
(
|
|
|
|
("\\.y[a]?ml\\'" . yaml-ts-mode)
|
|
|
|
("playbook\\.tmp\\'" . yaml-ts-mode)
|
2023-05-27 16:09:15 +00:00
|
|
|
("environments/[^/]*/group_vars/[^/]*\\'" . yaml-ts-mode)
|
|
|
|
("environments/[^/]*/host_vars/[^/]*\\'" . yaml-ts-mode)
|
2022-10-20 04:03:56 +00:00
|
|
|
)
|
2023-09-09 05:44:01 +00:00
|
|
|
:commands (yaml-ts-mode)
|
2022-10-20 04:03:56 +00:00
|
|
|
:hook (
|
2023-05-27 16:09:15 +00:00
|
|
|
(yaml-ts-mode . (lambda ()
|
2022-10-20 04:03:56 +00:00
|
|
|
(add-hook 'before-save-hook 'yaml-format-buffer nil 'local)
|
|
|
|
))
|
|
|
|
)
|
2023-05-27 16:09:15 +00:00
|
|
|
: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"))
|
2023-05-27 16:37:49 +00:00
|
|
|
(unless (treesit-ready-p 'yaml) (treesit-install-language-grammar 'yaml))
|
2022-10-20 04:03:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
(provide 'lang-yaml)
|