Skip to content

Commit 17f4aa5

Browse files
committed
plugins/cmp: refactor sources list & mkCmpSourcePlugin
List mkCmpSourcePlugin args directly in `sources/default.nix`, similar to LSP's language-servers list.
1 parent 3a8d4fe commit 17f4aa5

File tree

5 files changed

+218
-93
lines changed

5 files changed

+218
-93
lines changed

plugins/completion/cmp/cmp-helpers.nix

Lines changed: 0 additions & 28 deletions
This file was deleted.

plugins/completion/cmp/sources.nix

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
lib,
3+
helpers,
4+
config,
5+
pkgs,
6+
...
7+
}:
8+
{
9+
pluginName,
10+
sourceName,
11+
defaultPackage ? pkgs.vimPlugins.${pluginName},
12+
maintainers ? [ lib.maintainers.GaetanLepage ],
13+
imports ? [ ],
14+
...
15+
}@args:
16+
helpers.vim-plugin.mkVimPlugin config (
17+
builtins.removeAttrs args [
18+
"pluginName"
19+
"sourceName"
20+
]
21+
// {
22+
inherit defaultPackage maintainers;
23+
name = pluginName;
24+
25+
imports = imports ++ [
26+
# Register the source -> plugin name association
27+
{ cmpSourcePlugins.${sourceName} = pluginName; }
28+
];
29+
}
30+
)

plugins/completion/cmp/sources/codeium-nvim.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ in
1313
meta.maintainers = [ maintainers.GaetanLepage ];
1414

1515
options.plugins.codeium-nvim = helpers.neovim-plugin.extraOptionsOptions // {
16-
package = helpers.mkPluginPackageOption "codeium.nvim" pkgs.vimPlugins.codeium-nvim;
17-
1816
configPath = helpers.defaultNullOpts.mkStr {
1917
__raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'";
2018
} "The path to the config file, used to store the API key.";

plugins/completion/cmp/sources/default.nix

