;;; init-yaml.el --- Initialize yaml-mode -*- lexical-binding: t -*-

;;; Commentary:

;; Emacs doesn't include a YAML mode. I created yaml-mode solely to run yamllint
;; and Prettier on YAML files.

;;; Code:

(unless (package-installed-p 'flymake-yamllint)
  (package-vc-install "https://codeberg.org/shaohme/flymake-yamllint.git"
                      "020d2a33568c8069801db9dd6992b8961a58de8d"))

(require 'flymake-yamllint)
(require 'init-prettier)

(define-derived-mode yaml-mode nil "YAML")

(setopt flymake-yamllint-arguments '("-d" "relaxed"))

(add-to-list 'auto-mode-alist '("\\.\\(yaml\\|yml\\)\\'" . yaml-mode))

(add-hook 'yaml-mode-hook #'flymake-yamllint-setup)
(add-hook 'yaml-mode-hook #'flymake-mode)
(add-hook 'yaml-mode-hook #'prettier-js-mode)

(provide 'init-yaml)

;;; init-yaml.el ends here
