justinmk/tree-sitter-ini

setting_value includes leading white space.

dsully opened this issue · 1 comments

Hi - I'm trying to add highlights for Neovim using tree-sitter-ini, and the grammar is capturing the leading white space for setting_value. I've included a screen shot showing the node match:

CleanShot 2023-01-10 at 19 47 06@2x

I think this is just a minor change to grammar.js, but this is my first venture into TS grammars.

Thanks

Thanks for the report. This can be fixed with this patch:

diff --git a/grammar.js b/grammar.js
index d4bc82067a09..0c26d3bc421b 100644
--- a/grammar.js
+++ b/grammar.js
@@ -33,7 +33,7 @@ module.exports = grammar({
     setting: $ => seq(
       alias(/[^#=\s\[]+/, $.setting_name),
       '=',
-      alias(/.+/, $.setting_value),
+      alias(/[^\s]+.*/, $.setting_value),
       '\n',
     ),

but if I'm reading https://github.com/textmate/ini.tmbundle/blob/7d8c7b5544c48069a246fd2f43e965f06d03d3da/Syntaxes/Ini.plist#L97 correctly, it looks like it includes whitespace?

Isn't it possible (and common) that whitespace is important in INI values ? Especially trailing whitespace.