Skip to content

Sigil heredoc support #468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2020
Merged

Conversation

J3RN
Copy link
Contributor

@J3RN J3RN commented Dec 4, 2020

The syntax highlighting for LiveView with heredocs is broken:
image

This (single character) change make the ~L sigil support heredocs:
image

Ideally I would like to apply the interpolation face inside of <% ... %>, but I'm not really sure how to approach that and this change stands on its own.

@J3RN
Copy link
Contributor Author

J3RN commented Dec 4, 2020

I just realized that triple quotes are valid for all sigils, so a "true fix" might require a different change.

iex(1)> ~c"""
...(1)> foo bar  
...(1)> """
'foo bar\n'
iex(2)> ~r"""
...(2)> foo bar 
...(2)> """
~r/foo bar\n/
iex(3)> ~W"""
...(3)> foo bar
...(3)> """
["foo", "bar"]
iex(4)> 

@axelson
Copy link
Contributor

axelson commented Dec 12, 2020

Could you add the full list of supported sigils from: https://github.com/elixir-editors/emacs-elixir/pull/454/files

It won't be perfect but I think it would be good enough for now.

@J3RN J3RN changed the title LiveView Heredoc support Sigil heredoc support Dec 14, 2020
@J3RN
Copy link
Contributor Author

J3RN commented Dec 14, 2020

@axelson Done! 😁

Copy link
Contributor

@axelson axelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! ❤️

@axelson axelson merged commit 9de08c1 into elixir-editors:master Dec 16, 2020
@@ -265,7 +265,7 @@ is used to limit the scan."
(unless (elixir-syntax-in-string-or-comment-p)
(let ((heredoc-p (save-excursion
(goto-char (match-beginning 0))
(looking-at-p "~[sS]\\(?:'''\\|\"\"\"\\)"))))
(looking-at-p "~[BCDELNRSTUbcersw]\\(?:'''\\|\"\"\"\\)"))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@axelson we should generate tests for these new sigils as it's really easy to break and not notice day-to-day.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a good point and it would be good to include tests for them

@J3RN J3RN deleted the better-liveview branch February 1, 2021 03:41
J3RN pushed a commit to J3RN/emacs-elixir that referenced this pull request Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants