mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
modules/output: Allow to specify text to add as extra files (#343)
To enable some features (like adding tree-sitter queries) we need to add files to specific directories in the runtime path (queries/lang/file.scm for tree-sitter queries for example). This commit adds support for specifying such files. You must be careful to not have any collisions between `files` and `extraFiles`.
This commit is contained in:
parent
52120a891d
commit
5a498edd14
4 changed files with 36 additions and 8 deletions
|
@ -86,6 +86,12 @@ in {
|
|||
description = "Extra lua packages to include with neovim";
|
||||
default = _: [];
|
||||
};
|
||||
|
||||
extraFiles = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
description = "Extra files to add to the runtime path";
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
|
|
9
tests/test-sources/modules/extra-files.nix
Normal file
9
tests/test-sources/modules/extra-files.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
query = {
|
||||
extraFiles = {
|
||||
"queries/lua/injections.scm" = ''
|
||||
;; extends
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -26,6 +26,7 @@ in {
|
|||
configFiles = let
|
||||
cfg = config.programs.nixvim;
|
||||
in
|
||||
(
|
||||
lib.mapAttrs'
|
||||
(
|
||||
_: file:
|
||||
|
@ -33,5 +34,16 @@ in {
|
|||
"nvim/${file.path}"
|
||||
{text = file.content;}
|
||||
)
|
||||
cfg.files;
|
||||
cfg.files
|
||||
)
|
||||
// (
|
||||
lib.mapAttrs'
|
||||
(
|
||||
path: content:
|
||||
lib.nameValuePair
|
||||
"nvim/${path}"
|
||||
{text = content;}
|
||||
)
|
||||
cfg.extraFiles
|
||||
);
|
||||
}
|
||||
|
|
|
@ -57,8 +57,9 @@ in {
|
|||
# A directory with all the files in it
|
||||
filesPlugin = pkgs.buildEnv {
|
||||
name = "nixvim-config";
|
||||
paths = lib.mapAttrsToList (_: file: file.plugin) files;
|
||||
ignoreCollisions = true; # Collisions can't happen by construction
|
||||
paths =
|
||||
(lib.mapAttrsToList (_: file: file.plugin) files)
|
||||
++ (lib.mapAttrsToList (path: content: pkgs.writeTextDir path content) config.extraFiles);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue