summary refs log tree commit diff stats
path: root/user/modules
diff options
context:
space:
mode:
authorAlan Pearce2019-10-08 22:01:42 +0200
committerAlan Pearce2019-10-08 22:01:42 +0200
commit3455bd0b573d30cce2514dd1d6f6ca9b248c23a2 (patch)
tree3978a3ab5967845c962263e6a2abe5f257afc986 /user/modules
parent0a50d682ec85bf023bebd68a3ca388001f0c0677 (diff)
downloadnixfiles-3455bd0b573d30cce2514dd1d6f6ca9b248c23a2.tar.lz
nixfiles-3455bd0b573d30cce2514dd1d6f6ca9b248c23a2.tar.zst
nixfiles-3455bd0b573d30cce2514dd1d6f6ca9b248c23a2.zip
Extract TabNine LSP config into module
Diffstat (limited to 'user/modules')
-rw-r--r--user/modules/tabnine.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/user/modules/tabnine.nix b/user/modules/tabnine.nix
new file mode 100644
index 00000000..3230bde7
--- /dev/null
+++ b/user/modules/tabnine.nix
@@ -0,0 +1,41 @@
+{ 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)} \
+          > $out
+      '';
+in
+{
+
+  options.programs.tabnine = {
+    enable = mkEnableOption "TabNine, Smart Compose for code.";
+
+    lspConfig = mkOption {
+      type = types.attrs;
+      default = {};
+      description = ''
+        LSP Server configuration written to
+        <filename>~/.config/TabNine/TabNine.toml</filename>.
+        </para><para>
+      '';
+    };
+  };
+
+  config = mkIf cfg.enable {
+    xdg.configFile."TabNine/TabNine.toml" = {
+      source = configFile cfg.lspConfig;
+    };
+  };
+}