mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-23 21:09:48 +01:00
feat: add Copilot keybindings
This commit is contained in:
parent
9365a7753e
commit
5915262864
2 changed files with 85 additions and 0 deletions
|
@ -7,6 +7,10 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.assistant.copilot;
|
cfg = config.vim.assistant.copilot;
|
||||||
|
keyOrFalse = key:
|
||||||
|
if key != null
|
||||||
|
then "'${key}'"
|
||||||
|
else "false";
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
|
@ -18,6 +22,25 @@ in {
|
||||||
require("copilot").setup({
|
require("copilot").setup({
|
||||||
-- available options: https://github.com/zbirenbaum/copilot.lua
|
-- available options: https://github.com/zbirenbaum/copilot.lua
|
||||||
copilot_node_command = "${cfg.copilot_node_command}",
|
copilot_node_command = "${cfg.copilot_node_command}",
|
||||||
|
panel = {
|
||||||
|
keymap = {
|
||||||
|
jump_prev = ${keyOrFalse cfg.mappings.panel.jumpPrev},
|
||||||
|
jump_next = ${keyOrFalse cfg.mappings.panel.jumpNext},
|
||||||
|
accept = ${keyOrFalse cfg.mappings.panel.accept},
|
||||||
|
refresh = ${keyOrFalse cfg.mappings.panel.refresh},
|
||||||
|
open = ${keyOrFalse cfg.mappings.panel.open},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
suggestion = {
|
||||||
|
keymap = {
|
||||||
|
accept = ${keyOrFalse cfg.mappings.suggestion.accept},
|
||||||
|
accept_word = ${keyOrFalse cfg.mappings.suggestion.acceptWord},
|
||||||
|
accept_line = ${keyOrFalse cfg.mappings.suggestion.acceptLine},
|
||||||
|
next = ${keyOrFalse cfg.mappings.suggestion.next},
|
||||||
|
prev = ${keyOrFalse cfg.mappings.suggestion.prev},
|
||||||
|
dismiss = ${keyOrFalse cfg.mappings.suggestion.dismiss},
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,68 @@ with builtins; {
|
||||||
options.vim.assistant.copilot = {
|
options.vim.assistant.copilot = {
|
||||||
enable = mkEnableOption "Enable GitHub Copilot";
|
enable = mkEnableOption "Enable GitHub Copilot";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
panel = {
|
||||||
|
jumpPrev = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "[[";
|
||||||
|
description = "Jump to previous suggestion";
|
||||||
|
};
|
||||||
|
jumpNext = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "]]";
|
||||||
|
description = "Jump to next suggestion";
|
||||||
|
};
|
||||||
|
accept = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<CR>";
|
||||||
|
description = "Accept suggestion";
|
||||||
|
};
|
||||||
|
refresh = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "gr";
|
||||||
|
description = "Refresh suggestions";
|
||||||
|
};
|
||||||
|
open = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-CR>";
|
||||||
|
description = "Open suggestions";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
suggestion = {
|
||||||
|
accept = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-l>";
|
||||||
|
description = "Accept suggetion";
|
||||||
|
};
|
||||||
|
acceptWord = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Accept next word";
|
||||||
|
};
|
||||||
|
acceptLine = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Accept next line";
|
||||||
|
};
|
||||||
|
prev = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-[>";
|
||||||
|
description = "Previous suggestion";
|
||||||
|
};
|
||||||
|
next = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-]>";
|
||||||
|
description = "Next suggestion";
|
||||||
|
};
|
||||||
|
dismiss = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<C-]>";
|
||||||
|
description = "Dismiss suggestion";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
copilot_node_command = mkOption {
|
copilot_node_command = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "${lib.getExe pkgs.nodejs-slim-16_x}";
|
default = "${lib.getExe pkgs.nodejs-slim-16_x}";
|
||||||
|
|
Loading…
Reference in a new issue