2023-06-22 10:21:24 +02:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
2023-06-22 10:21:24 +02:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
copilot-lua-cfg = config.plugins.copilot-lua;
|
|
|
|
cfg = config.plugins.copilot-cmp;
|
|
|
|
in
|
|
|
|
{
|
2024-01-25 16:15:55 +01:00
|
|
|
options.plugins.copilot-cmp = helpers.neovim-plugin.extraOptionsOptions // {
|
2023-06-22 10:21:24 +02:00
|
|
|
event =
|
2024-10-06 09:57:31 -05:00
|
|
|
helpers.defaultNullOpts.mkListOf lib.types.str
|
2024-06-11 16:51:18 +01:00
|
|
|
[
|
|
|
|
"InsertEnter"
|
|
|
|
"LspAttach"
|
|
|
|
]
|
2023-06-22 10:21:24 +02:00
|
|
|
''
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-10-06 09:57:31 -05:00
|
|
|
config = lib.mkIf cfg.enable {
|
2023-06-22 10:21:24 +02:00
|
|
|
warnings =
|
2024-10-06 09:57:31 -05:00
|
|
|
lib.optional
|
|
|
|
((!lib.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.
|
|
|
|
''
|
|
|
|
++ lib.optional ((!lib.isBool copilot-lua-cfg.panel.enabled) || copilot-lua-cfg.panel.enabled) ''
|
2023-06-22 10:21:24 +02:00
|
|
|
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})
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|