Kakoune-kotlin.kak - Kotlin language support

Kotlin language support for the Kakoune editor.
repo: kakoune-kotlin.kak
See the repo directory kt/countWords.kt for demo on a kotlin integration with kak use-case.

Thanks guys and enjoy.

Update: kscript is now a requirement to parse kotlin.kak file (instead of awk).
countWords.kt now returns the line, paragraph, sentence, and word count.


@andreyorst I have added directory snippets/kotlin that complies with your kakoune-snippet-collection. I tried the pull request + fork but ‘cross functional teams’ don’t include competing companies Bitbucket -> Github. This also leaves me unable to view your email address. If you prefer a download link just let me know. Thanks @andreyorst.

We can go two different ways here.

  1. You simply create an account on GitHub and send me a proper PR, or
  2. You can send me a tar archive and I’ll add those myself, I don’t mind it at all.

Or I’ve realized that I can simply get it from your repo, so if you don’t mind if I do it myself, I think it will be fine solution.

My email is andreyorst@gmail.com

Also, with latest plug.kak you can instead of specifying a link use a domain keyword like so:


plug "https://bitbucket.org/KJ_Duncan/kakoune-kotlin.kak"


plug "KJ_Duncan/kakoune-kotlin.kak" domain "bitbucket.org"

It is friendlier to plug-list command

I’ve added your snippets to the repo

That is better thanks @andreyorst updated the other readme language support repos I have as well. We are good-to-go with the Kotlin snippets, thanks again.

1 Like

I’m not sure if this is a good decision, since I don’t know about Kotlin community, and if kscript is widespread tool among Kotlin users. If this tool makes your plugin more robust, and does something that is really hard to do, or even impossible (which I doubt) with awk or Perl, then it is fine to add a dependency, but generally Kakoune scripts try to stay as close to POSIX as possible (that’s why we use Perl and awk in first place).

Good point and noted, think a DSL for kotlin to kak with inclusion of type safety. I was finding that scripting a language support for kak was getting a little verbose and awk was yet another cryptic *nix tool. Just check out the man page its still loading in from the 1970’s. I enjoy my free time to much to go through that.

No I am not completely happy with my implementation, and in time I will continue to enhance kotlin.kak but with continued support for kscript. I was thinking final implementation would be directly from a URL click the link to see what’s possible in kscript. Or review this blog post pretty cool stuff.

Yes kscript and kotlin are hand and glove with built in IntelliJ IDEA support. Also kotlin-native compiles into a native binary so no problems for *nix os.

Cheers @andreyorst thanks for taking the time.

I think this is obviously a great thing for scripts included with Kakoune. But I think it is a crippling norm if we make it a part of our community. I think plugins must and should take advantage of existing (modern) tools outside of POSIX. It reduces maintenance, increases quality, and what is the point of being able to shell out easily if you are limited to what is available in POSIX?

I think scripts should emit good errors when missing binaries.


@robertmeta You have a lot of valid points in your commentary, but I want to mention that this is valid for complex plugins, and not that valid for small one. For example, imagine if I made smarttab.kak in, say, Emacs Lisp, for some known only by ancient gods reasons (because I love LISP), by using emacs --script. Would user benefit from it? I don’t think so. Would I benefit from it? Probably no, but it would be fun.

What I try to say is if your plugin is huge, like Parinfer or LSP it is sensible to use fast and feature full compiled language to take advantages of it. When you implement something very simple like syntax highlighting and basic indentation handling you should (should) rely on what everybody expect on their system to be. If every kotlin programmer is expecting kscript on their system (which I said I don’t know) then it is fine, if not, maybe it should be reconsidered. If I decide (no I’m not going to) to make full feature plugin from this script I wrote: org.kak I could consider to use Emacs for processing of some features Org mode provides, but I would make it optional, and make sure that users, that don’t have or don’t want Emacs could use plugin for basic interactions with org mode files.

I got you covered - kotlin.kak “Gold Standard” of error messages. Give it a run.

plug “KJ_Duncan/kakoune-kotlin.kak” domain “bitbucket.org

Yeah good point, admit it did not cross my mind.

I guess if your using a language support file that is written in the language you are requesting the highlighting support for…then needless to say computer programming in that language is first on the todo list. Heuristic teaching in full effect.

Ok last word on POSIX for those considering if, when, or maybe kotlin check it out:

import platform.posix.*

kotlin native posix-bindings.md

Yes…walked away and gave it a bit more thought perfect example @andreyorst your powerline.kak another great plugin thanks. You recently updated to the new require module dependency in kaks dev branch.

I want that hour of my life back restoring the old functionality…so point well taken. You master mind you planed it from the beginning.

The thing I am really enjoying with kotlin is I can you the same language across all domains Native/JS/JVM/Swift/OBJC/Android/IOS everything same language profile just a tweak here and there. If you have not yet had a look check it out I am not wasting your time with it. Plus kscript == easy bash support, I use it on a WSL running Debian as it comes with a stand-alone command line complier purrrrfect. Almost forgot Apache Spark & Kotlin kernel for Jupyter/iPython. A scripting language that does not isolate anyone on any platform.

So I came prepared for your next master plan and going to head you of with this AnsiColors via kscript

#!/usr/bin/env kscript

import kotlin.system.exitProcess

class AnsiColors { companion object { const val ANSI_RESET = "\u001B[0m"; const val ANSI_RED = "\u001B[31m"; const val ANSI_GREEN = "\u001B[32m"; const val ANSI_YELLOW = "\u001B[33m"; const val ANSI_BLUE = "\u001B[34m"; const val ANSI_PURPLE = "\u001B[35m"; const val ANSI_CYAN = "\u001B[36m"; const val ANSI_WHITE = "\u001B[37m"; } }

