Make nki-kakoune slightly more extensible, expose it as an overlay

This commit is contained in:
Natsu Kagami 2025-04-04 14:32:20 +02:00
parent 9156c6049c
commit b3ebb46101
Signed by: nki
GPG key ID: 55A032EB38B49ADB
6 changed files with 539 additions and 505 deletions

View file

@ -189,7 +189,12 @@
in in
{ {
overlays.default = lib.composeManyExtensions overlays; overlays = {
default = lib.composeManyExtensions overlays;
kakoune = final: prev: {
nki-kakoune = final.callPackage ./packages/common/nki-kakoune { };
};
};
packages.x86_64-linux.deploy-rs = deploy-rs.packages.x86_64-linux.default; packages.x86_64-linux.deploy-rs = deploy-rs.packages.x86_64-linux.default;
apps.x86_64-linux.deploy-rs = deploy-rs.apps.x86_64-linux.default; apps.x86_64-linux.deploy-rs = deploy-rs.apps.x86_64-linux.default;

View file

@ -2,21 +2,24 @@
callPackage, callPackage,
kakoune, kakoune,
kakoune-unwrapped, kakoune-unwrapped,
nki-kak-util ? callPackage ./util.nix { },
nki-kak-lsp ? callPackage ./lsp.nix { },
nki-kak-rc ? callPackage ./rc.nix { },
nki-kak-plugins ? callPackage ./plugins.nix { util = nki-kak-util; },
nki-kak-kaktex ? callPackage ./kaktex { },
nki-kak-themes ? callPackage ./themes.nix { },
nki-kak-faces ? callPackage ./faces.nix { util = nki-kak-util; },
... ...
}: }:
let
lsp = callPackage ./lsp.nix { };
rc = (callPackage ./rc.nix { });
in
(kakoune.override { (kakoune.override {
plugins = plugins =
callPackage ./plugins.nix { } nki-kak-plugins
++ callPackage ./themes.nix { } ++ nki-kak-themes
++ [ ++ [
(callPackage ./kaktex { }) nki-kak-kaktex
(callPackage ./faces.nix { }) nki-kak-faces
rc nki-kak-rc
lsp.plugin nki-kak-lsp.plugin
]; ];
}).overrideAttrs }).overrideAttrs
(attrs: { (attrs: {
@ -27,6 +30,15 @@ in
rm "$out/bin/kak" rm "$out/bin/kak"
makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \
--set KAKOUNE_RUNTIME "$out/share/kak" \ --set KAKOUNE_RUNTIME "$out/share/kak" \
--suffix PATH ":" "${lsp.extraPaths}" --suffix PATH ":" "${nki-kak-lsp.extraPaths}"
''; '';
passthru = {
lsp = nki-kak-lsp;
rc = nki-kak-rc;
plugins = nki-kak-plugins;
kaktex = nki-kak-kaktex;
themes = nki-kak-themes;
faces = nki-kak-faces;
};
}) })

View file

