From 3694a8464622ae7729a4b573e4d4220db11fe389 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 17:05:43 +0300 Subject: [PATCH] feat: separate copilot module and configuration --- modules/assistant/copilot/config.nix | 24 ++++++++++++++++++++++++ modules/assistant/copilot/copilot.nix | 20 ++++++++++++++++++++ modules/assistant/copilot/default.nix | 6 ++++++ 3 files changed, 50 insertions(+) create mode 100644 modules/assistant/copilot/config.nix create mode 100644 modules/assistant/copilot/copilot.nix create mode 100644 modules/assistant/copilot/default.nix diff --git a/modules/assistant/copilot/config.nix b/modules/assistant/copilot/config.nix new file mode 100644 index 0000000..62d0251 --- /dev/null +++ b/modules/assistant/copilot/config.nix @@ -0,0 +1,24 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.assistant.copilot; +in { + config = mkIf cfg.enable { + vim.startPlugins = [ + "copilot-lua" + pkgs.nodejs-slim-16_x + ]; + + vim.luaConfigRC.copilot = nvim.dag.entryAnywhere '' + require("copilot").setup({ + -- available options: https://github.com/zbirenbaum/copilot.lua + copilot_node_command = "${cfg.copilot_node_command}", + }) + ''; + }; +} diff --git a/modules/assistant/copilot/copilot.nix b/modules/assistant/copilot/copilot.nix new file mode 100644 index 0000000..5dc1245 --- /dev/null +++ b/modules/assistant/copilot/copilot.nix @@ -0,0 +1,20 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.assistant.copilot; +in { + options.vim.assistant.copilot = { + enable = mkEnableOption "Enable GitHub Copilot"; + + copilot_node_command = mkOption { + type = types.str; + default = "${lib.getExe pkgs.nodejs-slim-16_x}"; + description = "Path to nodejs"; + }; + }; +} diff --git a/modules/assistant/copilot/default.nix b/modules/assistant/copilot/default.nix new file mode 100644 index 0000000..fb291bd --- /dev/null +++ b/modules/assistant/copilot/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./copilot.nix + ./config.nix + ]; +}