Sample plugin written in Kotlin

Hi everyone,

Just wanted to announce that I’ve created a sample Obsidian plugin using KotlinJS. Mainly because I want to create a plugin and I know Kotlin better than TypeScript. I figured others might want to utilize the work I’m doing on creating the interop bindings for the Obsidian API. I did announce this a bit ago on Discord but I’ve put a bit more work into it and released the first version of it today (0.1.0).

It’s available at GitHub - darthmachina/obsidian-kotlin-plugin: Base Obsidian plugin written in Kotlin

It has KotlinJS bindings for the Obsidian API and duplicates almost all of the obsidian-sample-plugin functionality. It’s missing the open-sample-modal-complex command just because of an API call that I haven’t figured out yet. KotlinJS allows Kotlin classes to extend Javascript classes, so the full plugin can be developed in Kotlin including the main Plugin class.

It contains:

  • Obsidian API bindings for much of the main API
  • Sample Settings page
  • Editor text replacement command
  • Modal dialog command
  • Builder class for creating a Command (as it’s a JS interface, not a class)
  • Build support to output code in the format Obsidian requires

A non-exhaustive list of what’s missing:

  • Any CodeMirror bindings
  • The above-mentioned complex example of a checked callback
  • Sample Ribbon Icon (haven’t tried it yet)
  • Sample Status Bar Item (haven’t tried it yet)
  • Sample registerDomEvent call (haven’t tried it yet)
  • Sample registerInterval call (haven’t tried it yet)
  • Test support (disabled for now because the default task tries to execute in a browser)
  • Builders for other interface API elements

My long-term goal is to publish the KotlinJS bindings as a library on its own so there would be no need to fork the repository, but that will come after the library has improved a bit.

If people do fork this for their own use, I will be trying to minimize any changes outside of the “obsidian” package to prevent any merge conflicts in downstream repos, but I can’t guarantee that at the moment. I will try to note when that happens, though. I also definitely welcome any comments/criticisms/suggestions/etc. I’ll be switching my main effort to my own plugin but will be trying to improve the bindings as I go.

10 Likes