Closed carlosvneves closed 2 months ago
I am sorry that I couldn't reply earlier. Thank you for the review!
I think the textmate grammar needs some work, but it's alright for now. I might continue to work on it myself since I know C3's grammar very well by now.
I am new to this and I wanted to help. I hope I really can learn from the more experienced.
I made the fixes, except in the example.c3
(as in the comment above).
Please, let me know when you think the code is ready. Then I will push the updated code.
No worries.
Implementing good highlighting is tricky and takes a while, because it takes knowledge of the highlighting mechanism (TextMate in this case), regular expressions and the language grammar. The latter is where you need more experience with C3 to notice some issues. For example, block comments can be nested, macro parameters can start with #
, there's no raw string literal, no attribute highlighting, some brace types are missing etc. Copying from C doesn't do the trick here, for instance there are more type suffixes other than *
.
But don't worry about that stuff, I already went through the process twice with tree-sitter and Sublime Text syntax, so I'm gonna fix this one up too in the coming weeks. Plus I can copy a bunch of regular expressions from the Sublime syntax and make sure highlighting is kept relatively consistent between editors.
Another thing I noticed, can you please go through snippets.json
and make sure these are valid constructs that actually compile? I noticed case
and case-else
are not valid. Thanks!
Implementing good highlighting is tricky and takes a while, because it takes knowledge of the highlighting mechanism (TextMate in this case), regular expressions and the language grammar. The latter is where you need more experience with C3 to notice some issues. For example, block comments can be nested, macro parameters can start with
#
, there's no raw string literal, no attribute highlighting, some brace types are missing etc. Copying from C doesn't do the trick here, for instance there are more type suffixes other than*
Yeah, thanks for your patience. I think I was a "little bit ambitious" for my first PR. Was my first time on developing vscode extension and syntax-highlight. And I am very new to the C3 language. I became interested after TSoding's videos and I am very excited. It's a very nice concept and the community is awesome.
I tried to read the docs and understand all the snippets. But you are right about the lack of experience. I took zig, C and other extensions to see how I could implement some of the features I missed, and others that I saw people asking for.
But don't worry about that stuff, I already went through the process twice with tree-sitter and Sublime Text syntax, so I'm gonna fix this one up too in the coming weeks. Plus I can copy a bunch of regular expressions from the Sublime syntax and make sure highlighting is kept relatively consistent between editors.
Since you have all that experience, I am sure you can make great improvements. It is a great idea try to make it consistent between editors. Please, feel free to take what is worth from the code. I really hope it can helps :)
Another thing I noticed, can you please go through
snippets.json
and make sure these are valid constructs that actually compile? I noticedcase
andcase-else
are not valid. Thanks!
Sure, I can review the snippets. As I said earlier, I took some examples from other plugins. I thought that I changed the snippets accordingly, but I missed some. I will fix it and maybe add others that can be useful. I was thinking about the snippets as a way to help the beginners (like myself) to get some help with the C3 syntax. So, if you remember anything that it is worth to add, please let me know.
Finally, as you will make improvements, how would be the best way for me to work on the fixes? I mean, we let this PR opened and I make de the fixes you suggest in my fork, and then we merge with your improvements later before the merge in the main repo? I'm sorry if it is a silly question, but I think it was important to ask anyway.
Thanks again!
Development continues here, based off this PR and my syntax highlighting: https://github.com/c3lang/vscode-c3
This PR proposes enhancements to the C3 VS Code extension
The main adjustments include:
Function and Method Calls:
malloc()
,free()
).object.method()
).Variable and Struct Member:
&self
andObject*
).Contract Comments:
/** */
).@require
,@ensure
,@param
).[in]
,[out]
,$function
).Code snippets:
Support for LSP:
Other minor changes:
.vsix
file to the repo.Testing:
IMPORTANT:
extension.js
file. As discussed on Discord, the idea here is to try to unify the extensions (if is ok for everyone, specially when thinking about authorship and things like that).Feedback is welcome.
Note: This PR replaces the one that I made 2 days ago (by mistake). Thanks to Christoffer Lerno for pointing out what was wrong.