kakoune: add support for plugins
The kakoune editor has a plugin mechanism and several plugins are already packaged under `pkgs.kakounePlugins`. However, adding these packages to `home.packages` is not enough: the `kakoune` package needs to be configured with the list of plugins to include, so that they get sourced on start-up. We add a `programs.kakoune.plugins` option, analogous to `programs.vim.plugins`. The change is backwards compatible since `pkgs.kakoune` is defined as wrapKakoune kakoune-unwrapped { }; and `wrapKakoune` defaults the list of plugins to empty. PR #1356
This commit is contained in:
parent
3886f8db33
commit
96e2f1bdf0
|
@ -489,6 +489,10 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
kakouneWithPlugins = pkgs.wrapKakoune pkgs.kakoune-unwrapped {
|
||||
configure = { plugins = cfg.plugins; };
|
||||
};
|
||||
|
||||
configFile = let
|
||||
wrapOptions = with cfg.config.wrapLines;
|
||||
concatStrings [
|
||||
|
@ -634,11 +638,22 @@ in {
|
|||
<filename>~/.config/kak/kakrc</filename>.
|
||||
'';
|
||||
};
|
||||
|
||||
plugins = mkOption {
|
||||
type = with types; listOf package;
|
||||
default = [ ];
|
||||
example = literalExample "[ pkgs.kakounePlugins.kak-fzf ]";
|
||||
description = ''
|
||||
List of kakoune plugins to install. To get a list of
|
||||
supported plugins run:
|
||||
<command>nix-env -f '<nixpkgs>' -qaP -A kakounePlugins</command>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ pkgs.kakoune ];
|
||||
home.packages = [ kakouneWithPlugins ];
|
||||
xdg.configFile."kak/kakrc".source = configFile;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
kakoune-no-plugins = ./no-plugins.nix;
|
||||
kakoune-use-plugins = ./use-plugins.nix;
|
||||
kakoune-whitespace-highlighter = ./whitespace-highlighter.nix;
|
||||
kakoune-whitespace-highlighter-corner-cases =
|
||||
./whitespace-highlighter-corner-cases.nix;
|
||||
|
|
13
tests/modules/programs/kakoune/no-plugins.nix
Normal file
13
tests/modules/programs/kakoune/no-plugins.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
programs.kakoune = { enable = true; };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileNotRegex home-path/share/kak/plugins.kak . # file is empty
|
||||
'';
|
||||
};
|
||||
}
|
18
tests/modules/programs/kakoune/use-plugins.nix
Normal file
18
tests/modules/programs/kakoune/use-plugins.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
programs.kakoune = {
|
||||
enable = true;
|
||||
plugins = [ pkgs.kakounePlugins.kak-powerline ];
|
||||
};
|
||||
|
||||
nmt.script = let plugins_kak = "home-path/share/kak/plugins.kak";
|
||||
in ''
|
||||
assertFileRegex ${plugins_kak} \
|
||||
'^source "/nix/store/.*-kak-powerline/share/kak/autoload/plugins/powerline/.*.kak"$'
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue