Add support for SourcePawn (.sp files) from SourceMod
Currently there is no support for SourceMod's SourcePawn files (.sp).
For those who don't know what sourcemod is, it is basically a modding framework for Half-Life 2 Engine-Games.
There are some examples for editors we could get some inspiration for the highlightng from.
It's been a year. Can we get support for this?
@1ci We certainly welcome any community contributions. It helps to have lexers written by people familiar with the language.
here's an extension for the vs code https://github.com/Dreae/sourcepawn-vscode maybe it can help for the needs of making it
This issue has been automatically marked as stale because it has not had any activity for more than a year. It will be closed if no additional activity occurs within the next 14 days.
If you would like this issue to remain open, please reply and let us know if the issue is still reproducible.
is there any news?
@z4cH3r At this stage of its development, Rouge depends on the contributions of its users for new lexers. If you're interested in developing a lexer, we have a guide in the documentation that's a great place to start. Hope that helps!
Any updates on this?
@thanked Nobody has submitted a contribution yet.
@thanked Nobody has submitted a contribution yet.
I was interested to submit but it looks really hard, isn't there a more simple way to do it?
@thanked Unfortunately, there's an inherent complexity to lexing a text file that you can't really avoid.
One thing that might help is seeing how another highlighter (especially one similar to Rouge) does it. The syntax highlighter Pygments, which is written in Python, has a lexer for SourcePawn files. If you're finding it a bit bewildering to work out what regular expressions you need, you should be able to take the patterns from that file with minimal modification.
@pyrmont Why cannot we take the lexer file that GitHub uses for SourcePawn?
@thanked GitHub's Linguist library uses TextMate-compatible grammars. Rouge doesn't use this format but instead has a custom DSL for describing grammars (which is based on Pygments).
@pyrmont How long would it take to do a lexer for SourcePawn?
I'm not sure, @thanked. It would depend on a number of factors: whether your machine is set up for Ruby development, how much experience you have programming, your familiarity with regular expressions, etc. I'd guess at least a few of hours but it's very hard to be precise.
@pyrmont I have very little experience with regular expressions but I'll try to take some parts from the python file as you said https://github.com/rouge-ruby/rouge/issues/800#issuecomment-637599930. Where do I submit the file?
@thanked Good luck! A couple of points:
-
If you'd like to check a regular expression against some test data, I recommend Rubular.
-
You put the lexer in
lib/rouge/lexers/. I'd also recommend our development guide. -
When you've made your changes, you should submit a PR. GitHub has a guide on how to do that.
@pyrmont Thanks, I'll try my best!
Did you have any success so far @thanked ? I did also try writing a lexer for SP (years ago) but gave it up pretty quickly. This was waaay to complex for the gains.
@RAYs3T, sadly I have not procceeded to even trying. However, I was thinking about looking into the Pythons SourcePawn lexer file and try to edit it as pyrmont said in this post.
But I'm not quite sure what I'm supposed to do, sadly.
@thanked Mhh, was kinda the same for me...
@pyrmont Can you recommand any good resources which may describe the entry into writing lexers "beginners friendly"? This stuff is a lot different from normal programming.
@RAYs3T I think the development guide is a pretty beginner-friendly document. Is there something specific in that guide that you're struggling with?
Out of curiosity, for what purpose would you be using Rouge to highlight SourcePawn files? It seems rather similar to C, so you could potentially get something looking good with the C lexer.
If it's Gitlab, you can make all your sourcepawn files use C highlighting using your .gitattributes file: https://docs.gitlab.com/ee/user/project/highlighting.html
If it's Gitlab, you can make all your sourcepawn files use C highlighting using your
.gitattributesfile: https://docs.gitlab.com/ee/user/project/highlighting.html
Ah yeah that's true, we can just use C/CPP highlighting, thanks for being smarter than me
If it's Gitlab, you can make all your sourcepawn files use C highlighting using your
.gitattributesfile: https://docs.gitlab.com/ee/user/project/highlighting.htmlAh yeah that's true, we can just use C/CPP highlighting, thanks for being smarter than me
its not great though lot of stuff is just not highlighted (most of it)
github supports sourcepawn, as it uses the linguist https://github.com/github-linguist/linguist/blob/master/samples/SourcePawn/foo.sp
Wish this was added here, so we can have it highlighting on gitlab