all repos — nixfiles @ e3a41fb740bd254ef63eeaee0c70a5d854fd0490

System and user configuration, managed by nix and home-manager

Inline TabNine configuration
Alan Pearce alan@alanpearce.eu
Tue, 08 Oct 2019 19:43:28 +0200
commit

e3a41fb740bd254ef63eeaee0c70a5d854fd0490

parent

4381adba4f542479b8863879e66cb9772bf833e2

2 files changed, 52 insertions(+), 39 deletions(-)

jump to
M user/modules/tabnine.nixuser/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;
   };
 }
D user/tabnine/.config/TabNine/TabNine.toml
@@ -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"]