nix-community.nixvim/plugins/cmp/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
2.1 KiB
Nix
Raw Permalink Normal View History

{
lib,
...
2024-09-01 12:52:28 +01:00
}:
let
2024-10-06 10:05:31 -05:00
inherit (lib.nixvim) toLuaObject;
cmpOptions = import ./options { inherit lib; };
in
2024-10-06 10:05:31 -05:00
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "cmp";
originalName = "nvim-cmp";
package = "nvim-cmp";
2024-10-06 09:57:31 -05:00
maintainers = [ lib.maintainers.GaetanLepage ];
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;
};
```
'';
imports = [
# Introduced on 2024 February 21
# TODO: remove ~June 2024
./deprecations.nix
./auto-enable.nix
./sources
];
deprecateExtraOptions = true;
inherit (cmpOptions) settingsOptions settingsExample;
extraOptions = {
inherit (cmpOptions) filetype cmdline;
};
callSetup = false;
extraConfig = cfg: {
plugins.cmp.luaConfig.content =
''
local cmp = require('cmp')
2024-10-06 10:05:31 -05:00
cmp.setup(${toLuaObject cfg.settings})
''
2024-10-06 09:57:31 -05:00
+ (lib.concatStringsSep "\n" (
lib.mapAttrsToList (
2024-10-06 10:05:31 -05:00
filetype: settings: "cmp.setup.filetype('${filetype}', ${toLuaObject settings})\n"
) cfg.filetype
))
2024-10-06 09:57:31 -05:00
+ (lib.concatStringsSep "\n" (
lib.mapAttrsToList (
2024-10-06 10:05:31 -05:00
cmdtype: settings: "cmp.setup.cmdline('${cmdtype}', ${toLuaObject settings})\n"
) cfg.cmdline
));
};
}