rouge icon indicating copy to clipboard operation
rouge copied to clipboard

Add support for SourcePawn (.sp files) from SourceMod

Open RAYs3T opened this issue 8 years ago • 25 comments

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.

RAYs3T avatar Oct 09 '17 16:10 RAYs3T

It's been a year. Can we get support for this?

1ci avatar Nov 18 '18 13:11 1ci

@1ci We certainly welcome any community contributions. It helps to have lexers written by people familiar with the language.

dblessing avatar Nov 19 '18 17:11 dblessing

here's an extension for the vs code https://github.com/Dreae/sourcepawn-vscode maybe it can help for the needs of making it

z4cH3r avatar Dec 09 '18 01:12 z4cH3r

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.

stale[bot] avatar Dec 09 '19 02:12 stale[bot]

is there any news?

z4cH3r avatar Dec 21 '19 06:12 z4cH3r

@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!

pyrmont avatar Dec 21 '19 23:12 pyrmont

Any updates on this?

isakjensen avatar Jun 02 '20 10:06 isakjensen

@thanked Nobody has submitted a contribution yet.

pyrmont avatar Jun 02 '20 10:06 pyrmont

@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?

isakjensen avatar Jun 02 '20 12:06 isakjensen

@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 avatar Jun 02 '20 15:06 pyrmont

@pyrmont Why cannot we take the lexer file that GitHub uses for SourcePawn?

isakjensen avatar Jun 02 '20 19:06 isakjensen

@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 avatar Jun 02 '20 19:06 pyrmont

@pyrmont How long would it take to do a lexer for SourcePawn?

isakjensen avatar Jun 03 '20 08:06 isakjensen

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 avatar Jun 03 '20 09:06 pyrmont

@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?

isakjensen avatar Jun 03 '20 09:06 isakjensen

@thanked Good luck! A couple of points:

  1. If you'd like to check a regular expression against some test data, I recommend Rubular.

  2. You put the lexer in lib/rouge/lexers/. I'd also recommend our development guide.

  3. When you've made your changes, you should submit a PR. GitHub has a guide on how to do that.

pyrmont avatar Jun 03 '20 09:06 pyrmont

@pyrmont Thanks, I'll try my best!

isakjensen avatar Jun 03 '20 09:06 isakjensen

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 avatar Jun 15 '20 08:06 RAYs3T

@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.

isakjensen avatar Jun 15 '20 08:06 isakjensen

@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 avatar Jun 15 '20 08:06 RAYs3T

@RAYs3T I think the development guide is a pretty beginner-friendly document. Is there something specific in that guide that you're struggling with?

pyrmont avatar Jun 19 '20 02:06 pyrmont

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.

jneen avatar Jun 19 '20 04:06 jneen

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

jneen avatar Jun 19 '20 04:06 jneen

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

Ah yeah that's true, we can just use C/CPP highlighting, thanks for being smarter than me

isakjensen avatar Jun 21 '20 19:06 isakjensen

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

Ah 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

Neoony avatar Aug 05 '24 17:08 Neoony