@ -1,6 +1,9 @@
{ callPackage, ... }: {
callPackage,
utils ? callPackage ./utils.nix { },
...
}:
let let
utils = callPackage ./utils.nix { };
faces = { faces = {
Default = "%opt{text},%opt{base}"; Default = "%opt{text},%opt{base}";
BufferPadding = "%opt{base},%opt{base}"; BufferPadding = "%opt{base},%opt{base}";

View file

@ -19,449 +19,455 @@
marksman, marksman,
templ, templ,
rust-analyzer, rust-analyzer,
overrideConfig ? (baseConfig: baseConfig),
extraSetup ? "",
... ...
}: }:
let let
# Configuration for kak-lsp # Configuration for kak-lsp
config = { config =
languageIDs = { let
c = "c_cpp"; baseConfig = {
cpp = "c_cpp"; languageIDs = {
javascript = "javascriptreact"; c = "c_cpp";
typescript = "typescriptreact"; cpp = "c_cpp";
protobuf = "proto"; javascript = "javascriptreact";
sh = "shellscript"; typescript = "typescriptreact";
}; protobuf = "proto";
sh = "shellscript";
};
languageServers = languageServers =
let let
vscodeServerWith = vscodeServerWith =
{
name,
extraFileTypes ? [ ],
}:
{
name = "vscode-${name}-language-server";
value = {
args = [ "--stdio" ];
command = "vscode-${name}-language-server";
filetypes = [ name ] ++ extraFileTypes;
roots = [
"package.json"
".git"
];
package = nodePackages.vscode-langservers-extracted;
};
};
in
{ {
name, ccls = {
extraFileTypes ? [ ], args = [
}: "-v=2"
{ "-log-file=/tmp/ccls.log"
name = "vscode-${name}-language-server"; ];
value = { package = ccls;
args = [ "--stdio" ]; command = "ccls";
command = "vscode-${name}-language-server"; filetypes = [
filetypes = [ name ] ++ extraFileTypes; "c"
"cpp"
];
roots = [ roots = [
"compile_commands.json"
".cquery"
".git"
];
};
gopls = {
command = "gopls";
package = gopls;
filetypes = [ "go" ];
offset_encoding = "utf-8";
roots = [
"Gopkg.toml"
"go.mod"
".git"
".hg"
];
settings = {
gopls = {
hoverKind = "SynopsisDocumentation";
semanticTokens = true;
};
};
settings_section = "gopls";
};
haskell-language-server = {
args = [ "--lsp" ];
command = "haskell-language-server-wrapper";
filetypes = [ "haskell" ];
roots = [
"Setup.hs"
"stack.yaml"
"*.cabal"
"package.yaml"
];
settings_section = "haskell";
};
nil = {
command = "nil";
package = nil;
filetypes = [ "nix" ];
roots = [
"flake.nix"
"shell.nix"
".git"
];
settings.nil = {
formatting.command = [ "${lib.getExe nixfmt-rfc-style}" ];
};
};
pylsp = {
command = "pylsp";
package = python311Packages.python-lsp-server;
filetypes = [ "python" ];
offset_encoding = "utf-8";
roots = [
"requirements.txt"
"setup.py"
".git"
".hg"
];
};
# Spellchecking server
ltex-ls = {
command = "ltex-ls";
args = [ "--log-file=/tmp" ];
filetypes = [
"latex"
"typst"
];
roots = [
"main.tex"
"main.typ"
".git"
];
package = ltex-ls;
};
tailwind = {
command = "tailwindcss-language-server";
args = [ "--stdio" ];
filetypes = [
"html"
"css"
"javascript"
"typescript"
"templ"
];
roots = [
"tailwind.config.{js,cjs,mjs,ts}"
"package.json" "package.json"
".git" ".git"
]; ];
package = nodePackages.vscode-langservers-extracted; settings_section = "tailwindCSS";
settings.tailwindCSS = {
validate = "warning";
userLanguages.templ = "html";
};
package = tailwindcss-language-server;
}; };
}; elixir-ls = {
in args = [ ];
{ command = "elixir-ls";
ccls = { filetypes = [ "elixir" ];
args = [ roots = [ "mix.exs" ];
"-v=2"
"-log-file=/tmp/ccls.log"
];
package = ccls;
command = "ccls";
filetypes = [
"c"
"cpp"
];
roots = [
"compile_commands.json"
".cquery"
".git"
];
};
gopls = {
command = "gopls";
package = gopls;
filetypes = [ "go" ];
offset_encoding = "utf-8";
roots = [
"Gopkg.toml"
"go.mod"
".git"
".hg"
];
settings = {
gopls = {
hoverKind = "SynopsisDocumentation";
semanticTokens = true;
}; };
}; typescript-language-server = {
settings_section = "gopls"; args = [ "--stdio" ];
}; command = "typescript-language-server";
haskell-language-server = { filetypes = [
args = [ "--lsp" ]; "typescript"
command = "haskell-language-server-wrapper"; "javascript"
filetypes = [ "haskell" ]; ];
roots = [ roots = [ "package.json" ];
"Setup.hs" package = nodePackages.typescript-language-server;
"stack.yaml"
"*.cabal"
"package.yaml"
];
settings_section = "haskell";
};
nil = {
command = "nil";
package = nil;
filetypes = [ "nix" ];
roots = [
"flake.nix"
"shell.nix"
".git"
];
settings.nil = {
formatting.command = [ "${lib.getExe nixfmt-rfc-style}" ];
};
};
pylsp = {
command = "pylsp";
package = python311Packages.python-lsp-server;
filetypes = [ "python" ];
offset_encoding = "utf-8";
roots = [
"requirements.txt"
"setup.py"
".git"
".hg"
];
};
# Spellchecking server
ltex-ls = {
command = "ltex-ls";
args = [ "--log-file=/tmp" ];
filetypes = [
"latex"
"typst"
];
roots = [
"main.tex"
"main.typ"
".git"
];
package = ltex-ls;
};
tailwind = {
command = "tailwindcss-language-server";
args = [ "--stdio" ];
filetypes = [
"html"
"css"
"javascript"
"typescript"
"templ"
];
roots = [
"tailwind.config.{js,cjs,mjs,ts}"
"package.json"
".git"
];
settings_section = "tailwindCSS";
settings.tailwindCSS = {
validate = "warning";
userLanguages.templ = "html";
};
package = tailwindcss-language-server;
};
elixir-ls = {
args = [ ];
command = "elixir-ls";
filetypes = [ "elixir" ];
roots = [ "mix.exs" ];
};
typescript-language-server = {
args = [ "--stdio" ];
command = "typescript-language-server";
filetypes = [
"typescript"
"javascript"
];
roots = [ "package.json" ];
package = nodePackages.typescript-language-server;
};
fsautocomplete = {
args = [
"--adaptive-lsp-server-enabled"
"--project-graph-enabled"
"--source-text-factory"
"RoslynSourceText"
];
command = "fsautocomplete";
filetypes = [ "fsharp" ];
roots = [ "*.fsproj" ];
settings_section = "FSharp";
settings.FSharp = {
AutomaticWorkspaceInit = true;
};
package = fsautocomplete;
};
metals = {
command = "metals";
filetypes = [ "scala" ];
roots = [
"build.sbt"
"build.sc"
"build.mill"
];
settings_section = "metals";
settings.metals = {
inlayHints.inferredTypes.enable = true;
inlayHints.typeParameters.enable = true;
inlayHints.hintsInPatternMatch.enable = true;
# From kakoune-lsp's own options
icons = "unicode";
isHttpEnabled = true;
statusBarProvider = "log-message";
compilerOptions = {
overrideDefFormat = "unicode";
}; };
fsautocomplete = {
args = [
"--adaptive-lsp-server-enabled"
"--project-graph-enabled"
"--source-text-factory"
"RoslynSourceText"
];
command = "fsautocomplete";
filetypes = [ "fsharp" ];
roots = [ "*.fsproj" ];
settings_section = "FSharp";
settings.FSharp = {
AutomaticWorkspaceInit = true;
};
package = fsautocomplete;
};
metals = {
command = "metals";
filetypes = [ "scala" ];
roots = [
"build.sbt"
"build.sc"
"build.mill"
];
settings_section = "metals";
settings.metals = {
inlayHints.inferredTypes.enable = true;
inlayHints.typeParameters.enable = true;
inlayHints.hintsInPatternMatch.enable = true;
# From kakoune-lsp's own options
icons = "unicode";
isHttpEnabled = true;
statusBarProvider = "log-message";
compilerOptions = {
overrideDefFormat = "unicode";
};
};
package = metals;
};
texlab = {
command = "texlab";
filetypes = [ "latex" ];
roots = [
"main.tex"
"all.tex"
".git"
];
settings_section = "texlab";
settings.texlab = {
build.executable = "latexmk";
build.args = [
"-pdf"
"-shell-escape"
"-interaction=nonstopmode"
"-synctex=1"
"%f"
];
build.forwardSearchAfter = true;
build.onSave = true;
# forwardSearch =
# (if pkgs.stdenv.isDarwin then {
# executable = "/Applications/Skim.app/Contents/SharedSupport/displayline";
# args = [ "-r" "-g" "%l" "%p" "%f" ];
# } else
# {
# executable = "${pkgs.zathura}/bin/zathura";
# args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ];
# });
};
package = texlab;
};
tinymist = {
command = "tinymist";
filetypes = [ "typst" ];
roots = [
"main.typ"
".git"
];
settings_section = "tinymist";
settings.tinymist = {
exportPdf = "onSave";
formatterMode = "typstfmt";
};
package = tinymist;
};
marksman = {
command = "marksman";
filetypes = [ "markdown" ];
roots = [
".marksman.toml"
".git"
];
package = marksman;
};
templ = {
command = "templ";
args = [ "lsp" ];
filetypes = [ "templ" ];
roots = [
"go.mod"
".git"
];
package = templ;
};
rust-analyzer = {
args = [ ];
command = "rust-analyzer";
filetypes = [ "rust" ];
roots = [ "Cargo.toml" ];
package = rust-analyzer;
};
}
// (builtins.listToAttrs (
builtins.map
(
ft:
vscodeServerWith {
name = ft;
extraFileTypes = if ft == "json" then [ ] else [ "templ" ];
}
)
[
"html"
"css"
"json"
]
));
faces = [
## Items
# (Rust) Macros
{
face = "attribute";
token = "attribute";
}
{
face = "attribute";
token = "derive";
}
{
face = "macro";
token = "macro";
} # Function-like Macro
# Keyword and Fixed Tokens
{
face = "keyword";
token = "keyword";
}
{
face = "operator";
token = "operator";
}
# Functions and Methods
{
face = "function";
token = "function";
}
{
face = "method";
token = "method";
}
# Constants
{
face = "string";
token = "string";
}
{
face = "format_specifier";
token = "formatSpecifier";
}
# Variables
{
face = "variable";
token = "variable";
modifiers = [ "readonly" ];
}
{
face = "mutable_variable";
token = "variable";
}
{
face = "module";
token = "namespace";
}
{
face = "variable";
token = "type_parameter";
}
{
face = "class";
token = "enum";
}
{
face = "class";
token = "struct";
}
{
face = "class";
token = "trait";
}
{
face = "class";
token = "union";
}
{
face = "class";
token = "class";
}
## Comments
{
face = "documentation";
token = "comment";
modifiers = [ "documentation" ];
}
{
face = "comment";
token = "comment";
}
# Typst
{
face = "header";
token = "heading";
}
{
face = "ts_markup_link_url";
token = "link";
}
{
face = "ts_markup_link_uri";
token = "ref";
}
{
face = "ts_markup_link_label";
token = "label";
}
{
face = "ts_property";
token = "pol";
}
{
face = "ts_markup_list_checked";
token = "marker";
}
{
face = "ts_constant_builtin_boolean";
token = "bool";
}
{
face = "ts_keyword_control";
token = "delim";
}
{
face = "ts_number";
token = "text";
modifiers = [ "math" ];
}
{
face = "ts_markup_bold";
token = "text";
modifiers = [ "strong" ];
}
{
face = "ts_markup_italic";
token = "text";
modifiers = [ "emph" ];
}
];
raw = {
server = {
timeout = 1800;
}; };
package = metals; snippet_support = false;
verbosity = 255;
}; };
texlab = {
command = "texlab";
filetypes = [ "latex" ];
roots = [
"main.tex"
"all.tex"
".git"
];
settings_section = "texlab";
settings.texlab = {
build.executable = "latexmk";
build.args = [
"-pdf"
"-shell-escape"
"-interaction=nonstopmode"
"-synctex=1"
"%f"
];
build.forwardSearchAfter = true;
build.onSave = true;
# forwardSearch =
# (if pkgs.stdenv.isDarwin then {
# executable = "/Applications/Skim.app/Contents/SharedSupport/displayline";
# args = [ "-r" "-g" "%l" "%p" "%f" ];
# } else
# {
# executable = "${pkgs.zathura}/bin/zathura";
# args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ];
# });
};
package = texlab;
};
tinymist = {
command = "tinymist";
filetypes = [ "typst" ];
roots = [
"main.typ"
".git"
];
settings_section = "tinymist";
settings.tinymist = {
exportPdf = "onSave";
formatterMode = "typstfmt";
};
package = tinymist;
};
marksman = {
command = "marksman";
filetypes = [ "markdown" ];
roots = [
".marksman.toml"
".git"
];
package = marksman;
};
templ = {
command = "templ";
args = [ "lsp" ];
filetypes = [ "templ" ];
roots = [
"go.mod"
".git"
];
package = templ;
};
rust-analyzer = {
args = [ ];
command = "rust-analyzer";
filetypes = [ "rust" ];
roots = [ "Cargo.toml" ];
package = rust-analyzer;
};
}
// (builtins.listToAttrs (
builtins.map
(
ft:
vscodeServerWith {
name = ft;
extraFileTypes = if ft == "json" then [ ] else [ "templ" ];
}
)
[
"html"
"css"
"json"
]
));
faces = [
## Items
# (Rust) Macros
{
face = "attribute";
token = "attribute";
}
{
face = "attribute";
token = "derive";
}
{
face = "macro";
token = "macro";
} # Function-like Macro
# Keyword and Fixed Tokens
{
face = "keyword";
token = "keyword";
}
{
face = "operator";
token = "operator";
}
# Functions and Methods
{
face = "function";
token = "function";
}
{
face = "method";
token = "method";
}
# Constants
{
face = "string";
token = "string";
}
{
face = "format_specifier";
token = "formatSpecifier";
}
# Variables
{
face = "variable";
token = "variable";
modifiers = [ "readonly" ];
}
{
face = "mutable_variable";
token = "variable";
}
{
face = "module";
token = "namespace";
}
{
face = "variable";
token = "type_parameter";
}
{
face = "class";
token = "enum";
}
{
face = "class";
token = "struct";
}
{
face = "class";
token = "trait";
}
{
face = "class";
token = "union";
}
{
face = "class";
token = "class";
}
## Comments
{
face = "documentation";
token = "comment";
modifiers = [ "documentation" ];
}
{
face = "comment";
token = "comment";
}
# Typst
{
face = "header";
token = "heading";
}
{
face = "ts_markup_link_url";
token = "link";
}
{
face = "ts_markup_link_uri";
token = "ref";
}
{
face = "ts_markup_link_label";
token = "label";
}
{
face = "ts_property";
token = "pol";
}
{
face = "ts_markup_list_checked";
token = "marker";
}
{
face = "ts_constant_builtin_boolean";
token = "bool";
}
{
face = "ts_keyword_control";
token = "delim";
}
{
face = "ts_number";
token = "text";
modifiers = [ "math" ];
}
{
face = "ts_markup_bold";
token = "text";
modifiers = [ "strong" ];
}
{
face = "ts_markup_italic";
token = "text";
modifiers = [ "emph" ];
}
];
raw = {
server = {
timeout = 1800;
}; };
snippet_support = false; in
verbosity = 255; overrideConfig baseConfig;
};
};
per-lang-config = per-lang-config =
lang: lang:
@ -602,6 +608,9 @@ in
## Faces ## Faces
${faces-config} ${faces-config}
## Extra setup
${extraSetup}
} }
''; '';
} }

