/
kakoune.nix
83 lines (78 loc) · 2.29 KB
/
kakoune.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ pkgs, lib, ... }:
let
sources = import ../nix/sources.nix;
nixpkgs = import sources.nixpkgs { };
kakoune = import ../lib/kakoune.nix {
pkgs = nixpkgs.pkgs;
lib = nixpkgs.lib;
};
# plugins
pluginSources = lib.filterAttrs (_: source: lib.attrByPath [ "kakoune" ] "" source == "plugin") sources;
colorSources = lib.filterAttrs (_: source: lib.attrByPath [ "kakoune" ] "" source == "colors") sources;
pluginAttrs = lib.mapAttrs (name: source:
kakoune.mkPlugin {
name = name;
src = source;
}) pluginSources;
plugins = lib.mapAttrsToList (_: plugin: plugin) pluginAttrs;
colorAttrs = lib.mapAttrs (name: source:
kakoune.mkColorPlugin {
name = name;
src = source;
}) colorSources // {
colors = kakoune.mkColorPlugin {
name = "colors";
src = ./kakoune/colors;
};
};
colors = lib.mapAttrsToList (_: color: color) colorAttrs;
in {
programs.kakoune = {
enable = true;
config = {
colorScheme = "city-lights";
scrollOff = {
columns = 0;
lines = 5;
};
numberLines = {
enable = true;
separator = ''" "'';
};
showMatching = true;
ui.enableMouse = true;
wrapLines = {
enable = true;
indent = true;
marker = "⎁";
};
hooks = [
{
commands = "auto-pairs-enable";
name = "WinCreate";
option = ".*";
}
{
commands = ''
declare-user-mode surround
map global surround s ':surround<ret>' -docstring 'Surround'
map global surround c ':change-surround<ret>' -docstring 'Change'
map global surround d ':delete-surround<ret>' -docstring 'Delete'
map global surround t ':select-surrounding-tag<ret>' -docstring 'Select tag'
map global user s ':enter-user-mode surround<ret>' -docstring 'Surround'
'';
name = "WinCreate";
option = ".*";
}
{
commands = "mkdir-buffer";
name = "BufWritePre";
option = ".*";
}
];
};
};
# plugins
home.file.".config/kak/colors".source = "${kakoune.mkColors colors}/share/kak/colors";
home.file.".config/kak/autoload".source = "${kakoune.mkPlugins plugins}/share/kak/autoload";
}