-
Notifications
You must be signed in to change notification settings - Fork 107
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
VSCode does not recognize heredocs as markdown, and highlight/lint appropriately #315
Comments
I pulled down elixir-ls locally and built, and tried changing the name of some of the moduledoc patterns in elixir.json to |
This can be achieved with an injection grammar |
make markdown an embedded language Addresses #315
With the changes from 9b7f43d docstrings are now recognized as markdown. |
I had to partially revert 9b7f43d in 3e5c623. I couldn't find a workaround. Probably to handle it correctly we need a dedicated grammar for markdown heredocs. A good starting point would be forking https://github.com/microsoft/vscode-markdown-tm-grammar |
It seems that dedicated grammar is indeed needed as one could interpolate elixir code into docstrings, i.e. defmodule A do
alias Smth.Smth
@moduledoc """
Module description....
Does smth with `#{inspect Smth}`
"""
end |
@lukaszsamson this should be fixable by using a while pattern: diff --git a/syntaxes/elixir.json b/syntaxes/elixir.json
index 0e246ba..775118e 100644
--- a/syntaxes/elixir.json
+++ b/syntaxes/elixir.json
@@ -41,7 +41,11 @@
"include": "#escaped_char"
},
{
- "include": "text.html.markdown"
+ "begin": ".*",
+ "while": "(^|\\G)(?!\\s*\"\"\"\\s*$)",
+ "patterns": [
+ { "include": "text.html.markdown" }
+ ]
}
]
},
@@ -58,7 +62,11 @@
"include": "#escaped_char"
},
{
- "include": "text.html.markdown"
+ "begin": ".*",
+ "while": "(^|\\G)(?!\\s*'''\\s*$)",
+ "patterns": [
+ { "include": "text.html.markdown" }
+ ]
}
]
},
@@ -72,7 +80,11 @@
"include": "#escaped_char"
},
{
- "include": "text.html.markdown"
+ "begin": ".*",
+ "while": "(^|\\G)(?!\\s*\"\"\"\\s*$)",
+ "patterns": [
+ { "include": "text.html.markdown" }
+ ]
}
]
},
@@ -86,7 +98,11 @@
"include": "#escaped_char"
},
{
- "include": "text.html.markdown"
+ "begin": ".*",
+ "while": "(^|\\G)(?!\\s*'''\\s*$)",
+ "patterns": [
+ { "include": "text.html.markdown" }
+ ]
}
]
}, |
Nice. I'll give it a try |
Is this the right repo?
I believe this is the right repo, as the issue, as the issue I'm observing is related to syntax highlighting in VSCode.
Environment
Elixir 1.12.0 (compiled with Erlang/OTP 23)
Troubleshooting
.elixir_ls
directory, then restart your editorCrash report template
No Crash
Description
When working in elixir files with
@moduledoc
and@doc
attributes, they are not recognized as markdown. VSCode doesn't lint them appropriately, and there's no obvious way to provide appropriate previews of the files.I'm not sure if this is a new feature, or a bug.
I've reviewed some of the code that appears to define this. I suspect this is defined in:
https://github.com/elixir-lsp/vscode-elixir-ls/blob/master/elixir-language-configuration.json
and
https://github.com/elixir-lsp/vscode-elixir-ls/blob/master/syntaxes/elixir.json
However, I'm quite uninitiated here, so I don't know what I'm looking at. There appear to be some accomodations for
@moduledoc
and@doc
attributes, but I'm not sure if they are correct.The text was updated successfully, but these errors were encountered: