2024-02-03 23:22:06 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
helpers,
|
|
|
|
pkgs,
|
|
|
|
...
|
2024-09-01 12:52:28 +01:00
|
|
|
}:
|
2024-02-03 23:22:06 +01:00
|
|
|
let
|
|
|
|
cmpOptions = import ./options { inherit lib helpers; };
|
|
|
|
in
|
|
|
|
with lib;
|
2024-09-01 12:52:28 +01:00
|
|
|
helpers.neovim-plugin.mkNeovimPlugin {
|
2024-02-03 23:22:06 +01:00
|
|
|
name = "cmp";
|
|
|
|
originalName = "nvim-cmp";
|
|
|
|
defaultPackage = pkgs.vimPlugins.nvim-cmp;
|
|
|
|
|
|
|
|
maintainers = [ maintainers.GaetanLepage ];
|
|
|
|
|
2024-09-01 00:24:33 -05:00
|
|
|
description = ''
|
|
|
|
### Completion Source Installation
|
|
|
|
|
|
|
|
If `plugins.cmp.autoEnableSources` is `true` Nixivm will automatically enable the corresponding source
|
|
|
|
plugins. This is the default behavior, but will work only when this option is set to a list.
|
|
|
|
|
|
|
|
If you use a raw lua string or set `plugins.cmp.autoEnableSources` to `false`, you will need to explicitly enable the relevant source plugins in
|
|
|
|
your nixvim configuration.
|
|
|
|
|
|
|
|
#### With auto-enabled sources
|
|
|
|
```nix
|
|
|
|
plugins.cmp = {
|
|
|
|
autoEnableSources = true;
|
|
|
|
settings.sources = [
|
|
|
|
{ name = "nvim_lsp"; }
|
|
|
|
{ name = "path"; }
|
|
|
|
{ name = "buffer"; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Without auto-enabled sources
|
|
|
|
```nix
|
|
|
|
plugins = {
|
|
|
|
cmp = {
|
|
|
|
autoEnableSources = false;
|
|
|
|
settings.sources = [
|
|
|
|
{ name = "nvim_lsp"; }
|
|
|
|
{ name = "path"; }
|
|
|
|
{ name = "buffer"; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
cmp-nvim-lsp.enable = true;
|
|
|
|
cmp-path.enable = true;
|
|
|
|
cmp-buffer.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
```
|
|
|
|
'';
|
|
|
|
|
2024-02-03 23:22:06 +01:00
|
|
|
imports = [
|
2024-06-29 08:26:56 +01:00
|
|
|
# Introduced on 2024 February 21
|
|
|
|
# TODO: remove ~June 2024
|
2024-02-03 23:22:06 +01:00
|
|
|
./deprecations.nix
|
2024-06-29 08:26:56 +01:00
|
|
|
./auto-enable.nix
|
2024-02-03 23:22:06 +01:00
|
|
|
./sources
|
|
|
|
];
|
|
|
|
deprecateExtraOptions = true;
|
|
|
|
|
2024-06-29 08:26:56 +01:00
|
|
|
inherit (cmpOptions) settingsOptions settingsExample;
|
2024-02-03 23:22:06 +01:00
|
|
|
extraOptions = {
|
|
|
|
inherit (cmpOptions) filetype cmdline;
|
|
|
|
};
|
|
|
|
|
|
|
|
callSetup = false;
|
|
|
|
extraConfig = cfg: {
|
|
|
|
extraConfigLua =
|
|
|
|
''
|
|
|
|
local cmp = require('cmp')
|
|
|
|
cmp.setup(${helpers.toLuaObject cfg.settings})
|
|
|
|
|
|
|
|
''
|
|
|
|
+ (concatStringsSep "\n" (
|
|
|
|
mapAttrsToList (
|
|
|
|
filetype: settings: "cmp.setup.filetype('${filetype}', ${helpers.toLuaObject settings})\n"
|
|
|
|
) cfg.filetype
|
|
|
|
))
|
|
|
|
+ (concatStringsSep "\n" (
|
|
|
|
mapAttrsToList (
|
|
|
|
cmdtype: settings: "cmp.setup.cmdline('${cmdtype}', ${helpers.toLuaObject settings})\n"
|
|
|
|
) cfg.cmdline
|
|
|
|
));
|
|
|
|
};
|
|
|
|
}
|