• This repository has been archived on 23/Oct/2022
  • Stars
    star
    197
  • Rank 197,722 (Top 4 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Plugin manager for Kakoune

plug.kak

GitHub issues license

plug.kak

plug.kak is a plugin manager for Kakoune, that was inspired by vim-plug and use-package. It can install and update plugins, run post-update actions, and helps to encapsulate the configuration within itself.

Installation

plug.kak can be installed anywhere in your system, but in order to update itself, it is required to install plug.kak in the plugin installation directory. By default, plug.kak installs plugins to the %val{config}/plugins, which is usually at $HOME/.config/kak/plugins:

mkdir -p $HOME/.config/kak/plugins
git clone https://github.com/andreyorst/plug.kak.git $HOME/.config/kak/plugins/plug.kak

Now, when plug.kak is installed, we need to tell Kakoune about it. Add this to the kakrc file:

source "%val{config}/plugins/plug.kak/rc/plug.kak"
plug "andreyorst/plug.kak" noload

Alternatively, this process can be automated, by adding the following snippet to the kakrc:

evaluate-commands %sh{
    plugins="$kak_config/plugins"
    mkdir -p "$plugins"
    [ ! -e "$plugins/plug.kak" ] && \
        git clone -q https://github.com/andreyorst/plug.kak.git "$plugins/plug.kak"
    printf "%s\n" "source '$plugins/plug.kak/rc/plug.kak'"
}
plug "andreyorst/plug.kak" noload

This will create all needed directories on Kakoune launch, and download plug.kak if it is not installed already.

Note: plug "andreyorst/plug.kak" noload is needed to register plug.kak as manually loaded plugin, so plug-clean will not delete plug.kak.

Usage

All plugins are installed and loaded with the plug command. This command accepts one-or-more arguments, which are keywords and attributes, that change how plug.kak behaves.

The first strict rule of the plug command is that the first argument is always the plugin name formatted as in GitHub URL: "author/repository".

plug "author/repository"

By default plug.kak will look for the plugin at GitHub.com, and download it. When the plugin is hosted on a different service, a URL can be used as the first argument. So in most cases it is enough to add this to the kakrc to use a plugin:

plug "delapouite/kakoune-text-objects"

Or with URL:

plug "https://gitlab.com/Screwtapello/kakoune-inc-dec"

After adding this, kakrc needs to be re-sourced to let plug.kak know that configuration was changed. Alternatively, Kakoune can be restarted. After that newly added plugins can be installed with the plug-install command. More information about other commands available in Commands section.

Keywords and attributes

The plug command accepts optional attributes, that change how plug.kak works, or add additional steps for plug to perform.

These keywords are supported:

Branch, Tag or Commit

plug can checkout a plugin to desired branch, commit or tag before loading it. It can be done by adding the following keywords with parameters: branch "branch_name", tag "tag_name" or commit "commit_hash".

Loading plugin from different path

Plugins can be loaded from arbitrary path by specifying the load-path keyword and providing the path as an argument:

plug "plugin_name" load-path "~/Development/plugin_dir"

However all plug related commands, like plug-update or plug-clean will not work for plugins that aren't installed to plug_install_dir.

Skipping loading of a plugin

If plugin needs to be loaded manually, the noload keyword can be used. This can also be used to avoid loading the plugin second time, like in the example with plug.kak from the installation section:

source "%val{config}/plugins/plug.kak/rc/plug.kak"
plug "andreyorst/plug.kak" noload

Note, that plugins with the noload keyword are still configured and managed. See handling-user-configuration for more details.

Automatically do certain tasks on install or update

When the plugin requires some additional steps to preform after installation or update, the do keyword can be used. This keyword expects the body which will be executed in the shell, thus it can only contain shell commands, not Kakoune commands.

plug "ul/kak-lsp" do %{
    cargo build --release --locked
    cargo install --force --path .
}

In the example above plug.kak will run these cargo commands after kak-lsp was installed or updated.

Note that even though this is technically a shell expansion, the %sh{} expansion can't be used with do, as it will be evaluated immediately each time kakrc loaded. Use %{} instead.

Installing color schemes

To register the plugin as a color scheme, use theme keyword. Such plugins will be copied to the %val{config}/colors directory.

plug "andreyorst/base16-gruvbox.kak" theme config %{
    colorscheme base16-gruvbox-dark-soft
}

Ensuring that plugins are installed

plug command can be explicitly told to install the plugin automatically with the ensure keyword. The plug_always_ensure option can be set to true to perform this for each and every plugin specified in the kakrc.

Note that ensure plugins are installed (if missing) in a background job; they are then only loaded when the install finishes. Thus, subsequent kakrc commands should not depend on functionality provided by such plugins. Only use ensure with non-essential plugins, which are not required for kakrc to complete loading.

Handling user configurations

The configuration of the plugin is performed only when the plugin is installed. There's a second strict rule of plug command: every parameter that doesn't have a keyword before it, is treated as plugin configuration. For example:

plug "andreyorst/fzf.kak" config %{
    map -docstring 'fzf mode' global normal '<c-p>' ': fzf-mode<ret>'
}

Here, plug will map Ctrl+p key only if the plugin is installed. Everything within the config %{} block is an ordinary kakscript.

The config keyword is optional, and can be skipped. Multiple config blocks are also supported.

Commenting out plug options

It may be tricky to "toggle" plug options, for debugging or testing purposes, because it is impossible to continue a command past a #... comment (also, config blocks usually span multiple lines). To solve this, plug supports a comment keyword that ignores its next argument. For example, to toggle a load-path option, wrap it in comment %{}; then remove the "wrapper" to turn it back on (without having to re-type the full path):

plug "andreyorst/fzf.kak" comment %{load-path /usr/local/src/fzf} config %{
    # ...
}

Deferring plugin configuration

With the introduction of the module system, some configurations have to be preformed after loading the module. The defer keyword is a shorthand to register a ModuleLoaded hook for given module. You need to require the module explicitly elsewhere.

Below is the configuration of fzf.kak plugin, which provides the fzf module:

plug "andreyorst/fzf.kak" config %{
    map -docstring 'fzf mode' global normal '<c-p>' ': fzf-mode<ret>'
} defer fzf %{
    set-option global fzf_preview_width '65%'
    set-option global fzf_project_use_tilda true
}

Note: the ModuleLoaded hook is defined as early as possible - before sourcing any of plugin files.

Demanding plugin module configuration

Works the same as defer except requires the module immediately:

plug "andreyorst/fzf.kak" config %{
    # config1 (evaluated before demanding the module)
} demand fzf %{
    # demand block (will generate `require-modlue fzf` call, and a respective hook)
    set-option global fzf_project_use_tilda true
} config %{
    # config2 (evaluated after demanding the module)
}

The above snippet is a shorthand for this code:

plug "andreyorst/fzf.kak" defer fzf %{
    # the body of demand block
    set-option global fzf_project_use_tilda true # demand block
} config %{
    # config1 (evaluated before demanding the module)
    require-module fzf # the demand hook
    # config2 (evaluated after demanding the module)
}

Note: the ModuleLoaded hook is defined as early as possible - before sourcing any of plugin files. The place where require-module call will be placed depends on the order of config blocks in the plug command. As soon as the module is required, the ModuleLoaded hook will execute.

plug.kak Configuration

Several configuration options are available:

Proper way to configure plug.kak is to load it with the plug command, and providing both noload and config blocks: This should be done before loading other plugins.

plug "andreyorst/plug.kak" noload config %{
    # configure plug.kak here
}

Plugin installation directory

By default plug.kak automatically detects its installation path and installs plugins to the same directory. To change this, use the plug_install_dir option:

plug "andreyorst/plug.kak" noload config %{
    set-option global plug_install_dir %sh{ echo $HOME/.cache/kakoune_plugins }
}

Maximum downloads

plug.kak downloads plugins from github.com asynchronously via git. By default it allows only 10 simultaneously active git processes. To change this, use the plug_max_simultaneous_downloads option.

Default git domain

If majority of plugins is installed from the service other than GitHub, default git domain can be changed to avoid specifying the domain keyword for each plugin, or using URLs.

Notify on configuration error

By default, plug.kak will display an info box when any plugin's config block has errors while being evaluated. To change this, use the plug_report_conf_errors option:

set-option global plug_report_conf_errors false

Commands

plug.kak adds five new commands to Kakoune.

plug-install

This command installs all plugins that were specified in any of the configuration files sourced after Kakoune launch. It accepts optional argument, which can be the plugin name or the URL, so it could be used to install a plugin from command prompt without restarting Kakoune. This plugin will be enabled automatically, but you still need to add plug command to your configuration files in order to use that plugin after the restart.

plug-list

Display the buffer with all installed plugins, and check for updates. The Enter key is remapped to execute plug-update or plug-install command for selected plugin, depending on its state. This command accepts an optional argument noupdate, and if it is specified, check for updates will not be performed.

plug-update

This command updates all installed plugins. It accepts one optional argument, which is a plugin name, so it could be used to update single plugin. When called from prompt, it shows all installed plugins in the completion menu.

plug-clean

Remove plugins, that are installed, but disabled or missing in configuration files. This command also accepts optional argument, which is a plugin name, and can be used to remove any installed plugin.

plug

Load plugin from plugin installation directory by its name.

plug-chain

This command can collapse separate plug invocations and thus saves startup time by reducing multiple shell calls; it may come in handy if you're invoking kak frequently (e.g. as the $EDITOR). Replace the first plug command in your kakrc with plug-chain, then append subsequent plug calls and their parameters, as in the following:

plug-chain https://github.com/Delapouite/kakoune-select-view config %{
  map global view s '<esc>: select-view<ret>' -docstring 'select view'
} plug https://github.com/occivink/kakoune-vertical-selection %{
} plug https://github.com/jbomanson/search-doc.kak demand search-doc %{
  alias global doc-search search-doc
}

