{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.tabnine;
configFile = config:
pkgs.runCommand "TabNine.toml"
{
buildInputs = [ pkgs.remarshal ];
preferLocalBuild = true;
allowSubstitutes = false;
}
''
remarshal -if json -of toml \
< ${pkgs.writeText "config.json" (builtins.toJSON cfg.lspConfig)} \
| sed -e 's/^\["\(.*\)"\]/[\1]/' \
> $out
'';
in
{
options.programs.tabnine = {
enable = mkEnableOption "TabNine, Smart Compose for code.";
lspConfig = mkOption {
type = types.attrs;
default = {};
description = ''
LSP Server configuration written to
~/.config/TabNine/TabNine.toml.
'';
};
};
config = mkIf cfg.enable {
xdg.configFile."TabNine/TabNine.toml" = {
source = configFile cfg.lspConfig;
};
};
}