mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 10:59:49 +01:00
feat: copilot completions in nvim-cmp sources
This commit is contained in:
parent
111c2ad317
commit
4233a2c20d
7 changed files with 55 additions and 11 deletions
|
@ -202,7 +202,10 @@ inputs: let
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.assistant = {
|
vim.assistant = {
|
||||||
copilot.enable = isMaximal;
|
copilot = {
|
||||||
|
enable = isMaximal;
|
||||||
|
cmp.enable = isMaximal;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.session = {
|
vim.session = {
|
||||||
|
|
17
flake.lock
17
flake.lock
|
@ -224,6 +224,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"copilot-cmp": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1683831407,
|
||||||
|
"narHash": "sha256-+MzEGnhlrYRvAfskOwmw69OC1CsPXt7s3z+xPe9XPqs=",
|
||||||
|
"owner": "zbirenbaum",
|
||||||
|
"repo": "copilot-cmp",
|
||||||
|
"rev": "c2cdb3c0f5078b0619055af192295830a7987790",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "zbirenbaum",
|
||||||
|
"repo": "copilot-cmp",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"copilot-lua": {
|
"copilot-lua": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -1352,6 +1368,7 @@
|
||||||
"cmp-vsnip": "cmp-vsnip",
|
"cmp-vsnip": "cmp-vsnip",
|
||||||
"codewindow-nvim": "codewindow-nvim",
|
"codewindow-nvim": "codewindow-nvim",
|
||||||
"comment-nvim": "comment-nvim",
|
"comment-nvim": "comment-nvim",
|
||||||
|
"copilot-cmp": "copilot-cmp",
|
||||||
"copilot-lua": "copilot-lua",
|
"copilot-lua": "copilot-lua",
|
||||||
"crates-nvim": "crates-nvim",
|
"crates-nvim": "crates-nvim",
|
||||||
"dashboard-nvim": "dashboard-nvim",
|
"dashboard-nvim": "dashboard-nvim",
|
||||||
|
|
|
@ -481,6 +481,11 @@
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
copilot-cmp = {
|
||||||
|
url = "github:zbirenbaum/copilot-cmp";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
# Session management
|
# Session management
|
||||||
nvim-session-manager = {
|
nvim-session-manager = {
|
||||||
url = "github:Shatur/neovim-session-manager";
|
url = "github:Shatur/neovim-session-manager";
|
||||||
|
|
|
@ -87,6 +87,7 @@ with lib; let
|
||||||
"nvim-surround"
|
"nvim-surround"
|
||||||
"nvim-dap"
|
"nvim-dap"
|
||||||
"nvim-dap-ui"
|
"nvim-dap-ui"
|
||||||
|
"copilot-cmp"
|
||||||
];
|
];
|
||||||
# You can either use the name of the plugin or a package.
|
# You can either use the name of the plugin or a package.
|
||||||
pluginsType = with types;
|
pluginsType = with types;
|
||||||
|
|
|
@ -21,16 +21,21 @@ with builtins; let
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins =
|
||||||
"copilot-lua"
|
[
|
||||||
cfg.copilotNodePackage
|
"copilot-lua"
|
||||||
];
|
cfg.copilotNodePackage
|
||||||
|
]
|
||||||
|
++ lib.optionals (cfg.cmp.enable) [
|
||||||
|
"copilot-cmp"
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.copilot = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.copilot = nvim.dag.entryAnywhere ''
|
||||||
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.copilotNodeCommand}",
|
||||||
panel = {
|
panel = {
|
||||||
|
enabled = ${lib.boolToString (!cfg.cmp.enable)},
|
||||||
keymap = {
|
keymap = {
|
||||||
jump_prev = false,
|
jump_prev = false,
|
||||||
jump_next = false,
|
jump_next = false,
|
||||||
|
@ -44,6 +49,7 @@ in {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
suggestion = {
|
suggestion = {
|
||||||
|
enabled = ${lib.boolToString (!cfg.cmp.enable)},
|
||||||
keymap = {
|
keymap = {
|
||||||
accept = false,
|
accept = false,
|
||||||
accept_word = false,
|
accept_word = false,
|
||||||
|
@ -54,6 +60,10 @@ in {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
${lib.optionalString (cfg.cmp.enable) ''
|
||||||
|
require("copilot_cmp").setup()
|
||||||
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
vim.maps.normal = mkMerge [
|
vim.maps.normal = mkMerge [
|
||||||
|
|
|
@ -10,6 +10,7 @@ with builtins; let
|
||||||
in {
|
in {
|
||||||
options.vim.assistant.copilot = {
|
options.vim.assistant.copilot = {
|
||||||
enable = mkEnableOption "GitHub Copilot AI assistant";
|
enable = mkEnableOption "GitHub Copilot AI assistant";
|
||||||
|
cmp.enable = mkEnableOption "nvim-cmp integration for GitHub Copilot";
|
||||||
|
|
||||||
panel = {
|
panel = {
|
||||||
position = mkOption {
|
position = mkOption {
|
||||||
|
@ -91,16 +92,22 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
copilot_node_command = mkOption {
|
copilotNodeCommand = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "${lib.getExe cfg.copilotNodePackage}";
|
default = "${lib.getExe cfg.copilotNodePackage}";
|
||||||
description = "Path to nodejs";
|
description = ''
|
||||||
|
The command that will be executed to initiate nodejs for GitHub Copilot.
|
||||||
|
Recommended to leave as default.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
copilotNodePackage = mkOption {
|
copilotNodePackage = mkOption {
|
||||||
type = with types; nullOr package; # TODO - maybe accept a path as well? imperative users might want to use something like nvm
|
type = with types; nullOr package;
|
||||||
default = pkgs.nodejs-slim; # this will likely need to be downgraded because Copilot does not stay up to date with NodeJS
|
default = pkgs.nodejs-slim;
|
||||||
description = "The package that will be used for Copilot. NodeJS v18 is recommended.";
|
description = ''
|
||||||
|
The nodeJS package that will be used for GitHub Copilot. If you are using a custom node command
|
||||||
|
you may want to set this option to null so that the package is not pulled from nixpkgs.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ in {
|
||||||
"buffer" = "[Buffer]";
|
"buffer" = "[Buffer]";
|
||||||
"crates" = "[Crates]";
|
"crates" = "[Crates]";
|
||||||
"path" = "[Path]";
|
"path" = "[Path]";
|
||||||
|
"copilot" = "[Copilot]";
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.maps.insert = mkMerge [
|
vim.maps.insert = mkMerge [
|
||||||
|
|
Loading…
Reference in a new issue