Backslashes can also be used to separate individual plug "clauses" (which avoids the "visual hack" of empty config blocks, as above, serving as newlines). An initial plug redundant argument is also supported for symmetry. Either way, plug-chain simply figures out the parameters intended for each individual plug clause (using "plug" as a delimiter), and executes all implied plugs in a single shell call. All regular plug features are supported. Mix and match plug / plug-chain invocations in any order, any number of times.

Note, that if plug.kak own variables are altered in the plug-chain body, the chained plug commands won't get updated values. This happens because Kakoune reads its variables only once per shell invocation, and calling set-option won't update the value of a variable for current shell.

Alternative plugin managers

Here are some other plugin managers to consider as alternatives to plug.kak:

More Repositories

1

fzf.kak

FZF for Kakoune
KakouneScript
143
star
2

SimpleSnippets.vim

Simple snippet support for your Vim and Neovim
Vim Script
86
star
3

Breezemite

Aurorae theme that mimics Yosemite window decoration, with Breeze colors.
71
star
4

smarttab.kak

Automatic handling different styles of indentation and alignment.
KakouneScript
62
star
5

kaktree

File explorer side panel for Kakoune
KakouneScript
51
star
6

powerline.kak

Kakoune modeline, but with passion
KakouneScript
50
star
7

kde_wallpaper_blur

