Skip to content

Commit

Permalink
modules/files: fix creating configs of vim type
Browse files Browse the repository at this point in the history
  • Loading branch information
stasjok committed Jul 19, 2024
1 parent 55bda0c commit 134dd4b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
7 changes: 6 additions & 1 deletion modules/top-level/files/submodule.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name,
config,
lib,
pkgs,
helpers,
...
}:
Expand All @@ -22,6 +23,10 @@
path = lib.mkDefault name;
type = lib.mkDefault (if lib.hasSuffix ".vim" name then "vim" else "lua");
# No need to use mkDerivedConfig; this option is readOnly.
plugin = helpers.writeLua derivationName config.content;
plugin =
let
writeContent = if config.type == "lua" then helpers.writeLua else pkgs.writeText;
in
writeContent derivationName config.content;
};
}
16 changes: 0 additions & 16 deletions tests/modules/files.nix

This file was deleted.

29 changes: 29 additions & 0 deletions tests/test-sources/modules/files.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
after = {
files."after/ftplugin/python.lua" = {
localOpts.conceallevel = 1;

keymaps = [
{
mode = "n";
key = "<C-g>";
action = ":!python script.py<CR>";
options.silent = true;
}
];
};
};

vim-type = {
files."plugin/default_indent.vim".opts = {
shiftwidth = 2;
expandtab = true;
};

extraConfigLuaPost = ''
vim.cmd.runtime("plugin/default_indent.vim")
assert(vim.o.shiftwidth == 2, "shiftwidth is not set")
assert(vim.o.expandtab, "expandtab is not set")
'';
};
}

0 comments on commit 134dd4b

Please sign in to comment.