From 07a95ec697f302c92c9d932b560f8a284ec268e9 Mon Sep 17 00:00:00 2001 From: steven nguyen Date: Sun, 2 May 2021 11:26:49 -0500 Subject: [PATCH 1/3] tree-sitter comment folds --- grammars/tree-sitter-python.cson | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/grammars/tree-sitter-python.cson b/grammars/tree-sitter-python.cson index 4490d74..4637e5b 100644 --- a/grammars/tree-sitter-python.cson +++ b/grammars/tree-sitter-python.cson @@ -56,6 +56,16 @@ folds: [ { start: {type: '{', index: 0} end: {type: '}', index: -1} + }, + { + type: 'comment' + start: {type: '"\"\"\""', index: 0} + end: {type: '"\"\"\""', index: -1} + }, + { + type: 'comment' + start: {type: '"\'\'\'"', index: 0} + end: {type: '"\'\'\'"', index: -1} } ] From c1bc59f09360f091befe1eab22a6095bd1a1dabc Mon Sep 17 00:00:00 2001 From: steven nguyen Date: Sun, 2 May 2021 11:33:41 -0500 Subject: [PATCH 2/3] Oops, multiline comments are strings --- grammars/tree-sitter-python.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/tree-sitter-python.cson b/grammars/tree-sitter-python.cson index 4637e5b..22a45f5 100644 --- a/grammars/tree-sitter-python.cson +++ b/grammars/tree-sitter-python.cson @@ -58,12 +58,12 @@ folds: [ end: {type: '}', index: -1} }, { - type: 'comment' + type: 'string' start: {type: '"\"\"\""', index: 0} end: {type: '"\"\"\""', index: -1} }, { - type: 'comment' + type: 'string' start: {type: '"\'\'\'"', index: 0} end: {type: '"\'\'\'"', index: -1} } From 70bae2e4daacb8b1da60d183dd32b853dc36854e Mon Sep 17 00:00:00 2001 From: steven nguyen Date: Sun, 2 May 2021 12:15:24 -0500 Subject: [PATCH 3/3] fix escaping the single quote string matches ', so we need to add an additional escaped backslash: \' with \\\' the double quote string matches ", same thing. But we don't need to escape the quote, only the backslash: \" with \\" --- grammars/tree-sitter-python.cson | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grammars/tree-sitter-python.cson b/grammars/tree-sitter-python.cson index 22a45f5..09dea81 100644 --- a/grammars/tree-sitter-python.cson +++ b/grammars/tree-sitter-python.cson @@ -59,13 +59,13 @@ folds: [ }, { type: 'string' - start: {type: '"\"\"\""', index: 0} - end: {type: '"\"\"\""', index: -1} + start: {type: '"\\"\\"\\""', index: 0} + end: {type: '"\\"\\"\\""', index: -1} }, { type: 'string' - start: {type: '"\'\'\'"', index: 0} - end: {type: '"\'\'\'"', index: -1} + start: {type: '"\\\'\\\'\\\'"', index: 0} + end: {type: '"\\\'\\\'\\\'"', index: -1} } ]