Complete the initial LSH implementation#624
Conversation
|
looking forward to the other languages. they seemed to work well enough in https://github.com/microsoft/edit/tree/4f36e2afe2a84ed339829ea6c63242fb9f4b7de3 (well, really long Here Strings made the rest of the file red, but ones with a reasonable length were fine) |
|
PR awaiting 2 pending checks still. |
|
Working on this feature? In the current economy?! |
|
Thanks for your work on this. I've played around with this branch a bit and want to share my thoughts on the current implementation. I tried to hack together basic C highlighting and noticed there is some state missing for "constants" (convention with all-uppercase variables usually defined with Could the regexes be loaded from a file in the future? It might save some work to implement the basic functionality now by parsing a hardcoded string rather than defining everything in Another thing I wondered about is why the Edit: |
|
FYI I've continued development in the https://github.com/microsoft/edit/tree/dev/lhecker/syntax-highlighting-alt branch where I've since written a custom language with proper compiler. It even has rudimentary support for variables. It's fairly time consuming to develop so it's taking a while. It's also certainly not done yet, but please feel free to check it out already. You can find the definition files under |
|
Why not tree-sitter integration for syntax highlighting and text objects ? You basically get for "free" countless languages. (implementation not considered) |
FWIW, this has been hashed out over in #18. In fact, the justification for having a simple syntax highlighter that is expressly not tree-sitter is described in the issue body of #18. TL;DR (and it really is not much longer than this comment here): tree-sitter is huge. Edit is 250KiB. We don't want edit to become much larger than it already is. |
33890d3 to
3f386a9
Compare
|
Well, so this ain't a "draft for syntax highlighting" anymore by any measure. This PR is now 7000 lines and contains an entire frigging compiler lol. (...which btw is extremely poorly engineered. 😭😭) To anyone who reads this: Have fun testing this! Definitions are in |
|
Hi, I've been experimenting with this and managed to get a basic #[display_name = "Markdown"]
#[path = "**/*.md"]
#[path = "**/*.markdown"]
pub fn markdown() {
// Headers
if /#+ .*/ {
yield keyword;
}
// Bold
if /\*\*[^*]*\*\*/ {
yield string;
}
// Links
if /\[[^\]]*\]\([^)]*\)/ {
yield function;
}
} |
|
I'm glad you had a chance to try it out! I'll try to simplify the syntax in the future. Did you try my markdown.lsh version? It's included in this PR: https://github.com/microsoft/edit/blob/cb98cf5b0fe6a5e192f37e82ef3716cd9a63db7f/crates/lsh/definitions/markdown.lsh |
|
oh, I totally missed that, my bad. I was on the compiler branch the whole time! |
This PR contains no CLI frontend, etc., for the compiler, as I split out everything but the compiler to reduce the PR size. Part of #624
This integrates the LSH compiler and runtime into edit. Part of #624
463097d to
2fc81f5
Compare
| double_quote_string(); | ||
| } else if /true|false|null/ { | ||
| if /\w+/ { | ||
| // Not a keyword after all. |
There was a problem hiding this comment.
in JSON would this be an error token?
There was a problem hiding this comment.
do we have a token type for "this is obviously incorrect"
There was a problem hiding this comment.
Not yet, no. I didn't add that, because VS Code doesn't do anything special either. In an ideal world, Edit would get LSP support in the future which would significantly improve this.
|
make sure you update the description! |
DHowett
left a comment
There was a problem hiding this comment.
The powershell one seems somewhat broken, and yaml has some minor bugs, but I think this is a good place to start iterating.
|
Not familiar with "LSH", and I'm not building it myself, so I didn't try it out. Could it please be clarified whether the syntax schemes and/or the color themes are embedded into the binary? or as external files? And if external files, where could a collection of such files be found? Thanks. |
|
First off: This is the first (!) version of the simple (!) syntax highlighter. You cannot expect this to be feature complete. Alright...
They're embedded and not configurable. I will release v2.0.0 without it being configurable, because I expect v3.0.0 to be all about configurability anyway.
Hence, no external files. It's still a single binary.
Yes. The source code gets translated to the VM bytecode at compile time. The compiler is fairly poorly written for my standards, and I do not want it to process possibly untrusted, dangerous .lsh files. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@3052 If you'd like to further discuss this, create a "Discussion" and I'll respond there. We maintainers will not respond on this issue anymore. And because I am the primary maintainer, I'll also take my right to collapse all prior comments above, because I'm trying to focus on drafting the preview release and this is distracting. |


Previous commits have added all of the infinity stones.
This one introduces the remaining, more complex .lsh files.
Closes #18