Summary
Add brace matching support for sigil delimiters so that when the cursor is positioned near a sigil's opening delimiter, its matching closing delimiter is highlighted.
Elixir sigils support various delimiter pairs:
~s(...), ~r(...) - parentheses
~s[...], ~r[...] - brackets
~s{...}, ~r{...} - braces
~s<...>, ~r<...> - angle brackets
~s|...|, ~r|...| - pipes
~s/.../, ~r/.../ - slashes
~s"...", ~r"..." - double quotes
~s'...', ~r'...' - single quotes
Current Behavior
Currently, sigils are tokenized as a single EX_SIGIL token containing the entire sigil including its delimiters and content:
As a single token, there's no way to match the opening / with the closing /.
Desired Behavior
When the cursor is near a sigil's opening delimiter, the matching closing delimiter should be highlighted. For example, in ~r/pattern/, positioning the cursor at the first / should highlight the second /.
Complexity considerations:
- Symmetric delimiters (
|, /, ", ') use the same token for open and close
- Asymmetric delimiters (
(), [], {}, <>) need distinct open/close tokens
- IntelliJ-Elixir handles this with
LINE_PROMOTER/LINE_TERMINATOR tokens
Reference
IntelliJ-Elixir implementation:
- Paired.java - includes
LINE_PROMOTER/LINE_TERMINATOR pair
- The lexer uses states like
SIGIL, GROUP, etc. to track context
Acceptance Criteria
Notes
This is a larger undertaking than heredoc support due to the variety of delimiter types. Consider implementing incrementally, starting with the most common delimiters.
Summary
Add brace matching support for sigil delimiters so that when the cursor is positioned near a sigil's opening delimiter, its matching closing delimiter is highlighted.
Elixir sigils support various delimiter pairs:
~s(...),~r(...)- parentheses~s[...],~r[...]- brackets~s{...},~r{...}- braces~s<...>,~r<...>- angle brackets~s|...|,~r|...|- pipes~s/.../,~r/.../- slashes~s"...",~r"..."- double quotes~s'...',~r'...'- single quotesCurrent Behavior
Currently, sigils are tokenized as a single
EX_SIGILtoken containing the entire sigil including its delimiters and content:As a single token, there's no way to match the opening
/with the closing/.Desired Behavior
When the cursor is near a sigil's opening delimiter, the matching closing delimiter should be highlighted. For example, in
~r/pattern/, positioning the cursor at the first/should highlight the second/.Complexity considerations:
|,/,",') use the same token for open and close(),[],{},<>) need distinct open/close tokensLINE_PROMOTER/LINE_TERMINATORtokensReference
IntelliJ-Elixir implementation:
LINE_PROMOTER/LINE_TERMINATORpairSIGIL,GROUP, etc. to track contextAcceptance Criteria
()pairs[]pairs{}pairs<>pairs||pairs//pairs""pairs''pairs~s"""...""") also work (may depend on Add brace matching for heredocs #54)Notes
This is a larger undertaking than heredoc support due to the variety of delimiter types. Consider implementing incrementally, starting with the most common delimiters.