mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
modules/files: fix creating configs of vim type
This commit is contained in:
parent
daa94bd6c2
commit
c9a6912be5
3 changed files with 32 additions and 17 deletions
|
@ -2,6 +2,7 @@
|
||||||
name,
|
name,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
helpers,
|
helpers,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
@ -17,11 +18,12 @@
|
||||||
config =
|
config =
|
||||||
let
|
let
|
||||||
derivationName = "nvim-" + lib.replaceStrings [ "/" ] [ "-" ] name;
|
derivationName = "nvim-" + lib.replaceStrings [ "/" ] [ "-" ] name;
|
||||||
|
writeContent = if config.type == "lua" then helpers.writeLua else pkgs.writeText;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
path = lib.mkDefault name;
|
path = lib.mkDefault name;
|
||||||
type = lib.mkDefault (if lib.hasSuffix ".vim" name then "vim" else "lua");
|
type = lib.mkDefault (if lib.hasSuffix ".vim" name then "vim" else "lua");
|
||||||
# No need to use mkDerivedConfig; this option is readOnly.
|
# No need to use mkDerivedConfig; this option is readOnly.
|
||||||
plugin = helpers.writeLua derivationName config.content;
|
plugin = writeContent derivationName config.content;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
{
|
|
||||||
after = {
|
|
||||||
files."after/ftplugin/python.lua" = {
|
|
||||||
localOpts.conceallevel = 1;
|
|
||||||
|
|
||||||
keymaps = [
|
|
||||||
{
|
|
||||||
mode = "n";
|
|
||||||
key = "<C-g>";
|
|
||||||
action = ":!python script.py<CR>";
|
|
||||||
options.silent = true;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
29
tests/test-sources/modules/files.nix
Normal file
29
tests/test-sources/modules/files.nix
Normal file
|
@ -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")
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue