Skip to content
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

Highlighting issue with quoted string literal #18

Open
Alizter opened this issue Mar 13, 2023 · 3 comments
Open

Highlighting issue with quoted string literal #18

Alizter opened this issue Mar 13, 2023 · 3 comments

Comments

@Alizter
Copy link

Alizter commented Mar 13, 2023

Describe the bug

The following OCaml code causes a highlighting leak:

 let man =
    [ `S "DESCRIPTION"
    ; `P
        {|$(b,dune fmt) runs the formatter on the source code. The formatter is automatically selected. ocamlformat is used to format OCaml source code (*.ml and *.mli files) and refmt is used to format Reason source code (*.re and *.rei files).|}
    ; `Blocks Common.help_secs
    ]

image

Expected behaviour

The string escape characters {| |} shouldn't be interfered by a following $.

Related discussion

Additional notes

@Alhadis
Copy link

Alhadis commented Mar 16, 2023

The string escape characters {| |} shouldn't be interfered by a following $.

The $ doesn't appear to be causing the issue. From a cursory glance of the grammar, there doesn't appear to be a rule that matches {| |} constructs (I'm guessing it's a more recent feature of OCaml?) Assuming that the intended effect is for |…| to highlight its contents as a verbatim string (à la, Python's r"…" syntax), then I recommend adding something to the effect of the following diff:

ocaml.tmbundle.1.diff
diff --git a/Syntaxes/OCaml.plist b/Syntaxes/OCaml.plist
index c28d2ed..6fbc203 100644
--- a/Syntaxes/OCaml.plist
+++ b/Syntaxes/OCaml.plist
@@ -17,6 +17,27 @@
 	<string>OCaml</string>
 	<key>patterns</key>
 	<array>
+		<dict>
+			<key>name</key><string>string.interpolated.ocaml</string>
+			<key>begin</key><string>\\|</string>
+			<key>end</key><string>\\|</string>
+			<key>beginCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.string.begin.ocaml</string>
+				</dict>
+			</dict>
+			<key>endCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.string.end.ocaml</string>
+				</dict>
+			</dict>
+		</dict>
 		<dict>
 			<key>captures</key>
 			<dict>

(I don't know a single thing about OCaml, and it probably shows…)

@Alizter
Copy link
Author

Alizter commented Mar 17, 2023

@Alhadis Yes that is exactly it!

@Alizter
Copy link
Author

Alizter commented Mar 18, 2023

In fact, there are some pull requests implementing this already: https://github.com/textmate/ocaml.tmbundle/pull/17/files

It's just that the activity on this repo is non-existent.

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

No branches or pull requests

2 participants