Blur your wallpaper and set it to lockscreen and sddm automatically. This repo is orphaned since PLasma 5.13 implemented this feature.
Shell
43
star
8

dotfiles

Emacs configurations and other stuff (mirror)
Emacs Lisp
31
star
9

fennel-cljlib

Port of clojure.core namespace to Fennel (mirror)
Fennel
31
star
10

tagbar.kak

Tag viewer for Kakoune
KakouneScript
19
star
11

SimpleWorkspaces.vim

Visual Studio Code like workspace support for Vim and Neovim. Not actively maintained
Vim Script
15
star
12

kakoune-snippet-collection

Snippets for various languages for Kakoune editor.
Julia
12
star
13

itable

Immutable table manipulation library for Fennel and Lua. (mirror)
Fennel
12
star
14

fenneldoc

Turn Fennel docstrings into rich markdown documentation (mirror)
Fennel
10
star
15

lazy-seq

Lazy sequences for Fennel and Lua (mirror)
Fennel
10
star
16

fennel-conditions

Common Lisp's Condition System for Fennel (mirror)
Fennel
9
star
17

base16-gruvbox.kak

Base16 Gruvbox Dark Soft variant colorscheme for Kakoune
8
star
18

langmap.kak

Kakoune plugin to toggle between keyboard layouts in insert mode
KakouneScript
8
star
19

fennel-async

Asyncronous programming in Fennel (mirror)
Fennel
7
star
20

fennel-test

Testing library for Fennel (mirror)
Fennel
6
star
21

fennel-proto-repl-protocol

Protocol for the Fennel Proto REPL (mirror)
Fennel
6
star
22

pmanage.kak

Manage background processes from Kakoune
5
star
23

SimpleSnippets-snippets

Collection of snippets for SimpleSnippets.vim. Not actively maintained
Vim Script
5
star
24

pipeline-extras

pipline extras for clojure.core.async library
Clojure
4
star
25

SimpleClangFormat.vim

Small plugin to use clang-format in Vim and Neovim. Not actively maintained
Vim Script
4
star
26

fennel-defn

A small library for Fennel that implements Clojure's multi-arity feature as a defn macro (mirror)
Fennel
4
star
27

async.fnl

ClojureScript core.async library port to the Fennel language and Lua runtime (mirror)
Fennel
3
star
28

cfn

macro wrapper around LuaJIT's FFI that allows to write C directly in Fennel
Fennel
3
star
29

love-fabrik

Implementation of Forward and Backward Reaching Inverse Kinematics algorithm in Fennel (mirror)
Fennel
2
star
30

common-lisp-modes.el

Emacs Lisp
2
star
31

lua-inst

Implementation of Clojure's #inst tagged literal for Lua (mirror)
Lua
2
star
32

fnl-http

(Asynchronous) HTTP/1.1 client written in the Fennel language (mirror)
Fennel
2
star
33

advent-of-code

Solutions for Advent of Code
Clojure
1
star
34

infinite.el

Infinite space for creating windows in Emacs (mirror)
Emacs Lisp
1
star
35

region-bindings.el

Emacs Lisp
1
star
36

wave-function-collapse

Wave function collapse algorithm implementation in ClojureScript (mirror)
Clojure
1
star
37

ob-fennel

Org Babel support for the Fennel language (mirror)
Emacs Lisp
1
star