mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-02 13:24:28 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -6,81 +6,61 @@
|
|||
...
|
||||
}:
|
||||
with helpers.vim-plugin;
|
||||
with lib; rec {
|
||||
mkCmpSourcePlugin = {
|
||||
name,
|
||||
extraPlugins ? [],
|
||||
useDefaultPackage ? true,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
rec {
|
||||
mkCmpSourcePlugin =
|
||||
{
|
||||
name,
|
||||
extraPlugins ? [ ],
|
||||
useDefaultPackage ? true,
|
||||
...
|
||||
}:
|
||||
mkVimPlugin config {
|
||||
inherit name;
|
||||
extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name});
|
||||
|
||||
maintainers = [maintainers.GaetanLepage];
|
||||
maintainers = [ maintainers.GaetanLepage ];
|
||||
};
|
||||
|
||||
extractSourcesFromOptionValue = sources:
|
||||
if isList sources
|
||||
then sources
|
||||
else [];
|
||||
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;
|
||||
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);
|
||||
# [{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
|
||||
);
|
||||
# Take only the names from the sources provided by the user
|
||||
# ["foo" "bar"]
|
||||
foundSources = lists.unique (map (source: source.name) allSources);
|
||||
|
||||
# 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);
|
||||
# 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)
|
||||
{
|
||||
lspCapabilities = mkIf (elem "nvim_lsp" foundSources) {
|
||||
lsp.capabilities = ''
|
||||
capabilities = vim.tbl_deep_extend("force", capabilities, require('cmp_nvim_lsp').default_capabilities())
|
||||
'';
|
||||
};
|
||||
in
|
||||
in
|
||||
mkMerge [
|
||||
(mkIf cfg.autoEnableSources attrsEnabled)
|
||||
lspCapabilities
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue