Skip to content

Add brace matching for heredocs #54

@mkaput

Description

@mkaput

Summary

Add brace matching support for heredoc delimiters ("""...""" and '''...''') so that when the cursor is positioned near a heredoc delimiter, its matching pair is highlighted.

Current Behavior

Currently, heredocs are tokenized as single tokens (EX_HEREDOC and EX_CHARLIST_HEREDOC) containing the entire heredoc content. This means the lexer produces:

EX_HEREDOC: """
  multiline
  content
"""

As a single token, there's no way to match the opening """ with the closing """.

Desired Behavior

When the cursor is near an opening """ or ''', the matching closing delimiter should be highlighted, similar to how do...end and fn...end work.

Reference

IntelliJ-Elixir implements this with HEREDOC_PROMOTER and HEREDOC_TERMINATOR tokens:

Acceptance Criteria

  • Opening """ matches closing """
  • Opening ''' matches closing '''
  • Heredoc content is still properly highlighted as string
  • Parser tests continue to pass
  • Syntax highlighting continues to work correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions