Skip to content
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

Add Raku (Perl 6) filetype support (lexer and ctags parser) #3169

Merged
merged 4 commits into from Mar 19, 2024

Conversation

techee
Copy link
Member

@techee techee commented Apr 14, 2022

Note: I have never used Perl 6 (and did my best to avoid Perl) so I largely don't know what I'm doing. There just are several open issues requesting this language and I believe Geany should support it. And even if this PR isn't perfect, it should be much easier for real Raku users to improve it once this PR is in (e.g. by providing better keywords or highlighting).

I based the keyword list on

https://github.com/Raku/vim-raku/blob/master/syntax/raku.vim

and also fixed one lexilla bug here

ScintillaOrg/lexilla#76

Fixes #3054, fixes #3053, fixes #2456.

@techee
Copy link
Member Author

techee commented Apr 15, 2022

@kugel- I added a patch updating HACKING with some changes related to adding a lexer and also mentioning updates to meson.build. Would you have a look if the changes look good to you?

@kugel-
Copy link
Member

kugel- commented Apr 15, 2022

Speaking only for HACKING it seems alright

@techee
Copy link
Member Author

techee commented Apr 24, 2022

I just repushed with all the keyword groups and keywords from Scintilla.

@elextr
Copy link
Member

elextr commented Sep 5, 2022

No Rakuist has tested in the time this has been here, maybe its not worth adding.

@rdipardo
Copy link
Contributor

rdipardo commented Sep 6, 2022

No Rakuist has tested in the time this has been here

One way to promote user participation might be configuring the CI workflow to pack a binary tarball and save it with the upload-artifact action.

Not that Geany users need coddling, but source builds really are problematic when the make install step could clobber your system's editor, and hacking the LD_LIBRARY_PATH is not advisable (although I've found it does work in a pinch).

@elextr
Copy link
Member

elextr commented Sep 6, 2022

CI workflow to pack a binary tarball and save it with the upload-artifact action.

The problem with this is "for what system"? All the Linuxes have their own quirks, and most distros have their own patches for Geany to meet their requirements. Somewhat ironically Windows and Macos are more consistent, although (IIUC) both have occasional forward/backward compatibility lapses and are somewhat harder to build for.

Making a source tarball is more likely portable, but its not really much less work for the user than using the git repo.

but source builds really are problematic when the make install step could clobber your system's editor

On Linux its actually quite easy to build a fully isolated copy of Geany from git that can't clobber the system install (because its installed without privileges). I did once try to add the instructions to README or INSTALL (can't remember which) but it was sabotaged by other devs who kept adding more options and insisting it should not be in tree etc etc, so it was abandoned as it ended up no simpler.

Assuming you have installed the required tools (eg on Debuntu build-essential, git, libgtk-3-dev, autoconf and all its recommends and suggests). Many Geany users being developers will have at least some of these installed already.

In your home

mkdir git-geany; cd git-geany
git clone https://github.com/geany/geany.git
cd geany
./autogen.sh --prefix=/the/full/absolute/path/to/git-geany --disable-html-docs
make install
cd ../bin; ./geany -c ../config

Any time you cd to git-geany/geany you can follow (copy and paste) the command line instructions to checkout and test the PR on github and make installing again. Each PR is in its own branch so they don't interfere. So you can test lots of PRs!!!!! :-)

When you are finished or something breaks your repository (damn force pushes) just delete the whole git-geany tree, I find its faster to re-clone something as small as Geany than it is to fix broken git repos.

hacking the LD_LIBRARY_PATH is not advisable

correct.

@techee
Copy link
Member Author

techee commented Sep 6, 2022

No Rakuist has tested in the time this has been here, maybe its not worth adding.

Well, even though I'm not a big fan of anything perl-related, I think Geany should support Raku. We have 3 open issues related to this language so people seem to be interested in it and I think it's a relatively common language (compared to some rather esoteric languages that Geany supports) and shouldn't be omitted.

This patch does the "hard work" (especially for someone who knows only scripting languages and has no experience with Geany hacking) and even if e.g. the keyword selection isn't perfect, once the support is in, any subsequent improvement should be much easier for Raku users.

@eht16
Copy link
Member

eht16 commented Sep 11, 2022

Agree with @techee and I could give it a bit of testing, though this might takes a few weeks.
But my Perl is also as low as I managed to keep it.

@techee
Copy link
Member Author

techee commented Oct 8, 2023

So I guess this PR will have to wait for the next release, right? I'm a bit sad about that because Perl 6 was requested several times and this PR was waiting for a year and a half for merging but I guess it's too late now...

