2022-07-28 21:38:38 +02:00
|
|
|
{
|
2023-02-20 11:42:13 +01:00
|
|
|
lib,
|
2024-02-09 14:31:04 +01:00
|
|
|
helpers,
|
2023-11-06 15:04:08 +01:00
|
|
|
config,
|
2023-02-20 11:42:13 +01:00
|
|
|
pkgs,
|
|
|
|
...
|
2024-02-09 14:31:04 +01:00
|
|
|
}:
|
|
|
|
with helpers.vim-plugin;
|
2024-02-03 23:22:06 +01:00
|
|
|
with lib; rec {
|
2024-02-09 14:31:04 +01:00
|
|
|
mkCmpSourcePlugin = {
|
|
|
|
name,
|
|
|
|
extraPlugins ? [],
|
|
|
|
useDefaultPackage ? true,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
mkVimPlugin config {
|
|
|
|
inherit name;
|
|
|
|
extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name});
|
2024-02-03 23:22:06 +01:00
|
|
|
|
2024-03-04 09:35:28 +01:00
|
|
|
maintainers = [maintainers.GaetanLepage];
|
2023-02-20 11:42:13 +01:00
|
|
|
};
|
2024-02-09 14:31:04 +01:00
|
|
|
|
|
|
|
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";
|
2024-04-05 22:39:08 +01:00
|
|
|
"yanky" = "cmp_yanky";
|
2024-02-09 14:31:04 +01:00
|
|
|
"zsh" = "cmp-zsh";
|
|
|
|
};
|
2024-02-03 23:22:06 +01:00
|
|
|
|
|
|
|
extractSourcesFromOptionValue = sources:
|
|
|
|
if isList sources
|
|
|
|
then sources
|
|
|
|
else [];
|
|
|
|
|
|
|
|
autoInstallSourcePluginsModule = cfg: let
|
|
|
|
# cfg.setup.sources
|
|
|
|
setupSources = extractSourcesFromOptionValue cfg.settings.sources;
|
|
|
|
# cfg.filetype.<name>.sources
|
|
|
|
filetypeSources =
|
|
|
|
mapAttrsToList
|
|
|
|
(_: filetypeConfig:
|
|
|
|
extractSourcesFromOptionValue filetypeConfig.sources)
|
|
|
|
cfg.filetype;
|
|
|
|
# cfg.cmdline.<name>.sources
|
|
|
|
cmdlineSources =
|
|
|
|
mapAttrsToList
|
|
|
|
(_: cmdlineConfig:
|
|
|
|
extractSourcesFromOptionValue cmdlineConfig.sources)
|
|
|
|
cfg.cmdline;
|
|
|
|
|
|
|
|
# [{name = "foo";} {name = "bar"; x = 42;} ...]
|
|
|
|
allSources = flatten (setupSources ++ filetypeSources ++ cmdlineSources);
|
|
|
|
|
|
|
|
# Take only the names from the sources provided by the user
|
|
|
|
# ["foo" "bar"]
|
|
|
|
foundSources =
|
|
|
|
lists.unique
|
|
|
|
(
|
|
|
|
map
|
|
|
|
(source: source.name)
|
|
|
|
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);
|
|
|
|
lspCapabilities =
|
|
|
|
mkIf
|
|
|
|
(elem "nvim_lsp" foundSources)
|
|
|
|
{
|
|
|
|
lsp.capabilities = ''
|
|
|
|
capabilities = vim.tbl_deep_extend("force", capabilities, require('cmp_nvim_lsp').default_capabilities())
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
mkMerge [
|
|
|
|
(mkIf cfg.autoEnableSources attrsEnabled)
|
|
|
|
lspCapabilities
|
|
|
|
];
|
2024-02-09 14:31:04 +01:00
|
|
|
}
|