Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Plugins

Akin edited this page Apr 6, 2018 · 14 revisions

Oni does not require the use of a plugin-manager such as pathogen or vundle (although you may use one if you wish, and this will be necessary if you are sharing a configuration between Neovim and Oni). Oni will attempt to load all plugins found in the $HOME/.config/oni/plugins directory.

Installing a Vim Plugin

To install a Vim plugin, you just need to create a directory inside $HOME/.config/oni/plugins.

git clone will usually do this for you, so for example, if you wanted to install this Solarized Theme by lifepillar, you'd run:

NOTE: On Windows, use your home directory (ie, C:/users/<your username) instead of ~

  • cd ~/.config/oni
  • mkdir -p plugins
  • cd plugins
  • git clone https://github.com/lifepillar/vim-solarized8

This will clone the vim-solarized8 plugin and create an ~/.config/oni/plugins/vim-solarized8 folder.

Restart Oni, and execute :colorscheme solarized8_light, and enjoy your new theme!

Included Vim Plugins

Several plugins are included with Oni:

As well as some color-schemes:

NOTE: You can disable these by setting the oni.useDefaultConfig configuration value to false. See Configuration for details.

Incompatible Vim Plugins

In general, most vim plugins should work with Oni. However, we've found a few that have compatibility issues.

Dein

Dein caches the runtimepath variable - Oni uses the runtimepath to load some custom plugins. This means that if you call dein#save_state from your init.vim, it will persist Oni's runtimepaths as well - this will cause problems if you then try and run terminal vim. See #1163 for more info.

Workaround:

if !exists("g:gui_oni")
  call dein#save_state()
endif

Installing an Oni Plugin

Installing an Oni plugin is much the same as installing a Vim plugin. However, because they potentially have JavaScript extension code in addition to VimL, you often need to install NPM dependencies.

Oni currently has the following plugins:

Prerequisite: Make sure the npm command is available. If not, install the latest node

As above, you just need to create a folder hosting the plugin, and install the dependencies. As an example, here's how you'd install the oni-plugin-tslint extension.

  • cd ~/.config/oni
  • mkdir -p plugins
  • cd plugins
  • git clone https://github.com/extr0py/oni-plugin-tslint
  • cd oni-plugin-tslint
  • npm install

Restart Oni, and linting should now be enabled when you open up a TypeScript (.ts) file.

API

Oni offers several rich extensibility points, with the focus being on various UI integrations as well as IDE-like capabilities.

NOTE: The API will be in-flux until v1.0.

Language extenders given ONI rich integration with languages, offering services like:

  • Code Completion
  • Quick Info
  • Goto Definition
  • Formatting
  • Live code evaluation
  • Unit test integration
  • Enhanced syntax highlighting

To see the in-progress API, check out the Oni.d.ts definition file as well as the typescript language plugin, which demonstrates several of these features:

You can explore the Oni API during runtime by doing the following:

  • Press <C-P> (open Command Palette)
  • Select "Open Dev Tools"
  • You can access the Oni object directly, ie:

Available Plugins

Plugins bundled with Oni include: Prettier autoformatting plugin

Prettier Plugin

Prettier is:

  • An opinionated code formatter
  • Supports many languages
  • Integrates with most editors
  • Has few options

To use the prettier plugin in oni some default options must first be set

//The default config Oni ships with
    "oni.plugins.prettier": {
        settings: {
            semi: false,
            tabWidth: 2,
            useTabs: false,
            singleQuote: false,
            trailingComma: "es5",
            bracketSpacing: true,
            jsxBracketSameLine: false,
            arrowParens: "avoid",
            printWidth: 80,
        },
		// TODO: Set this to true to enable formatting on save
        formatOnSave: false,

		// TODO: Set this to true to enable the plugin
        enabled: false,
    },

A list of the available configuration options can be found here.

Once enabled a prettier statusbar item should appear in compatible files, if not compatible the plugin does not run and the icon disappears. Once formatted the icon will briefly change to indicate success or failure of the formatting and will also save the buffer.

A format can also be manually triggered by clicking the statubar icon or selecting the Autoformat with Prettier option in the command pallette

Clone this wiki locally