From 3455bd0b573d30cce2514dd1d6f6ca9b248c23a2 Mon Sep 17 00:00:00 2001
From: Alan Pearce
Date: Tue, 8 Oct 2019 22:01:42 +0200
Subject: Extract TabNine LSP config into module
---
user/modules/tabnine.nix | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 user/modules/tabnine.nix
(limited to 'user/modules/tabnine.nix')
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
+ ~/.config/TabNine/TabNine.toml.
+
+ '';
+ };
+ };
+
+ config = mkIf cfg.enable {
+ xdg.configFile."TabNine/TabNine.toml" = {
+ source = configFile cfg.lspConfig;
+ };
+ };
+}
--
cgit 1.4.1