modules: make lib calls explicit where possible

This commit is contained in:
raf 2024-02-26 08:05:23 +03:00
commit 024e1a6845
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
41 changed files with 245 additions and 203 deletions

View file

@ -1,11 +1,14 @@
{
pkgs,
config,
lib,
...
}: let
inherit (builtins) toJSON;
inherit (lib) mkIf nvim mkLuaBinding mkMerge;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.lists) optionals;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkLuaBinding;
cfg = config.vim.assistant.copilot;
@ -27,16 +30,16 @@ in {
"copilot-lua"
cfg.copilotNodePackage
]
++ lib.optionals (cfg.cmp.enable) [
++ optionals (cfg.cmp.enable) [
"copilot-cmp"
];
vim.luaConfigRC.copilot = nvim.dag.entryAnywhere ''
vim.luaConfigRC.copilot = entryAnywhere ''
require("copilot").setup({
-- available options: https://github.com/zbirenbaum/copilot.lua
copilot_node_command = "${cfg.copilotNodeCommand}",
panel = {
enabled = ${lib.boolToString (!cfg.cmp.enable)},
enabled = ${boolToString (!cfg.cmp.enable)},
keymap = {
jump_prev = false,
jump_next = false,
@ -50,7 +53,7 @@ in {
},
},
suggestion = {
enabled = ${lib.boolToString (!cfg.cmp.enable)},
enabled = ${boolToString (!cfg.cmp.enable)},
keymap = {
accept = false,
accept_word = false,

View file

@ -1,10 +1,12 @@
{
pkgs,
config,
pkgs,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum float nullOr str package;
inherit (lib.meta) getExe;
cfg = config.vim.assistant.copilot;
in {
@ -14,7 +16,7 @@ in {
panel = {
position = mkOption {
type = types.enum [
type = enum [
"bottom"
"top"
"left"
@ -24,7 +26,7 @@ in {
description = "Panel position";
};
ratio = mkOption {
type = types.float;
type = float;
default = 0.4;
description = "Panel size";
};
@ -33,59 +35,68 @@ in {
mappings = {
panel = {
jumpPrev = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "[[";
description = "Jump to previous suggestion";
};
jumpNext = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "]]";
description = "Jump to next suggestion";
};
accept = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<CR>";
description = "Accept suggestion";
};
refresh = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "gr";
description = "Refresh suggestions";
};
open = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<M-CR>";
description = "Open suggestions";
};
};
suggestion = {
accept = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<M-l>";
description = "Accept suggetion";
};
acceptWord = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = null;
description = "Accept next word";
};
acceptLine = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = null;
description = "Accept next line";
};
prev = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<M-[>";
description = "Previous suggestion";
};
next = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<M-]>";
description = "Next suggestion";
};
dismiss = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<C-]>";
description = "Dismiss suggestion";
};
@ -93,8 +104,8 @@ in {
};
copilotNodeCommand = mkOption {
type = types.str;
default = "${lib.getExe cfg.copilotNodePackage}";
type = str;
default = "${getExe cfg.copilotNodePackage}";
description = ''
The command that will be executed to initiate nodejs for GitHub Copilot.
Recommended to leave as default.
@ -102,7 +113,7 @@ in {
};
copilotNodePackage = mkOption {
type = with types; nullOr package;
type = nullOr package;
default = pkgs.nodejs-slim;
description = ''
The nodeJS package that will be used for GitHub Copilot. If you are using a custom node command

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./copilot.nix
./config.nix