mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-25 02:08:40 +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];
|
||||
};
|
||||
|
||||
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:
|
||||
if isList sources
|
||||
then sources
|
||||
|
@ -100,16 +54,24 @@ with lib; rec {
|
|||
allSources
|
||||
);
|
||||
|
||||
# A list of known source names
|
||||
knownSourceNames = attrNames pluginAndSourceNames;
|
||||
attrsEnabled = listToAttrs (map
|
||||
(name: {
|
||||
# Name of the corresponding plugin to enable
|
||||
name = pluginAndSourceNames.${name};
|
||||
# Whether or not we enable it
|
||||
value.enable = mkIf (elem name foundSources) true;
|
||||
})
|
||||
knownSourceNames);
|
||||
# If the user has enabled the `foo` and `bar` sources, this attrs will look like:
|
||||
# {
|
||||
# cmp-foo.enable = true;
|
||||
# cmp-bar.enable = true;
|
||||
# }
|
||||
attrsEnabled =
|
||||
mapAttrs'
|
||||
(
|
||||
sourceName: pluginName: {
|
||||
name = pluginName;
|
||||
value.enable =
|
||||
mkIf
|
||||
(elem sourceName foundSources)
|
||||
true;
|
||||
}
|
||||
)
|
||||
(import ./sources.nix);
|
||||
|
||||
lspCapabilities =
|
||||
mkIf
|
||||
(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
|
||||
cmpLib = import ../cmp-helpers.nix {inherit lib config helpers pkgs;};
|
||||
cmpSourcesPluginNames = attrValues cmpLib.pluginAndSourceNames;
|
||||
cmpSourcesPluginNames = attrValues (import ../sources.nix);
|
||||
pluginModules =
|
||||
map
|
||||
(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue