Oni: Scriptability of Oni

Created on 12 Aug 2017  ·  8Comments  ·  Source: onivim/oni

How scriptable is Oni right now? I know that we have an existing plugin infrastructure, but if I miss the whole "Just add it to your .vimrc" mentality for small things

question

All 8 comments

Great question. This is something I've been thinking about.

One thing I'd like to do is treat the Config.js as a mini-plugin, and have an activate method for it - so you can script against the Oni object.

You can also open the developer tools and make calls against the Oni object (which is the same thing the plugins get), but it's not super interesting - it'll be moreso once there are things like keybindings hooked up...

Is there a particular sort of customization you were thinking about, that wasn't easy to do without rebuilding Oni?

Maybe a dumb example, but hypothetically I might want to change the
background color of the whole status bar based on mode. I don't actually,
but it seems like something I should be able to do. I don't know that
it's going to be feasible in JS and electron, but basically any state that
isn't critical to the editor's correct functionality should be available to
the user

On Sat, Aug 12, 2017, 6:16 PM extr0py notifications@github.com wrote:

Great question. This is something I've been thinking about.

One thing I'd like to do is treat the Config.js as a mini-plugin, and
have an activate method for it - so you can script against the Oni object.

You can also open the developer tools and make calls against the Oni
object (which is the same thing the plugins get), but it's not super
interesting - it'll be moreso once there are things like keybindings hooked
up...

Is there a particular sort of customization you were thinking about, that
wasn't easy to do without rebuilding Oni?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/extr0py/oni/issues/610#issuecomment-322009278, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AICBCQFpUkU0MJsxbn5f545Q-tWx7TX-ks5sXiQqgaJpZM4O1gME
.

Not a dumb example at all, this is great, and is exactly what I'd like to support!

The way I'm thinking about this would be, in Config.js, we'd expose an activate method:

const activate = (Oni) => {

     Oni.on("mode-changed", (newMode) => {
          const newColor = newMode === "insert" ? "black" : "white"
           Oni.configuration.setValue("oni.colors", {
                 "statusbar.background": newColor
           })
     })
}

module.exports = {
   activate,

  //add custom config here, such as
  //"oni.useDefaultConfig": true,
  "editor.fontSize": "12px",
  "editor.fontFamily": "Fira Code",
  "oni.bookmarks": ["C:/Toronto2"],
  "oni.loadInitVim": true,
  "statusbar.enabled": true,
  "editor.scrollBar.visible": true,
  "editor.cursorLine": true,
  "editor.cursorLineOpacity": 0.1,
...

Something like that... It's a bit awkward having the function in the same space as the configuration, but I'd like to use 'activate' and 'deactivate' as reserved capabilities here.

The setting of color properties ties into some of the thoughts @cyansprite had in #604

Ideally, it should be really lightweight... in that I can save and see changes immediately, as well as be very straightforward - it should have premier autocompletion / quickinfo / etc.

Here's another scriptability example I was thinking of the other day - I'd like to make an easy way to take screenshots of the window (or, later, even record/pause/stop gifs/videos):

Oni.input.bind("<C-Space>", () => Oni.workspace.takeScreenshot())

FYI, the screenshot example works now in 0.2.12.

I've started documenting the API surface here:
https://github.com/bryphe/oni/wiki/API

And some examples of how to use it in the config:
https://github.com/bryphe/oni/wiki/Configuration#examples

@bryphe AFAIK, this was implemented.
Am I correct? (if so, let's close this issue :D)

@TalAmuyal I agree, seems like basic scriptability is available, only thing missing is documentation on the API functions available.

@TalAmuyal @badosu - sounds good! Yes, makes sense, the core 'scriptability' is available - the next step is to improve our API documentation and core documentation. Thanks for reviewing these issues 👍

There are still plenty of gaps (both in functionality and documentation), but we're at the point where we can have more targetted issues for those - so I'll go ahead and close this out. @Bretley , let me know if there are any specifics that we should move to separate isues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

badosu picture badosu  ·  3Comments

LucianBuzzo picture LucianBuzzo  ·  3Comments

TalAmuyal picture TalAmuyal  ·  3Comments

Siilwyn picture Siilwyn  ·  3Comments

magopian picture magopian  ·  3Comments