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

36 lines
1.0 KiB
EmacsLisp

;; (defun yaml-backspace (arg)
;; "Special handling of yaml backspace."
;; (interactive "*p")
;; (if mark-active
;; (backward-delete-char-untabify arg)
;; (yaml-electric-backspace arg)
;; )
;; )
(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-mode)
("environments/[^/]*/group_vars/[^/]*\\'" . yaml-mode)
("environments/[^/]*/host_vars/[^/]*\\'" . yaml-mode)
)
:hook (
(yaml-mode . (lambda ()
(setq eglot-workspace-configuration
(list (cons ':yaml (list ':hover :json-false :validate :json-false :completion t))))
(eglot-ensure)
(add-hook 'before-save-hook 'yaml-format-buffer nil 'local)
))
)
;; :bind (
;; (:map yaml-mode-map ([backspace] . yaml-backspace))
;; )
)
(provide 'lang-yaml)