mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-25 10:18:36 +02:00
plugins/cmp: refactor source-plugin internal mechanics
This commit is contained in:
parent
892caa9b40
commit
dc038244f8
3 changed files with 65 additions and 57 deletions
|
@ -20,52 +20,6 @@ with lib; rec {
|
||||||
maintainers = [maintainers.GaetanLepage];
|
maintainers = [maintainers.GaetanLepage];
|
||||||
};
|
};
|
||||||
|
|
||||||
pluginAndSourceNames = {
|
|
||||||
"buffer" = "cmp-buffer";
|
|
||||||
"calc" = "cmp-calc";
|
|
||||||
"dap" = "cmp-dap";
|
|
||||||
"cmdline" = "cmp-cmdline";
|
|
||||||
"cmp-clippy" = "cmp-clippy";
|
|
||||||
"cmp-cmdline-history" = "cmp-cmdline-history";
|
|
||||||
"cmp_pandoc" = "cmp-pandoc-nvim";
|
|
||||||
"cmp_tabby" = "cmp-tabby";
|
|
||||||
"cmp_tabnine" = "cmp-tabnine";
|
|
||||||
"codeium" = "codeium-nvim";
|
|
||||||
"conventionalcommits" = "cmp-conventionalcommits";
|
|
||||||
"copilot" = "copilot-cmp";
|
|
||||||
"crates" = "crates-nvim";
|
|
||||||
"dictionary" = "cmp-dictionary";
|
|
||||||
"digraphs" = "cmp-digraphs";
|
|
||||||
"emoji" = "cmp-emoji";
|
|
||||||
"fish" = "cmp-fish";
|
|
||||||
"fuzzy_buffer" = "cmp-fuzzy-buffer";
|
|
||||||
"fuzzy_path" = "cmp-fuzzy-path";
|
|
||||||
"git" = "cmp-git";
|
|
||||||
"greek" = "cmp-greek";
|
|
||||||
"latex_symbols" = "cmp-latex-symbols";
|
|
||||||
"look" = "cmp-look";
|
|
||||||
"luasnip" = "cmp_luasnip";
|
|
||||||
"nvim_lsp" = "cmp-nvim-lsp";
|
|
||||||
"nvim_lsp_document_symbol" = "cmp-nvim-lsp-document-symbol";
|
|
||||||
"nvim_lsp_signature_help" = "cmp-nvim-lsp-signature-help";
|
|
||||||
"nvim_lua" = "cmp-nvim-lua";
|
|
||||||
"npm" = "cmp-npm";
|
|
||||||
"omni" = "cmp-omni";
|
|
||||||
"pandoc_references" = "cmp-pandoc-references";
|
|
||||||
"path" = "cmp-path";
|
|
||||||
"rg" = "cmp-rg";
|
|
||||||
"snippy" = "cmp-snippy";
|
|
||||||
"spell" = "cmp-spell";
|
|
||||||
"tmux" = "cmp-tmux";
|
|
||||||
"treesitter" = "cmp-treesitter";
|
|
||||||
"ultisnips" = "cmp-nvim-ultisnips";
|
|
||||||
"vim_lsp" = "cmp-vim-lsp";
|
|
||||||
"vimwiki-tags" = "cmp-vimwiki-tags";
|
|
||||||
"vsnip" = "cmp-vsnip";
|
|
||||||
"yanky" = "cmp_yanky";
|
|
||||||
"zsh" = "cmp-zsh";
|
|
||||||
};
|
|
||||||
|
|
||||||
extractSourcesFromOptionValue = sources:
|
extractSourcesFromOptionValue = sources:
|
||||||
if isList sources
|
if isList sources
|
||||||
then sources
|
then sources
|
||||||
|
@ -100,16 +54,24 @@ with lib; rec {
|
||||||
allSources
|
allSources
|
||||||
);
|
);
|
||||||
|
|
||||||
# A list of known source names
|
# If the user has enabled the `foo` and `bar` sources, this attrs will look like:
|
||||||
knownSourceNames = attrNames pluginAndSourceNames;
|
# {
|
||||||
attrsEnabled = listToAttrs (map
|
# cmp-foo.enable = true;
|
||||||
(name: {
|
# cmp-bar.enable = true;
|
||||||
# Name of the corresponding plugin to enable
|
# }
|
||||||
name = pluginAndSourceNames.${name};
|
attrsEnabled =
|
||||||
# Whether or not we enable it
|
mapAttrs'
|
||||||
value.enable = mkIf (elem name foundSources) true;
|
(
|
||||||
})
|
sourceName: pluginName: {
|
||||||
knownSourceNames);
|
name = pluginName;
|
||||||
|
value.enable =
|
||||||
|
mkIf
|
||||||
|
(elem sourceName foundSources)
|
||||||
|
true;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
(import ./sources.nix);
|
||||||
|
|
||||||
lspCapabilities =
|
lspCapabilities =
|
||||||
mkIf
|
mkIf
|
||||||
(elem "nvim_lsp" foundSources)
|
(elem "nvim_lsp" foundSources)
|
||||||
|
|
46
plugins/completion/cmp/sources.nix
Normal file
46
plugins/completion/cmp/sources.nix
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# Maps each source name to the plugin that provides it
|
||||||
|
{
|
||||||
|
buffer = "cmp-buffer";
|
||||||
|
calc = "cmp-calc";
|
||||||
|
dap = "cmp-dap";
|
||||||
|
cmdline = "cmp-cmdline";
|
||||||
|
cmp-clippy = "cmp-clippy";
|
||||||
|
cmp-cmdline-history = "cmp-cmdline-history";
|
||||||
|
cmp_pandoc = "cmp-pandoc-nvim";
|
||||||
|
cmp_tabby = "cmp-tabby";
|
||||||
|
cmp_tabnine = "cmp-tabnine";
|
||||||
|
codeium = "codeium-nvim";
|
||||||
|
conventionalcommits = "cmp-conventionalcommits";
|
||||||
|
copilot = "copilot-cmp";
|
||||||
|
crates = "crates-nvim";
|
||||||
|
dictionary = "cmp-dictionary";
|
||||||
|
digraphs = "cmp-digraphs";
|
||||||
|
emoji = "cmp-emoji";
|
||||||
|
fish = "cmp-fish";
|
||||||
|
fuzzy_buffer = "cmp-fuzzy-buffer";
|
||||||
|
fuzzy_path = "cmp-fuzzy-path";
|
||||||
|
git = "cmp-git";
|
||||||
|
greek = "cmp-greek";
|
||||||
|
latex_symbols = "cmp-latex-symbols";
|
||||||
|
look = "cmp-look";
|
||||||
|
luasnip = "cmp_luasnip";
|
||||||
|
nvim_lsp = "cmp-nvim-lsp";
|
||||||
|
nvim_lsp_document_symbol = "cmp-nvim-lsp-document-symbol";
|
||||||
|
nvim_lsp_signature_help = "cmp-nvim-lsp-signature-help";
|
||||||
|
nvim_lua = "cmp-nvim-lua";
|
||||||
|
npm = "cmp-npm";
|
||||||
|
omni = "cmp-omni";
|
||||||
|
pandoc_references = "cmp-pandoc-references";
|
||||||
|
path = "cmp-path";
|
||||||
|
rg = "cmp-rg";
|
||||||
|
snippy = "cmp-snippy";
|
||||||
|
spell = "cmp-spell";
|
||||||
|
tmux = "cmp-tmux";
|
||||||
|
treesitter = "cmp-treesitter";
|
||||||
|
ultisnips = "cmp-nvim-ultisnips";
|
||||||
|
vim_lsp = "cmp-vim-lsp";
|
||||||
|
vimwiki-tags = "cmp-vimwiki-tags";
|
||||||
|
vsnip = "cmp-vsnip";
|
||||||
|
yanky = "cmp_yanky";
|
||||||
|
zsh = "cmp-zsh";
|
||||||
|
}
|
|
@ -7,7 +7,7 @@
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
cmpLib = import ../cmp-helpers.nix {inherit lib config helpers pkgs;};
|
cmpLib = import ../cmp-helpers.nix {inherit lib config helpers pkgs;};
|
||||||
cmpSourcesPluginNames = attrValues cmpLib.pluginAndSourceNames;
|
cmpSourcesPluginNames = attrValues (import ../sources.nix);
|
||||||
pluginModules =
|
pluginModules =
|
||||||
map
|
map
|
||||||
(
|
(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue