scopatz / nanorc

Improved Nano Syntax Highlighting Files
Other
3k stars 549 forks source link

elixir string interpolation is getting highlighted as comments #340

Open ioistired opened 3 years ago

ioistired commented 3 years ago

As is, string interpolation is not being highlighted at all:

Putting the comment definition before the strings definition helps, but it still treats the rest of the line, after the #{}, as a comment:

image

What to do?

davidhcefx commented 4 months ago

Probably a bit late, but here's a solution:

  1. For comments, # should not be followed by a { and there should be at least one blank before #.
  2. Change the color of expression substitution to normal (white)
diff --git a/elixir.nanorc b/elixir.nanorc
--- a/elixir.nanorc
+++ b/elixir.nanorc
@@ -29,16 +29,16 @@ color brightmagenta "~[a-z]\/([^\/])*\/[a-z]*" "~[a-z]\|([^\|])*\|[a-z]*" "~[a-z
 ## Strings, double-quoted
 color green ""([^"]|(\\"))*""

-## Expression substitution.  These go inside double-quoted strings,
-## "like #{this}".
-color brightgreen "#\{[^}]*\}"
-
 ## Strings, single-quoted
 color green "'([^']|(\\'))*'"

+## Expression substitution.  These go inside double-quoted strings,
+## "like #{this}".
+color normal "#\{[^}]*\}"
+
 ## Comments
-color cyan "#.*$" "#$"
-color brightcyan "##.*$" "##$"
+color cyan "(^|[[:space:]])#([^{].*|)$"
+color brightcyan "(^|[[:space:]])##.*$"

image