Lines changed: 188 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,198 @@
11
{
22
lib,
3-
config,
43
helpers,
54
pkgs,
65
...
7-
}:
8-
with lib;
6+
}@args:
97
let
10-
cmpLib = import ../cmp-helpers.nix {
11-
inherit
12-
lib
13-
config
14-
helpers
15-
pkgs
16-
;
17-
};
8+
# A list of most cmp source plugins, passed to mkCmpSourcePlugin.
9+
# More complex cmp sources can instead be defined as their own plugin
10+
# and register their source-name association using the `cmpSourcePlugins` option.
11+
sources = [
12+
{
13+
pluginName = "cmp-async-path";
14+
sourceName = "async_path";
15+
}
16+
{
17+
pluginName = "cmp-buffer";
18+
sourceName = "buffer";
19+
}
20+
{
21+
pluginName = "cmp-calc";
22+
sourceName = "calc";
23+
}
24+
{
25+
pluginName = "cmp-dap";
26+
sourceName = "dap";
27+
}
28+
{
29+
pluginName = "cmp-cmdline";
30+
sourceName = "cmdline";
31+
}
32+
{
33+
pluginName = "cmp-ai";
34+
sourceName = "cmp_ai";
35+
}
36+
{
37+
pluginName = "cmp-clippy";
38+
sourceName = "cmp-clippy";
39+
}
40+
{
41+
pluginName = "cmp-cmdline-history";
42+
sourceName = "cmp-cmdline-history";
43+
}
44+
{
45+
pluginName = "cmp-pandoc-nvim";
46+
sourceName = "cmp_pandoc";
47+
}
48+
{
49+
pluginName = "cmp-tabby";
50+
sourceName = "cmp_tabby";
51+
}
52+
{
53+
pluginName = "cmp-tabnine";
54+
sourceName = "cmp_tabnine";
55+
}
56+
{
57+
pluginName = "codeium-nvim";
58+
sourceName = "codeium";
59+
}
60+
{
61+
pluginName = "cmp-conventionalcommits";
62+
sourceName = "conventionalcommits";
63+
}
64+
{
65+
pluginName = "copilot-cmp";
66+
sourceName = "copilot";
67+
}
68+
{
69+
pluginName = "crates-nvim";
70+
sourceName = "crates";
71+
}
72+
{
73+
pluginName = "cmp-dictionary";
74+
sourceName = "dictionary";
75+
}
76+
{
77+
pluginName = "cmp-digraphs";
78+
sourceName = "digraphs";
79+
}
80+
{
81+
pluginName = "cmp-emoji";
82+
sourceName = "emoji";
83+
}
84+
{
85+
pluginName = "cmp-fish";
86+
sourceName = "fish";
87+
}
88+
{
89+
pluginName = "cmp-fuzzy-buffer";
90+
sourceName = "fuzzy_buffer";
91+
}
92+
{
93+
pluginName = "cmp-fuzzy-path";
94+
sourceName = "fuzzy_path";
95+
}
96+
{
97+
pluginName = "cmp-git";
98+
sourceName = "git";
99+
}
100+
{
101+
pluginName = "cmp-greek";
102+
sourceName = "greek";
103+
}
104+
{
105+
pluginName = "cmp-latex-symbols";
106+
sourceName = "latex_symbols";
107+
}
108+
{
109+
pluginName = "cmp-look";
110+
sourceName = "look";
111+
}
112+
{
113+
pluginName = "cmp_luasnip";
114+
sourceName = "luasnip";
115+
}
116+
{
117+
pluginName = "cmp-nvim-lsp";
118+
sourceName = "nvim_lsp";
119+
}
120+
{
121+
pluginName = "cmp-nvim-lsp-document-symbol";
122+
sourceName = "nvim_lsp_document_symbol";
123+
}
124+
{
125+
pluginName = "cmp-nvim-lsp-signature-help";
126+
sourceName = "nvim_lsp_signature_help";
127+
}
128+
{
129+
pluginName = "cmp-nvim-lua";
130+
sourceName = "nvim_lua";
131+
}
132+
{
133+
pluginName = "cmp-npm";
134+
sourceName = "npm";
135+
}
136+
{
137+
pluginName = "cmp-omni";
138+
sourceName = "omni";
139+
}
140+
{
141+
pluginName = "cmp-pandoc-references";
142+
sourceName = "pandoc_references";
143+
}
144+
{
145+
pluginName = "cmp-path";
146+
sourceName = "path";
147+
}
148+
{
149+
pluginName = "cmp-rg";
150+
sourceName = "rg";
151+
}
152+
{
153+
pluginName = "cmp-snippy";
154+
sourceName = "snippy";
155+
}
156+
{
157+
pluginName = "cmp-spell";
158+
sourceName = "spell";
159+
}
160+
{
161+
pluginName = "cmp-tmux";
162+
sourceName = "tmux";
163+
}
164+
{
165+
pluginName = "cmp-treesitter";
166+
sourceName = "treesitter";
167+
}
168+
{
169+
pluginName = "cmp-nvim-ultisnips";
170+
sourceName = "ultisnips";
171+
}
172+
{
173+
pluginName = "cmp-vim-lsp";
174+
sourceName = "vim_lsp";
175+
}
176+
{
177+
pluginName = "cmp-vimwiki-tags";
178+
sourceName = "vimwiki-tags";
179+
}
180+
{
181+
pluginName = "cmp-vsnip";
182+
sourceName = "vsnip";
183+
}
184+
{
185+
pluginName = "cmp_yanky";
186+
sourceName = "yanky";
187+
}
188+
{
189+
pluginName = "cmp-zsh";
190+
sourceName = "zsh";
191+
}
192+
];
18193

19-
cmpSourcesPluginNames = import ../sources.nix;
20-
pluginModules = mapAttrsToList (
21-
sourceName: name: cmpLib.mkCmpSourcePlugin { inherit sourceName name; }
22-
) cmpSourcesPluginNames;
194+
mkCmpSourcePlugin = import ./_mk-cmp-plugin.nix args;
195+
pluginModules = builtins.map mkCmpSourcePlugin sources;
23196
in
24197
{
25198
# For extra cmp plugins

0 commit comments

Comments
 (0)