resolves #434 You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/2584
-- Commit Summary --
* Create julia lexer, no ctags
-- File Changes --
M data/Makefile.am (1) M data/filedefs/filetypes.common (4) A data/filedefs/filetypes.julia (62) M scintilla/Makefile.am (1) M scintilla/include/SciLexer.h (14) M scintilla/include/Scintilla.iface (16) A scintilla/lexers/LexJulia.cxx (536) M scintilla/src/Catalogue.cxx (1) M src/filetypes.c (1) M src/filetypes.h (1) M src/highlighting.c (10) M src/highlightingmappings.h (32)
-- Patch Links --
https://github.com/geany/geany/pull/2584.patch https://github.com/geany/geany/pull/2584.diff
@getzze pushed 1 commit.
dca3d8510deca3853fedb7246f179f9b151cda67 Add julia tag parser
I didn't review the code, just an early note: the Scintilla lexer should be first submitted to and accepted by the Scintilla project (https://www.scintilla.org/). Also the Ctags parser should be first submitted to and accepted by the Universal Ctags project (https://github.com/universal-ctags/ctags). See also https://github.com/universal-ctags/ctags/issues/1566#issuecomment-515902669 where someone also started a parser.
We want to stay inline with the upstream projects and so the code should be accepted there first.
Ok, thanks. They will need to be tested by julia+geany users first anyway.
They will need to be tested by julia+geany users first anyway.
And a reminder to those who test it to comment, that lets @getzze know its working (or what needs fixing :) and it lets Geany project devs know there is a demand.
@getzze pushed 2 commits.
8aa74a74596c6752c1d74f75a47071297f0d042a parse symbols and string literals 3539be4796fccb277f7717f07ec0407e50ee746c ctag: multiline strings
@getzze pushed 2 commits.
59712ae8d4f06e39711847301044beae932ab83b lexer cleanup f1da05e2bf5380b1bb1d853647420365c889ccab ctag: parse short functions
@getzze pushed 1 commit.
eb9ac1e4fdcb79a0e4798084540a2e44487eff93 lexer: bug transpose in interpolation
@getzze pushed 1 commit.
bb7fc603c1c540caac0e007d9714f5d144483586 ctags: better parse functions. add type parsing
@getzze pushed 2 commits.
0f25715f88764a1acc074aec071935f128560c9d ctags: rewrite based on rust 6cd8cd33b39a1ec6e9a2d9ccdc0c56a8f47a7c84 lexer: bugs with strings
Upstream merge: - [ ] Scintilla Merge Request: https://sourceforge.net/p/scintilla/code/merge-requests/25/ - [ ] Universal-ctags PR: https://github.com/universal-ctags/ctags/pull/2654
Upstream merge: - [ ] Scintilla: https://sourceforge.net/p/scintilla/code/merge-requests/25/ - [ ] Universal-ctags: https://github.com/universal-ctags/ctags/pull/2654
@getzze pushed 5 commits.
00dba4526aa0b8ea16c5d26f38402e21ca7e9358 lexer: add unicode support identifiers 4a4cc382ddc25ee64e91a7313f6465c6ec567937 ctags: add backtick recognition c544769be5047a6833b02f825c4fe5aec29b9055 lexer: add backtick recognition c255b2c68728fb014c5e53bc3de7dadaa0001415 merge from ctags 7f69aebeec9b4089fb122867ab0e25db94e8f66d update lexer
@getzze pushed 1 commit.
252509e30858bc41ac06686ac9d156eec2265b6b solve conflicts
Thanks for your efforts so far @getzze. I'd be happy to see this merged. I wanted to test, but have trouble building the branch `julia_lexxer` in a standard Kubuntu 20.04 environment (gcc 9.3.0): ``` CXX lexers/LexMake.lo lexers/LexJulia.cxx: In static member function ‘static Scintilla::ILexer* LexerJulia::LexerFactoryJulia()’: lexers/LexJulia.cxx:123:25: error: invalid new-expression of abstract class type ‘LexerJulia’ 123 | return new LexerJulia(); | ^ lexers/LexJulia.cxx:90:7: note: because the following virtual functions are pure within ‘LexerJulia’: 90 | class LexerJulia : public DefaultLexer { | ^~~~~~~~~~ In file included from lexers/LexJulia.cxx:25: ./include/ILexer.h:92:34: note: ‘virtual const char* Scintilla::ILexerWithIdentity::PropertyGet(const char*)’ 92 | virtual const char * SCI_METHOD PropertyGet(const char *key) = 0; | ^~~~~~~~~~~ CXX lexers/LexMarkdown.lo ```
@getzze pushed 1 commit.
d3ec25d5be98e4b0a6e72d19a0ea8752eccee141 missing constructor LexerJulia
Thanks for testing it, I commited a correction, you should be able to compile it now. Happy to hear your feedback.
Thanks, that fixed it. Looking pretty good already. I will continue to test this in the coming days and report back.
Two points I noticed instantly: 1) Highlighting interpolated strings seems inconsistent: Depending on using `$(var)` vs `$var` and single quote vs triple quote strings, I see different colors. Example: `"($scanPosX,$scanPosY): (k±Δk)=$(kLaserApprox) $(begin x+5 end)"` `"""($scanPosX,$scanPosY): (k±Δk)=$(kLaserApprox) $(begin x+5 end)"""`
2) Macros confuse the lexer (possibly we have to live with that, since macros can have arbitrary syntax) Example: ``` Base.@kwdef struct A a::Float64 = 1E-19 b::Float64 = 1E-22 end ``` shows that the struct contains Symbols `E`
@elextr @getzze I have not discovered any further issues. If more testers or feedback on the level of demand is required, I suggest announcing this on [https://discourse.julialang.org/%5D(https://discourse.julialang.org/).
@AndiMD thats entirely up to @getzze, remember no Geany devs are Juliaists, so they have no knowledge or need to support this.
Also the failing CI needs fixing.
@AndiMD Thanks for reporting these problems! I think it would be great to announce it on Julia discourse.
1. Highlighting interpolated strings seems inconsistent: Depending on using `$(var)` vs `$var` and single quote vs triple quote strings, I see different results. Example: `"($scanPosX,$scanPosY): (k±Δk)=$(kLaserApprox) $(begin x+5 end)"` `"""($scanPosX,$scanPosY): (k±Δk)=$(kLaserApprox) $(begin x+5 end)"""`
Interpolation highlighting is only done for single-quote strings, but I am planning to allow it in triple-quote and commands also. For `$(var)` vs `$var`, I didn't find a way to highlight `$(` in the former so I ended up highlighting only what is inside the parenthesis. Because in the latter case there are no parenthesis, nothing is highlighted. I can try to find a way to highlight both, including the `$`.
2. Macros confuse the lexer (possibly we have to live with that, since macros can have arbitrary syntax) Example:
Base.@kwdef struct A a::Float64 = 1E-19 b::Float64 = 1E-22 end
Thanks for reporting, that are actually two bugs: - defined values for the attributes are not parsed at all - `Base.@kwdef` is not recognized as a macro (`@kwdef` is well recognized):
```julia @eval fun1(x) = $pi # recognizes `fun1` short function definition Base.@eval fun1(x) = $pi # does not recognize `fun1` short function definition ```
Love this initiative! Thank you all.
@getzze pushed 2 commits.
09e8137b6f8db325289fd94b5577247446d56be7 better handling of struct with @kwdef 04cf6b3c16fc3cb3c6c615b843c99abd6f92b6e2 interpolation of all strings and correct folding of list comprehension
@getzze pushed 1 commit.
dccf5522f9945ba739d2e0b2c9743245335a65b4 merge scope from ctags
Found another edge case: `(2E9)` / `(2e9)`/ `(2f9)`: the right bracket is highlighted as part of the number.
@getzze pushed 10 commits.
dbe2964f195b4e5f1255e7e9f830d6e452008a4b add filetype extension 9c431fc8f2af00aaa75f8eda53983706a552f649 add snippets 671521775f66821a2caabc6a4325a7b842e56cad correct end of macro c4cfe82f48d215ad00fff2a8b3f3d0980ad27d74 update ctags from upstream d3a56d90c222c85a1561039733f1e6ef85b54a0a ctags: [geany patch] disable reftags roles ce2172856effe4f429fd4557d7e16126d095e5f5 ctags: change naming 5db72695539fd60cdbf5fa3ec6d880ffe10f82f8 add as keyword 3150cdc6cd3519a2725b299098d5130ce6b24d00 add repl unicode snippets ae47f33e23809132d02bd9c6da1f98a45d9de852 lexer: do not highlight string interpolation for raw strings 10cd4a645adbd33cb271b2d832342aeb6acc2d4b lexer: correct folding
Thanks for the feedback. I pushed a patch for it, along with some other improvements: - merge ctags from upstream - do not highlight interpolation for raw strings - correct folding - add REPL autocompletion using snippets (needs to change wordchars)
@getzze So... any update on this? Is it complete? Thanks for taking the time!
What's the status on this? I love both Julia and Geany and this looks like a really good improvement.
@oscardssmith three problems:
1. Geany regular contributors are very quiet ATM for various reasons, but then none of them are Juliaists anyway 2. As noted in the first comment, the lexer and parser need to be upstreamed, even when 1. improves Geany doesn't have the effort to maintain its own versions of those 3. Scintilla is going through a major evolution, and is still classed as unstable by its maintainer, so any lexer submitted there will be a while before its added to Geany (after Geany is updated to the eventually stable new Scintilla) 4. it has merge conflicts which prevent CI building to see if its ok
oops thats 4, anyway at least you could build your own test if the merge was fixed.
@getzze pushed 4 commits.
6400fe99fc439a48001b614bc27d2109e772f102 correct scintilla warnings 613d38bad18b36f6bbb2267642b40b2dcfabeb0e merge conflict 8f9e59f14786d2ef5c135b768b18092c8edf2125 merge conflict 31bede9a57915916e1066d380925f0fef3677680 merge conflict
I just pushed new commits to solve conflicts. As @elextr said, julia ctag parser has been merged upstream but from Scintilla it will take much longer (they only reviewed aesthetic aspects of the code so far). But you can build from source applying this PR.
@getzze pushed 1 commit.
eb36bae9efa1ee20e3aef8a3b4f479d4b6e81040 make raw string literals list modificable
LexJulia has been merged upstream by Scintilla (https://github.com/ScintillaOrg/lexilla/commit/6ee6b086a1920fdafe3af41eecbd8... and later commits for minor corrections). I will push a clean rebase of this PR so it can be merged to geany.
@getzze pushed 2 commits.
9b7d6e4dc3d620041c6c4e024bcc96fecf2ad4df merge upstream lexilla corrections 9b377e2e5869c0720667350f407e098dd9819b12 set SCLEX_JULIA=133 like lexilla upstream
The PR has been rebased. The ctags parser file is identical to upstream and the scintilla lexer has minimal change (3 lines) because upstream is using lexilla v5 and geany is still at v4. Geany-specific files need to be reviewed.
This looks almost complete.... I hope we get this in the newer versions of Genie.... :smiley: Again @getzze Thanks!
@elextr requested changes on this pull request.
First glance at it only a few comments, also for the Julia lexer could you add a diff that applies the three lines (I think you said) to backport it from Lexilla, probably best in the same place as scintilla_changes.patch and add a prompt to update_scintilla.sh to use it so the changes are known and can be re-applied if another backport is needed.
@@ -129,14 +129,15 @@ comment_line_doc=comment_doc
comment_doc_keyword=comment_doc,bold comment_doc_keyword_error=comment_doc,italic
-number=0x007f00 +number=0x808000
Why the change to the default colour scheme?
@@ -138,3 +138,3283 @@ module=-module(%cursor%).
export=-export(%cursor%). compile=-compile(%cursor%). include=-include(%cursor%). + +[Julia]
This is a cunning way of getting the Julia latex input to work in Geany :-) but IIRC all the snippets for all languages are read at startup, is there a way this could be distributed in another way instead of every user of every language having several thousand Julia snippets loaded? As a user snippets somehow maybe?
@@ -153,6 +154,7 @@ identifier_4=identifier_1
string=0xff8000 string_1=string string_2=0x008000 +string_3=0x008000
Is this used?
+# MIME type
+mime_type=text/x-julia + +# single comments, like # in this file +comment_single=# +# multiline comments +comment_open=#= +comment_close==# + +[indentation] +width=4 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +type=0 + + +[build_settings]
Please use the `[build_menu]` settings, all the old filetypes still use `[build_settings]` because I made the backwards compat too good and nobody has needed to change them :-) but lets make it right for new ones.
@getzze commented on this pull request.
@@ -129,14 +129,15 @@ comment_line_doc=comment_doc
comment_doc_keyword=comment_doc,bold comment_doc_keyword_error=comment_doc,italic
-number=0x007f00 +number=0x808000
Sorry I didn't remember that I did that, but the `number` color 0x007f00 is very similar to `string_2`, which is very confusing for Julia.
@getzze commented on this pull request.
@@ -138,3 +138,3283 @@ module=-module(%cursor%).
export=-export(%cursor%). compile=-compile(%cursor%). include=-include(%cursor%). + +[Julia]
you are right, better create a page on Geany wiki with Julia snippet at https://wiki.geany.org/snippets/start
@getzze commented on this pull request.
@@ -153,6 +154,7 @@ identifier_4=identifier_1
string=0xff8000 string_1=string string_2=0x008000 +string_3=0x008000
this is not used
@getzze commented on this pull request.
@@ -138,3 +138,3283 @@ module=-module(%cursor%).
export=-export(%cursor%). compile=-compile(%cursor%). include=-include(%cursor%). + +[Julia]
done: https://wiki.geany.org/snippets/julia/start
There are still some open issues with Lexilla: https://github.com/ScintillaOrg/lexilla/pull/13
@elextr commented on this pull request.
@@ -129,14 +129,15 @@ comment_line_doc=comment_doc
comment_doc_keyword=comment_doc,bold comment_doc_keyword_error=comment_doc,italic
-number=0x007f00 +number=0x808000
But since this is the default colour scheme you are changing it for everybody and there have been no complaints that I could find.
If its really a problem for Julia (why for Julia specifically and not other languages that use `string_2` ?) maybe map Julia numbers to something other than "number" in `highlighting_mappings.h`, "julia_number" for eg, so you can have your own colour. Adding new highlight type names won't modify existing ones.
@elextr commented on this pull request.
@@ -153,6 +154,7 @@ identifier_4=identifier_1
string=0xff8000 string_1=string string_2=0x008000 +string_3=0x008000
To say it clearer "If this is not used please remove it", the "is this used" was rhetorical :-)
I didn't look at the lexer code, but most lexers load the "keyword" lists from Geany. Not sure how you can approach the two word keywords (curse Jeff and his femtolisp parser :-) where each word is a valid variable in other contexts. Unless you simply build it into the lexer, have it know and find the two word keywords first and do not test any of the keyword list keywords in that case.
A similar (unsolved) issue happens with C++ where names like `override` which are keywords in one context and variable or type names in other contexts are currently keyword highlighted in all contexts since the lexer doesn't have sufficient capability to distinguish the context, it also happens in other IDEs where highlighting is separate from parsing (eg Eclipse).
So its not unprecedented if some edge cases are wrongly highlighted, just raise an issue after this is committed.
@getzze commented on this pull request.
@@ -129,14 +129,15 @@ comment_line_doc=comment_doc
comment_doc_keyword=comment_doc,bold comment_doc_keyword_error=comment_doc,italic
-number=0x007f00 +number=0x808000
ok, then I can create a `number_3` color for julia numbers.
@getzze pushed 2 commits.
56551cb4c84cf198f7599d104338d060edf49e53 remove julia snippets 2074ecd518bab0d0787727240e129195c4ff277e do not change defaults
@getzze can you push some inconsequential change (or a big change if you have one :) to see if CI has been fixed?
@getzze pushed 1 commit.
63f4c6e6cceaf49ede29fdcc162dafd662cbe979 use LineState to lex and fold line-by-line
@getzze commented on this pull request.
+# MIME type
+mime_type=text/x-julia + +# single comments, like # in this file +comment_single=# +# multiline comments +comment_open=#= +comment_close==# + +[indentation] +width=4 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +type=0 + + +[build_settings]
Is it `[build_menu]` or `[build-menu]` ? (`filetypes.python` has '[build-menu]')
@elextr commented on this pull request.
+# MIME type
+mime_type=text/x-julia + +# single comments, like # in this file +comment_single=# +# multiline comments +comment_open=#= +comment_close==# + +[indentation] +width=4 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +type=0 + + +[build_settings]
sorry errant shift key, dash not underscore
Yay CI works again!!
One thing you might like to consider (can be later) is a test for the ctags parser, see `tests/ctags` so CI would notice if a ctags infrastructure update like #2830 broke your parser.
@elextr approved this pull request.
Have approved the changes (pending build-menu :) and LGTM, but havn't tested it yet, might have time in a few days then should be mergable.
Yay CI works again!!
One thing you might like to consider (can be later) is a test for the ctags parser, see `tests/ctags` so CI would notice if a ctags infrastructure update like #2830 broke your parser.
Closed #2584.
Reopened #2584.
IIUC most of the tests are simply from ctags anyway, many of their names relate to ctags bug reports
IIUC the tests are just one (or more) source file(s) mentioned in `Makefile.am` and tags file(s) with the same name but extension `.tags` (generated by Geany, they are tagmanager format, which is binary, so not manually generated). I think mentioning the source files in `Makefile.am` sources list makes the existing test harness feed the source to Geany and generate and compare to the tags files.
@getzze pushed 3 commits.
31128dc29c9c71ed36134da4a79a96e5284a74c5 update pending PR from lexilla bba7d67c57e2336ea9161f959480f6560272a479 add patch file to apply to LexJulia.cxx from lexilla to work with v4 bfeaaaacdcb19730814463aa6c4bf224f144bdbb add ctags test file
I pushed some changed from Lexilla (like using a new keyword list for coloring builtin functions).
I added a patch file in the `scintilla` folder, so the lexer works with lexilla v4. Also added a ctags test file (I didn't manage to generate the binary file).
@elextr commented on this pull request.
delete this;
+ } + int SCI_METHOD Version() const override { +- return lvRelease5; ++ // Geany still uses Lexilla v4 ++ //return lvRelease5; ++ return lvIdentity; + } + const char * SCI_METHOD PropertyNames() override { + return osJulia.PropertyNames(); +@@ -173,7 +176,9 @@ public: + return 0; + } + +- static ILexer5 *LexerFactoryJulia() { ++ // Geany still uses Lexilla v4
Technically this is wrong, Geany uses Scintilla 3.5 which is before the separation of lexilla
@getzze pushed 1 commit.
bc627857f1236d162cbf6419c0ba91ee29c7c7a3 repair CI
@getzze pushed 1 commit.
3b0c3ea8c1bca24435a8d9e71c0dc61e20fc46f6 repair CI
@getzze pushed 1 commit.
17e670ab45833ec528d9da8112f44465b7d340f9 update LexJulia patch
@getzze commented on this pull request.
delete this;
+ } + int SCI_METHOD Version() const override { +- return lvRelease5; ++ // Geany still uses Lexilla v4 ++ //return lvRelease5; ++ return lvIdentity; + } + const char * SCI_METHOD PropertyNames() override { + return osJulia.PropertyNames(); +@@ -173,7 +176,9 @@ public: + return 0; + } + +- static ILexer5 *LexerFactoryJulia() { ++ // Geany still uses Lexilla v4
corrected
@getzze pushed 2 commits.
2330dae685550f752e347aea231d1b2344496803 add SCE_JULIA_TYPEOPERATOR and remove no-interpolaton option 897ae6ad15a9808ec039e5c147e44edcf98864e0 upstream merge
The issue with Lexilla is solved. It's ready to merge. If needed, I can rebase to one commit.
I just rebased to two commits. I left the ctags test file in a separate commit because I am not sure it is needed, julia parser is well tested in ctags upstream.
Merged #2584 into master.
WFM, although testing limited, thanks @getzze
Thanks so much for getting this pushed through!
@elextr Any idea when's the next release?
Hopefully it will happen in September, if not at least this year :).
Hello, in the following snippet, the 4th line after the `#` char constant parsed as comment: ```julia ok=true for r=2:R+1,c=2:C+1 if table[r,c]=='#' all(table[r+d[1],c+d[2]]!='#' for d=[(1,0),(-1,0),(0,1),(0,-1)])&&(ok=false;break) end end ``` it can be resolved by putting an extra space after the operator. (geany version 1.39)
That's not a correct fix. The correct fix would be to check whether you're inside or outside quotation marks.
Its actually lexing the first `'` as an operator, possibly a postfix transpose, then the `#` is indeed a comment.
Lexers come from the [Lexilla](https://github.com/ScintillaOrg/lexilla/issues) project. Since Geany folks don't know Julia, please post the issue there so the Julia lexer maintainer can talk to you directly.
Post a link to the issue here.
@oscardssmith: i did not mean it as a fix, just as a how to get rid of it. :-) @elextr: thx, i'll file an issue. ![image](https://user-images.githubusercontent.com/2426972/182254817-de0bc1b6-33d0-42...)
Thanks for catching this bug! I submitted a fix to lexilla: https://github.com/ScintillaOrg/lexilla/pull/98
github-comments@lists.geany.org