fun logInfo(message: String) = println("${AnsiColors.ANSI_BLUE}$message${AnsiColors.ANSI_RESET}")
fun logWarn(message: String) = println("${AnsiColors.ANSI_YELLOW}$message${AnsiColors.ANSI_RESET}")
fun logError(message: String) = println("${AnsiColors.ANSI_RED}$message${AnsiColors.ANSI_RESET}")

val usage = """
Use this tool to... <TODO>
<TODO> required params info
if (args.size < 2) {
val arg1 = args.get(0)
val arg2 = args.get(1)
// <script>
logInfo("Hello world")
// </script>

All the best and thanks for your input. Yes I agree type erasure on the JVM well need I say it…

That’s what she said

Fellas @robertmeta, @andreyorst if you guys have any sway with the boss @mawww. kotlinlang added as a kak file type would be awesome. Its not like your doing enough already :star_struck:.

My repo has say 90% of the work already done it just needs someone with Kakoune source code knowledge and a github account to polish it up correctly and submit via official channels.

Why don’t I have a github account? Quick answer: it’s one more thing to learn and I have enough of that going on at Uni already.

Why don’t you have a bitbucket account? well bully boy I’m telling mum.

looking at the plugin, all the kscript part does is composes bunch of strings and i dont see what in there couldnt be done with just a shell. but if i want to just look at the kotlin code with syntax highlighting, i would have to install entire kotlin toolchain and more. thats a pretty big barrier.

1 Like

I disagree with your sentiment.

My reasoning, I use Kakoune as a text editor foremost. When I have spare time, my hobby is currently computer programming which I have been doing for approximately three years. The JVM as I see it is just another tool in a programmers tool belt. When considering how large the tool chain is for front-end development let’s not get carried away with an installation process as easy as this:

$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
$ sdk install java
$ sdk install kotlin
$ sdk install kscript

Not a Heath and Safety issue insight. Kakoune for work and play!

Supported Kotlin language platforms, look at what it targets.

  • jvm for Kotlin/JVM.
  • js for Kotlin/JS;
  • android for Android applications and libraries.
  • Kotlin/Native target presets:
    • androidNativeArm32 and androidNativeArm64 for Android NDK;
    • iosArm32 , iosArm64 , iosX64 for iOS;
    • linuxArm32Hfp , linuxMips32 , linuxMipsel32 , linuxX64 for Linux;
    • macosX64 for MacOS;
    • mingwX64 for Windows;
    • wasm32 for WebAssembly.

When you get access to all this in one programming language, well you can see why I disagree.

Appreciate your input and feedback. Thank you for taking the time.

@duncan Do you have a guide to enter in the Java world (Kotlin, Clojure, Scala)?

I would like to do some Android stuff, but not tried yet because I’m intimidated with the ecosystem (VMs, tools, etc.).

One project which picks my interest for example is mpv-android.

Before we get there let me first say thank you for amazing work in the Kakoune ecosystem @alexherbo2, I regularly review your Github repository for ‘A’ grade solutions to Kakoune problems. While I have not yet had the chance, I am excited about the prospect of playing with your keyboard interface to the web project. So big high-five Alex.

Now let’s get on with it. The official curated list of the Kotlin world is home base. Second comes discuss.kotlinlang for the community.

Duncan what about Android you idiot.

OK, Anko is the most widely used Android Kotlin framework and is officially supported by Jetbrains. If you enjoy reading this practice by example Android Kotlin 500 pages for $10, you cannot go wrong. Finally, if all you want to do is get your hands dirty straight away then Kotlin Koans at the Play Kotlinlang website.

Review these four tabs on the website:play_kotlinlang_org

And, of course, the peer reviewed and industry celebrated KJ_Duncan Kakoune/Kotlin repository front page here and back page here. Yaah Duncan :clap:

Let’s step up the creepiness of this hug-a-thon with a quick you know it’s creepy but get in here for a group hug; @alexherbo2, @andreyorst, @robertmeta, @occivink, @Delapouite, and let’s not forget the boss @mawww. You have all shaped my Kakoune experience and making your repositories publicly available has enabled me to succeed with minimal frustrations. Now get back to work and let us never mention this again.

Thanks Guys.

1 Like

Came across this github-wiki today while it doesn’t explain the ecosystem of the java world it falls into the category “when in doubt, ask someone smarter” google/guava. Just a brilliant read for understanding Java. Including guava/android. It’s all under one open source repo on Github: Guava: Google Core Libraries for Java.

Clojure has a great read on Programming at the REPL you could probably skip to Enhancing your REPL workflow or Guidelines for REPL-Aided Development. I did not dive deep enough into the Clojure landscape but I do like Scheme and Lisp variants, so will come back to Clojure.

Scala have not been to that show but did do Haskell and OCaml is next on the list.

Have done Android but it was with Java (spent a year on Java 3/4 of it was outside Android) and boiler plate coding is a relict programming practice so bye bye Java.

Oh, oh, oh, almost forgot this bloke: if anyone knows him twist his arm to do a Kotlin book. An absolute superstar for a must book to buy if only one can be bought then this is the guy Y. Daniel Liang. Don’t sell your self short and buy the brief version’s of his text books. Go for broke baby guaranteed a night too remember; Python, C++, and Java.

Hope this has been of some help, catch ya later.

A convenience link to Kotlin/stdlib/test on Github the best way to learn from the pro’s.

Gave this a bit of thought and “Challenge Accepted!”. :hourglass_flowing_sand: