Skip to content

Commit 3c130ce

Browse files
committed
modules/files: fix creating configs of vim type
1 parent daa94bd commit 3c130ce

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

modules/top-level/files/submodule.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name,
33
config,
44
lib,
5+
pkgs,
56
helpers,
67
...
78
}:
@@ -22,6 +23,10 @@
2223
path = lib.mkDefault name;
2324
type = lib.mkDefault (if lib.hasSuffix ".vim" name then "vim" else "lua");
2425
# No need to use mkDerivedConfig; this option is readOnly.
25-
plugin = helpers.writeLua derivationName config.content;
26+
plugin =
27+
let
28+
writeContent = if config.type == "lua" then helpers.writeLua else pkgs.writeText;
29+
in
30+
writeContent derivationName config.content;
2631
};
2732
}

tests/modules/files.nix

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
after = {
3+
files."after/ftplugin/python.lua" = {
4+
localOpts.conceallevel = 1;
5+
6+
keymaps = [
7+
{
8+
mode = "n";
9+
key = "<C-g>";
10+
action = ":!python script.py<CR>";
11+
options.silent = true;
12+
}
13+
];
14+
};
15+
};
16+
17+
vim-type = {
18+
files."plugin/default_indent.vim".opts = {
19+
shiftwidth = 2;
20+
expandtab = true;
21+
};
22+
23+
extraConfigLuaPost = ''
24+
vim.cmd.runtime("plugin/default_indent.vim")
25+
assert(vim.o.shiftwidth == 2, "shiftwidth is not set")
26+
assert(vim.o.expandtab, "expandtab is not set")
27+
'';
28+
};
29+
}

0 commit comments

Comments
 (0)