gleam-lang / tree-sitter-gleam

🌳 A tree-sitter grammar for the Gleam programming language
Apache License 2.0
71 stars 13 forks source link

Add child nodes for the contents of a string? #12

Closed connorlay closed 2 years ago

connorlay commented 2 years ago

Howdy! As you know, I am working on integrating this grammar with neovim https://github.com/J3RN/tree-sitter-gleam/issues/1, during which I realized there is no node for string escape sequences. Without this node, I cannot highlight escape sequences similar to what I did with the nvim-treesitter Elixir highlight queries.

For example, tree-sitter-elixir parses:

"foo\nbar"

as the following tree of nodes:

(string
  quoted_start: """
  (quoted_content)
  (escape_sequence)
  (quoted_content)
  quoted_end: """)

I'm curious what you think!

J3RN commented 2 years ago

This is an interesting idea. We will, likely, eventually, have to do more string introspection seeing as string interpolation is planned, so this seems like a reasonable place to start. I'll probably not have time to look at this until the weekend, so you're welcome to give it a go if you'll have time sooner :grin: