From 36bbf518420918e965d11dad3d3f194803c47731 Mon Sep 17 00:00:00 2001 From: Chris Grieser <73286100+chrisgrieser@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:37:18 +0100 Subject: [PATCH] feat(yaml): capture "boolean strings" (#7512) See for example: https://www.bram.us/2022/01/11/yaml-the-norway-problem/ values based on: https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.truthy Parser targets YAML 1.2, which has stricter promotions. --- queries/yaml/highlights.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/queries/yaml/highlights.scm b/queries/yaml/highlights.scm index d41068359..9aed59ce4 100644 --- a/queries/yaml/highlights.scm +++ b/queries/yaml/highlights.scm @@ -80,3 +80,20 @@ "---" "..." ] @punctuation.special + +; help deal with for yaml's norway problem https://www.bram.us/2022/01/11/yaml-the-norway-problem/ +; only using `true` and `false`, since Treesitter parser targets YAML spec 1.2 https://github.com/nvim-treesitter/nvim-treesitter/pull/7512#issuecomment-2565397302 +(block_mapping_pair + value: (block_node + (block_sequence + (block_sequence_item + (flow_node + (plain_scalar + (string_scalar) @boolean + (#any-of? @boolean "TRUE" "FALSE" "True" "False"))))))) + +(block_mapping_pair + value: (flow_node + (plain_scalar + (string_scalar) @boolean + (#any-of? @boolean "TRUE" "FALSE" "True" "False"))))