mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/nvim-cmp,copilot-cmp: change plugin for copilot completion source
This commit is contained in:
parent
660c865928
commit
0c0c3b2d9d
3 changed files with 68 additions and 1 deletions
|
@ -49,7 +49,7 @@ in
|
|||
"npm" = "cmp-npm";
|
||||
"cmp-clippy" = "cmp-clippy";
|
||||
"cmp_tabnine" = "cmp-tabnine";
|
||||
"copilot" = "cmp-copilot";
|
||||
"copilot" = "copilot-cmp";
|
||||
"dap" = "cmp-dap";
|
||||
"emoji" = "cmp-emoji";
|
||||
"greek" = "cmp-greek";
|
||||
|
|
66
plugins/completion/nvim-cmp/sources/copilot-cmp.nix
Normal file
66
plugins/completion/nvim-cmp/sources/copilot-cmp.nix
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
copilot-lua-cfg = config.plugins.copilot-lua;
|
||||
cfg = config.plugins.copilot-cmp;
|
||||
helpers = import ../../../helpers.nix {inherit lib;};
|
||||
in {
|
||||
options.plugins.copilot-cmp =
|
||||
helpers.extraOptionsOptions
|
||||
// {
|
||||
event =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; listOf str)
|
||||
''["InsertEnter" "LspAttach"]''
|
||||
''
|
||||
Configures when the source is registered.
|
||||
Unless you have a unique problem for your particular configuration you probably don't want
|
||||
to touch this.
|
||||
'';
|
||||
|
||||
fixPairs = helpers.defaultNullOpts.mkBool true ''
|
||||
Suppose you have the following code: `print('h')`.
|
||||
Copilot might try to account for the `'` and `)` and complete it with this: `print('hello`.
|
||||
|
||||
This is not good behavior for consistency reasons and will just end up deleting the two ending
|
||||
characters.
|
||||
This option fixes that.
|
||||
Don't turn this off unless you are having problems with pairs and believe this might be
|
||||
causing them.
|
||||
'';
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
warnings =
|
||||
optional
|
||||
((!isBool copilot-lua-cfg.suggestion.enabled) || copilot-lua-cfg.suggestion.enabled)
|
||||
''
|
||||
It is recommended to disable copilot's `suggestion` module, as it can interfere with
|
||||
completions properly appearing in copilot-cmp.
|
||||
''
|
||||
++ optional
|
||||
(
|
||||
(!isBool copilot-lua-cfg.panel.enabled) || copilot-lua-cfg.panel.enabled
|
||||
)
|
||||
''
|
||||
It is recommended to disable copilot's `panel` module, as it can interfere with completions
|
||||
properly appearing in copilot-cmp.
|
||||
'';
|
||||
|
||||
plugins.copilot-lua.enable = true;
|
||||
|
||||
extraConfigLua = let
|
||||
setupOptions = with cfg;
|
||||
{
|
||||
inherit event;
|
||||
fix_pairs = fixPairs;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in ''
|
||||
require('copilot_cmp').setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -11,6 +11,7 @@ in {
|
|||
# For extra cmp plugins
|
||||
imports =
|
||||
[
|
||||
./copilot-cmp.nix
|
||||
./cmp-tabnine.nix
|
||||
./crates-nvim.nix
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue