feat(yaml): add treesit support

This commit is contained in:
Henrik Lissner
2025-05-15 18:55:42 +02:00
parent 8931c48913
commit 2556cb58f2
3 changed files with 27 additions and 6 deletions

View File

@ -11,8 +11,8 @@ This module provides support for the [[https://yaml.org/][YAML file format]] to
** Module flags
- +lsp ::
Enable LSP support for ~yaml-mode~. Requires [[doom-module::tools lsp]] and a langserver
(supports [[https://github.com/redhat-developer/yaml-language-server][yaml-language-server]]).
Enable LSP support for ~yaml-mode~. Requires [[doom-module::tools lsp]] and a
langserver (supports [[https://github.com/redhat-developer/yaml-language-server][yaml-language-server]]).
- +tree-sitter ::
Leverages tree-sitter for better syntax highlighting and structural text
editing. Requires [[doom-module::tools tree-sitter]].

View File

@ -2,10 +2,22 @@
(use-package! yaml-mode
:mode "Procfile\\'"
:init
:config
(when (modulep! +lsp)
(add-hook 'yaml-mode-local-vars-hook #'lsp! 'append))
(when (modulep! +tree-sitter)
(add-hook 'yaml-mode-local-vars-hook #'tree-sitter! 'append))
:config
(setq-hook! 'yaml-mode-hook tab-width yaml-indent-offset))
(use-package! yaml-ts-mode
:when (modulep! +tree-sitter)
:when (fboundp 'yaml-ts-mode) ; 29.1+ only
:init
(set-tree-sitter! 'yaml-mode 'yaml-ts-mode
'((yaml :url "https://github.com/tree-sitter-grammars/tree-sitter-yaml"
:rev "v0.7.0")))
:config
;; HACK: Rely on `major-mode-remap-defaults'.
(cl-callf2 rassq-delete-all 'yaml-ts-mode auto-mode-alist)
(when (modulep! +lsp)
(add-hook 'yaml-ts-mode-local-vars-hook #'lsp! 'append)))

View File

@ -0,0 +1,9 @@
;;; lang/yaml/doctor.el -*- lexical-binding: t; -*-
(assert! (or (not (modulep! +lsp))
(modulep! :tools lsp))
"This module requires (:tools lsp)")
(assert! (or (not (modulep! +tree-sitter))
(modulep! :tools tree-sitter))
"This module requires (:tools tree-sitter)")