Should I extract the changes from HACKING to a separate PR? It contains the most up-to-date info about how to add ctags parsers and Scintilla lexers.

@b4n
Copy link
Member

b4n commented Oct 8, 2023

@techee yeah I'd think it's wiser to wait, but probably get it in soon after. And yeah, HACKING changes are probably useful nonetheless.

@techee
Copy link
Member Author

techee commented Oct 9, 2023

OK, I removed the 2.0 milestone from this PR and posted the HACKING update separately in #3586.

@elextr
Copy link
Member

elextr commented Oct 24, 2023

@eht16 if you can test this thats great, its the main thing missing which delayed it until it was too late for release. Since @techee has guaranteed he will support all these new languages lets take advantage of it 😄

@eht16
Copy link
Member

eht16 commented Mar 17, 2024

Agree with @techee and I could give it a bit of testing, though this might takes a few weeks.

s/few weeks/few years/ but we are all patient :).

I gave it some testing and it works fine. I want to repeat I'm really bad at Perl and saw Raku the first time now. Btw, I did not fell in love with it :D.

The perl6.c parser is taken from uctags, I assume. If so, we probably should to rename it as it was done in universal-ctags/ctags#3777.

Geany detects https://github.com/Raku/examples/blob/master/categories/games/blackjack.p6 as Perl even the file extension tells Raku. This is because of the shebang in the file. The following change should solve it by first checking for "perl6" and only then "perl".

@@ -604,6 +605,7 @@ static GeanyFiletype *find_shebang(const gchar *utf8_filename, const gchar *line
                        { "sh",         GEANY_FILETYPES_SH },
                        { "bash",       GEANY_FILETYPES_SH },
                        { "dash",       GEANY_FILETYPES_SH },
+                       { "perl6",      GEANY_FILETYPES_RAKU },
                        { "perl",       GEANY_FILETYPES_PERL },
                        { "python",     GEANY_FILETYPES_PYTHON },
                        { "php",        GEANY_FILETYPES_PHP },

@techee
Copy link
Member Author

techee commented Mar 17, 2024

I gave it some testing and it works fine. I want to repeat I'm really bad at Perl and saw Raku the first time now. Btw, I did not fell in love with it :D.

Good, I was worried we'd have to rewrite Geany in it :-)

The perl6.c parser is taken from uctags, I assume. If so, we probably should to rename it as it was done in universal-ctags/ctags#3777.

I'm aware of that, I was just thinking it could be done during the next "ctags sync" if it's not a problem.

Geany detects https://github.com/Raku/examples/blob/master/categories/games/blackjack.p6 as Perl even the file extension tells Raku. This is because of the shebang in the file.

I totally missed that one, thanks! I've just made a fixup commit with the proposed fix.

Is anything else missing? If there are no other problems, I'd like to merge this PR so we are finally done with it.

Copy link
Member

@b4n b4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clue about Rakut, but looks pretty good (as expected), minor comments/questions inline.

data/filedefs/filetypes.raku Show resolved Hide resolved
src/highlightingmappings.h Show resolved Hide resolved
src/filetypes.c Show resolved Hide resolved
@eht16
Copy link
Member

eht16 commented Mar 18, 2024 via email

Copy link
Member

@b4n b4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have no clue about Raku, but LGTM and works as far as super-basic testing goes.

@b4n
Copy link
Member

b4n commented Mar 19, 2024

Maybe I'll change my mind in two weeks, what about Reany?

Sounds like Geany written in R, doesn't it? :)

I'm not gonna suggest Geary… 😆

@elextr
Copy link
Member

elextr commented Mar 19, 2024

Maybe I'll change my mind in two weeks, what about Reany?

Sounds like Geany written in R, doesn't it? :)

Surely he means Racket, its lisp (well Scheme, but similar) and it has its own portable native GUI library built in, no more GTK on windows issues .. hmm I just might convince myself at this rate :-)

@eht16
Copy link
Member

eht16 commented Mar 19, 2024 via email

@techee techee merged commit 847dc92 into geany:master Mar 19, 2024
7 checks passed
@techee
Copy link
Member Author

techee commented Mar 19, 2024

Meh, I forgot how github handles fixup commits and kind of assumed they get auto-squashed when merging a PR (which didn't happen). So there's a slight mess as the fixup commits were preserved. Sorry for that.

@elextr
Copy link
Member

elextr commented Mar 19, 2024

The dropdown to the right of the big green button has a squash and merge option.

@b4n b4n added this to the 2.1 milestone Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants