Hello,
I use geany for my all works and after i move from Java to Kotlin for Android. I realized that Geany do not have a support Kotlin language syntax can you add this support please ?
+1 I'd like this feature as well :)
I wanna move back the Geany again :pray:
Feel free to post a pull request with a custom filetype file, maybe based on Java.
Note that if Kotlin needs specific highlighting and symbols support those need to be added to the [Scintilla](https://www.scintilla.org/) and [UCtags](https://github.com/universal-ctags/ctags) first before the integration into Geany.
I went to the Scintilla website, but the documentation is pretty bad (IMO) for adding a new language. Is there an example or documentation available for how to add a new language? And also for making a pull request? (Wish it was on GitHub.)
I'd like to also add Groovy.
I also don't know what to do for UCtags. Grateful for any help. Thanks.
@esotericpig I'm not aware of any better docs than those projects own resources, maybe you could ask there (they are both totally separate projects from Geany, we just use their products).
Maybe its not clear from the post above, but you can (actually must) use the lexer of an existing filetype and the parser of a possibly different existing filetype with a custom filetype. Thats probably the first thing to try, you may find existing ones are "good enough". I suggested Java, but I don't know how close Kotlin is, you could try any of the built-in languages.
I forked the project on SourceForge, but seems like a lot of work, don't know if I will get around to doing it (as I have other projects I'm working on).
I found this: https://www.scintilla.org/Lexer.txt
Basically, you would need to copy this file as LexKotlin.cxx: https://github.com/geany/geany/blob/master/scintilla/lexers/LexCPP.cxx https://sourceforge.net/p/scintilla/code/ci/default/tree/lexers/LexCPP.cxx
Then add the new keywords and syntax that Kotlin has, such as `object` (lower-case), `data class`, `sealed class`, `fun`, `then`, etc. I think you'd probably also want to remove parsing of the ternary operator `a ? b : c` and add parsing for the elvis operator `a ?: b`.
You can also look at this project that is adding the Rust language: https://sourceforge.net/u/dobkeratops/scintilla/ci/default/tree/
Here are other open source projects that have added Kotlin support for help as well: https://github.com/vkostyukov/kotlin-sublime-package https://github.com/nishtahir/language-kotlin
I opened up a feature request:
https://sourceforge.net/p/scintilla/feature-requests/1224/
So maybe someone with more knowledge of Scintilla will do it properly, or at least help guide how to do it.
I opened up a feature request:
Yes, you are better off engaging directly with Scintilla.
@esotericpig from what you mention it sounds like it'd be easy to create a [custom filetype](https://www.geany.org/manual/#custom-filetypes) just adding a few keywords, at least for the highlighting part, if the syntax is basically C++.
For extracting symbols (the [Universal-CTags](/universal-ctags/ctags/) part) it might actually require some extra work if there is different syntax for defining classes or such, as then it's not merely tokenizing but parsing.
@esotericpig while you are waiting for Scintilla and Uctags, did you actually try making a custom filetype using an existing lexer and parser?
Thanks, that's probably the best way.
I made `~/.config/geany/filedefs/filetypes.kotlin`: ```INI [styling=Java]
[keywords=Java] # https://kotlinlang.org/docs/reference/keyword-reference.html primary=as as? fun in !in object typealias val var when by constructor delegate dynamic field file get init param property receiver set setparam where actual annotation companion const crossinline data expect external infix inline inner internal lateinit noinline open operator out reified sealed suspend tailrec vararg field it # https://kotlinlang.org/docs/reference/basic-types.html secondary=Double Float Long Int Short Byte NaN # documentation keywords for javadoc doccomment= typedefs=
[lexer_properties=Java]
[settings=Java] extension=kt mime_type=text/x-kotlin
[build_settings] # For this to work, the main class should be the same name as the file compiler=kotlinc "%f" run_cmd=kotlin "%e"
# If you usually use Kotlin as a scripting lang, use this instead #compiler= #run_cmd=kotlin -script "%f" ```
Then, in `filetype_extensions.conf` I added:
```INI Kotlin=*.kt;*.kts;
[Groups] Programming=Arduino;Clojure;CUDA;Cython;Genie;Scala;Kotlin ```
I assume I need to do something more? Where should I specify filetypes.kotlin? Thanks
I assume I need to do something more?
To read the docs more closely I'm afraid :)
You have the filename wrong, you havn't specified the lexer_filetype and you havn't specified the tags parser, see for example [Cython](https://github.com/geany/geany/blob/master/data/filedefs/filetypes.Cython.co...)
Okay, I got it working. File name has to be `filetypes.Kotlin.conf`.
`~/.config/geany/filedefs/filetypes.Kotlin.conf`: ```INI [styling=C]
[keywords] # https://kotlinlang.org/docs/reference/keyword-reference.html primary=abstract assert break case catch class const continue default do else enum extends final finally for goto if implements import instanceof interface native new package private protected public return static strictfp super switch synchronized this throw throws transient try volatile while true false null as fun in object typealias val var when by constructor delegate dynamic field file get init param property receiver set setparam where actual annotation companion const crossinline data expect external infix inline inner internal lateinit noinline open operator out reified sealed suspend tailrec vararg field it # https://kotlinlang.org/docs/reference/basic-types.html secondary=Double Float Long Int Short Byte NaN Void # documentation keywords for javadoc doccomment=author deprecated exception param return see serial serialData serialField since throws todo version typedefs=
[lexer_properties=C]
[settings] lexer_filetype=C tag_parser=C extension=kt mime_type=text/x-kotlin
[build-menu] FT_00_LB=_Compile Kotlin Class FT_00_CM=kotlinc "%f" FT_00_WD=
EX_00_LB=_Execute Kotlin Class EX_00_CM=kotlin "%eKt" EX_00_WD=
EX_01_LB=Execute Kotlin _Script EX_01_CM=kotlinc -script "%f" EX_01_WD= ```
What the status of this feature? has it made its way into a release yet?
I've used Scintilla-based editors for years, and would love support for my new favourite language in my favourite editor :)
What the status of this feature? has it made its way into a release yet?
AFAIK nobody has made a pull request so its unlikely to be in any release.
and would love support for my new favourite language in my favourite editor :)
Feel free to contribute it.
filetypes.Kotlin.conf
@esotericpig Is this custom filetype good enough to distribute with Geany, have you or others tested it with much Kotlin code?
You can add support by yourself, I made a tutorial for this. See the video in
https://www.youtube.com/watch?v=C0eWBMTu4LU
filetypes.Kotlin.conf
@esotericpig Is this custom filetype good enough to distribute with Geany, have you or others tested it with much Kotlin code?
It's not perfect, but it's better than nothing I think. I use it in my projects fine.
You can add support by yourself, I made a tutorial for this. See the video at
I mean that's great that you did this, but why wouldn't you just make a text comment here instead of a 14min video? It seems like you just want view counts on your YT video. I don't have time to watch a 14min video. Text is much faster to follow IMO.
@esotericpig Thanks, I've made a pull to add this: #2186.
I'd like to also add Groovy.
I'm happy to merge that if done as a custom filetype.
@esotericpig Thanks, I've made a pull to add this: #2186.
I'd like to also add Groovy.
I'm happy to merge that if done as a custom filetype.
Thank you.
I tried to make one, but it's a bit more difficult. Specifically stuff like this:
```Groovy println "${string_interop}" println '''My String''' println """My String""" println $/My String /$ double money = 12_345_132.12 ``` http://docs.groovy-lang.org/docs/next/html/documentation/#_groovy_language_s...
For now, I just use this in filetype_extensions.conf:
``` Java=*.java;*.jsp;*.groovy;*.gradle; ```
I tried to make one, but it's a bit more difficult
Thanks, I've made a start using the C lexer with properties set for dollar identifiers and triple quoted `"""strings"""`: https://github.com/ntrel/geany/commits/groovy-ft
The other strings aren't supported by Scintilla's LexCPP AFAIK.
@esotericpig I've added a few things for Groovy and made a WIP pull: #2188. Please test it and advise on what the build commands should be.
You can add support by yourself, I made a tutorial for this. See the video at https://www.youtube.com/watch?v=C0eWBMTu4LU
I mean that's great that you did this, but why wouldn't you just make a text comment here instead of a 14min video? It seems like you just want view counts on your YT video. I don't have time to watch a 14min video. Text is much faster to follow IMO.
The video is just to show that everything works and to make it look more clearly, I do not gain anything with the views of my video, it was just to help. It took me several hours to find the correct way to configure the files, 14 minutes is not much compared to what it took me
Closed #1581 via #2186.
github-comments@lists.geany.org