summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--user/modules/tabnine.nix55
-rw-r--r--user/tabnine/.config/TabNine/TabNine.toml36
2 files changed, 52 insertions, 39 deletions
diff --git a/user/modules/tabnine.nix b/user/modules/tabnine.nix
index f07850ed..8018bcca 100644
--- a/user/modules/tabnine.nix
+++ b/user/modules/tabnine.nix
@@ -1,8 +1,57 @@
 { config, pkgs, ... }:
 
+let
+  cfg = {
+    config = {
+      "language.typescript" = {
+        command = "typescript-language-server";
+        args = ["--stdio"];
+      };
+      "language.javascript" = {
+        command = "javascript-typescript-stdio";
+        args = ["--stdio"];
+      };
+      "language.css" = {
+        command = "css-languageserver";
+        args = ["--stdio"];
+      };
+      "language.scss" = {
+        command = "css-languageserver";
+        args = ["--stdio"];
+      };
+      "language.html" = {
+        command = "html-languageserver";
+        args = ["--stdio"];
+      };
+      "language.dockerfile" = {
+        command = "docker-langserver";
+        args = ["--stdio"];
+      };
+      "language.yaml" = {
+        command = "yaml-language-server";
+        args = ["--stdio"];
+      };
+      "language.haskell" = {
+        command = "hie";
+        args = ["--stdio"];
+      };
+    };
+  };
+  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.config)} \
+          > $out
+      '';
+in
 {
-  xdg.configFile.TabNine = {
-    recursive = true;
-    source = ../tabnine/.config/TabNine;
+  xdg.configFile."TabNine/TabNine.toml" = {
+    source = configFile cfg.config;
   };
 }
diff --git a/user/tabnine/.config/TabNine/TabNine.toml b/user/tabnine/.config/TabNine/TabNine.toml
deleted file mode 100644
index c239f5a0..00000000
--- a/user/tabnine/.config/TabNine/TabNine.toml
+++ /dev/null
@@ -1,36 +0,0 @@
-[language.javascript]
-command = "javascript-typescript-stdio"
-args = []
-install = [["nix-env", "-iA", "nixos-unstable.nodePackages_10_x.javascript-typescript-langserver"]]
-
-[language.typescript]
-command = "typescript-language-server"
-args = ["--stdio"]
-install = [["nix-env", "-iA", "nixos-unstable.nodePackages_10_x.typescript-language-server"]]
-
-[language.css]
-command = "css-languageserver"
-args = ["--stdio"]
-install = [["nix-env", "-iA", "nixos-unstable.nodePackages_10_x.vscode-css-languageserver-bin"]]
-
-[language.scss]
-command = "css-languageserver"
-args = ["--stdio"]
-install = [["nix-env", "-iA", "nixos-unstable.nodePackages_10_x.vscode-css-languageserver-bin"]]
-
-[language.html]
-command = "html-languageserver"
-args = ["--stdio"]
-install = [["nix-env", "-iA", "nixos-unstable.nodePackages_10_x.vscode-html-languageserver-bin"]]
-
-[language.dockerfile]
-command = "docker-langserver"
-args = ["--stdio"]
-
-[language.yaml]
-command = "yaml-language-server"
-args = ["--stdio"]
-
-[language.haskell]
-command = "hie"
-args = ["--lsp"]