Kakoune Script as an embedded DSL in another general purpose language

Hi all!

Really love Kakoune and have been using it full-time at my job and for personal project.

Not a fan of using plugins - I prefer to control and understand how my editor and tools work, I even do not use the built-in rc scripts, rather writing my own.

So, what happened is that I am struggling with organizing my Kakoune codebase.
It grew quite big at this point and became difficult to navigate and understand.

Also, I still want to add more features:

  1. Tree-view of high-level classes, interfaces, functions, etc of a buffer.
  2. Sticky headers like in here https://twitter.com/a_grebenyuk/status/1534359760308424711
  3. Semantic folding.
  4. Automatic resolution of git conflicts when it’s possible (perhaps, need to integrate an external tool).
  5. Semantic project tree based on packages/classes/modules rather than files.

So, as you see, there’s a lot to do, and I’m afraid that it’s going to be challenging to implement using Kakoune Script, or even another language, but as a bunch of unrelated micro projects. What I need is a standardazed, self-explorable API, preferrably, staticly typed, to ease scaling.

I enjoy working with typed pure functional programming (name Scala, Haskell, OCaml), and have been thinking about create a DSL in such language which then would be compiled into a Kakoune Script, and then maybe abstracting up to make the API more high-level and approachable.

I’ve started implementing that DSL in Scala starting with Kakoune options, but realised that it’s a quite challenging task to do - there lot’s of rules to consider like expansions, different option types, built-in options, etc.

So, my question is has anyone tried to achieve something similar?
Providing a unified Kakoune Script interface in another language, whatever it is?

And also, do you have any suggestions I could use? I’ve found there’s a JSON RPC API, but I’m not sure if it’s related to my problem and task.

Maybe you want to look at GitHub - tomKPZ/pykak: script Kakoune with python, I made my own fork of it over at GitHub - danr/pykak: script Kakoune with python it is actually quite ambitiously typed.

Exactly what I needed. Thanks!