View file

@ -1,59 +1,14 @@
{ {
pkgs, callPackage,
symlinkJoin, utils ? callPackage ./utils.nix { },
writeTextDir, fetchFromGitHub,
kakouneUtils, fetchFromGitLab,
luajit,
... ...
}: }:
with { with {
inherit (kakouneUtils) buildKakounePluginFrom2Nix; inherit (utils) toDir writeModuleWrapper kakounePlugin;
}; };
let
toDir = name: file: writeTextDir name (builtins.readFile file);
writeActivationScript =
script:
writeTextDir "on-load.kak" ''
hook global KakBegin .* %{
${script}
}
'';
writeModuleWrapper =
name: script:
writeTextDir "module.kak" ''
provide-module ${name} %
${script}
'';
kakounePlugin =
{
name,
src,
wrapAsModule ? false,
activationScript ? null,
...
}@attrs:
let
module = if wrapAsModule then writeModuleWrapper name (builtins.readFile src) else src;
in
buildKakounePluginFrom2Nix {
pname = name;
version = attrs.version or "latest";
src =
if activationScript == null then
module
else
symlinkJoin {
name = "${name}-src";
paths = [
module
(writeActivationScript activationScript)
];
};
};
in
builtins.map kakounePlugin [ builtins.map kakounePlugin [
# My own scripts # My own scripts
{ {
@ -68,7 +23,7 @@ builtins.map kakounePlugin [
# Plugins # Plugins
{ {
name = "luar"; name = "luar";
src = pkgs.fetchFromGitHub { src = fetchFromGitHub {
owner = "gustavo-hms"; owner = "gustavo-hms";
repo = "luar"; repo = "luar";
rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450";
@ -78,12 +33,12 @@ builtins.map kakounePlugin [
# Enable luar # Enable luar
require-module luar require-module luar
# Use luajit # Use luajit
set-option global luar_interpreter ${pkgs.luajit}/bin/luajit set-option global luar_interpreter ${luajit}/bin/luajit
''; '';
} }
{ {
name = "peneira"; name = "peneira";
src = pkgs.fetchFromGitHub { src = fetchFromGitHub {
owner = "gustavo-hms"; owner = "gustavo-hms";
repo = "peneira"; repo = "peneira";
rev = "b56dd10bb4771da327b05a9071b3ee9a092f9788"; rev = "b56dd10bb4771da327b05a9071b3ee9a092f9788";
@ -128,7 +83,7 @@ builtins.map kakounePlugin [
} }
{ {
name = "kakoune-focus"; name = "kakoune-focus";
src = pkgs.fetchFromGitHub { src = fetchFromGitHub {
owner = "caksoylar"; owner = "caksoylar";
repo = "kakoune-focus"; repo = "kakoune-focus";
rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0";
@ -140,7 +95,7 @@ builtins.map kakounePlugin [
} }
{ {
name = "kakoune-inc-dec"; name = "kakoune-inc-dec";
src = pkgs.fetchFromGitLab { src = fetchFromGitLab {
owner = "Screwtapello"; owner = "Screwtapello";
repo = "kakoune-inc-dec"; repo = "kakoune-inc-dec";
rev = "7bfe9c51"; rev = "7bfe9c51";
@ -158,14 +113,10 @@ builtins.map kakounePlugin [
}) })
+ "/rc"; + "/rc";
} }
# {
# name = "kakoune-discord";
# src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc";
# }
rec { rec {
name = "kakoune-mirror"; name = "kakoune-mirror";
src = src =
pkgs.fetchFromGitHub { fetchFromGitHub {
owner = "Delapouite"; owner = "Delapouite";
repo = "kakoune-mirror"; repo = "kakoune-mirror";
rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15";
@ -182,7 +133,7 @@ builtins.map kakounePlugin [
} }
{ {
name = "unicode-math"; name = "unicode-math";
src = pkgs.fetchFromGitHub { src = fetchFromGitHub {
owner = "natsukagami"; owner = "natsukagami";
repo = "kakoune-unicode-math"; repo = "kakoune-unicode-math";
rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d";
@ -199,7 +150,7 @@ builtins.map kakounePlugin [
} }
{ {
name = "kakoune-buffers"; name = "kakoune-buffers";
src = pkgs.fetchFromGitHub { src = fetchFromGitHub {
owner = "Delapouite"; owner = "Delapouite";
repo = "kakoune-buffers"; repo = "kakoune-buffers";
rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881";

View file

@ -1,5 +1,14 @@
{ lib, writeTextDir, ... }:
{ {
lib,
writeTextDir,
kakouneUtils,
symlinkJoin,
...
}:
with {
inherit (kakouneUtils) buildKakounePluginFrom2Nix;
};
rec {
mkFacesScript = mkFacesScript =
name: faces: name: faces:
writeTextDir "share/kak/autoload/${name}/faces.kak" '' writeTextDir "share/kak/autoload/${name}/faces.kak" ''
@ -9,4 +18,49 @@
)} )}
} }
''; '';
toDir = name: file: writeTextDir name (builtins.readFile file);
writeActivationScript =
script:
writeTextDir "on-load.kak" ''
hook global KakBegin .* %{
${script}
}
'';
writeModuleWrapper =
name: script:
writeTextDir "module.kak" ''
provide-module ${name} %
${script}
'';
kakounePlugin =
{
name,
src,
wrapAsModule ? false,
activationScript ? null,
...
}@attrs:
let
module = if wrapAsModule then writeModuleWrapper name (builtins.readFile src) else src;
in
buildKakounePluginFrom2Nix {
pname = name;
version = attrs.version or "latest";
src =
if activationScript == null then
module
else
symlinkJoin {
name = "${name}-src";
paths = [
module
(writeActivationScript activationScript)
];
};
};
} }