neovim-flake/modules/plugins/assistant/copilot/copilot.nix

132 lines
3.4 KiB
Nix
Raw Normal View History

{
config,
pkgs,
lib,
...
}: let
2024-02-17 13:51:05 +01:00
inherit (lib) mkRenamedOptionModule;
inherit (lib.options) mkEnableOption mkOption;
2024-02-17 13:51:05 +01:00
inherit (lib.types) nullOr str enum float;
inherit (lib.nvim.types) mkPluginSetupOption;
cfg = config.vim.assistant.copilot;
in {
2024-02-17 13:51:05 +01:00
imports = [
(mkRenamedOptionModule ["vim" "assistant" "copilot" "panel"] ["vim" "assistant" "copilot" "setupOpts" "panel"])
(mkRenamedOptionModule ["vim" "assistant" "copilot" "copilotNodeCommand"] ["vim" "assistant" "copilot" "setupOpts" "copilot_node_command"])
(mkRenamedOptionModule ["vim" "assistant" "copilot" "copilotNodePackage"] ["vim" "assistant" "copilot" "setupOpts" "copilot_node_command"])
];
options.vim.assistant.copilot = {
enable = mkEnableOption "GitHub Copilot AI assistant";
cmp.enable = mkEnableOption "nvim-cmp integration for GitHub Copilot";
2024-02-17 13:51:05 +01:00
setupOpts = mkPluginSetupOption "Copilot" {
copilot_node_command = mkOption {
type = str;
default = "${lib.getExe pkgs.nodejs-slim}";
description = ''
The command that will be executed to initiate nodejs for GitHub Copilot.
Recommended to leave as default.
'';
2023-04-11 14:38:27 +02:00
};
2024-02-17 13:51:05 +01:00
panel = {
enabled = mkEnableOption "Completion Panel" // {default = !cfg.cmp.enable;};
layout = {
position = mkOption {
type = enum [
"bottom"
"top"
"left"
"right"
];
default = "bottom";
description = "Panel position";
};
ratio = mkOption {
type = float;
default = 0.4;
description = "Panel size";
};
};
};
suggestion = {
enabled = mkEnableOption "Suggestions" // {default = !cfg.cmp.enable;};
# keymap = { };
2023-04-11 14:38:27 +02:00
};
};
2023-04-05 00:53:21 +02:00
mappings = {
panel = {
jumpPrev = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = "[[";
description = "Jump to previous suggestion";
};
2023-04-05 00:53:21 +02:00
jumpNext = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = "]]";
description = "Jump to next suggestion";
};
2023-04-05 00:53:21 +02:00
accept = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = "<CR>";
description = "Accept suggestion";
};
2023-04-05 00:53:21 +02:00
refresh = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = "gr";
description = "Refresh suggestions";
};
2023-04-05 00:53:21 +02:00
open = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = "<M-CR>";
description = "Open suggestions";
};
};
suggestion = {
accept = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = "<M-l>";
description = "Accept suggetion";
};
2023-04-05 00:53:21 +02:00
acceptWord = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = null;
description = "Accept next word";
};
2023-04-05 00:53:21 +02:00
acceptLine = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = null;
description = "Accept next line";
};
2023-04-05 00:53:21 +02:00
prev = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = "<M-[>";
description = "Previous suggestion";
};
2023-04-05 00:53:21 +02:00
next = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = "<M-]>";
description = "Next suggestion";
};
2023-04-05 00:53:21 +02:00
dismiss = mkOption {
type = nullOr str;
2023-04-05 00:53:21 +02:00
default = "<C-]>";
description = "Dismiss suggestion";
};
};
};
};
}