nix-community.nixvim/tests/test-sources/plugins/pluginmanagers/lz-n.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

167 lines
4.1 KiB
Nix
Raw Normal View History

2024-07-16 01:02:44 -03:00
let
/*
Transform plugins into attrset and set optional to true
This installs the plugin files to {runtimepath}/pack/opt, instead of {runtimepath}/pack/start.
Plugins in pack/opt are not loaded on startup, but can be later loaded with `:packadd {name}` or `require("lz.n").load({name})`
See `nixpkgs/pkgs/applications/editors/neovim/utils.nix`
See `nixpkgs/pkgs/applications/editors/vim/plugins/vim-utils.nix`
*/
optionalPlugins = map (x: (if x ? plugin then x else { plugin = x; }) // { optional = true; });
in
{
# Empty configuration
empty = {
plugins.lz-n.enable = true;
};
# Empty configuration
defaults = {
plugins.lz-n = {
enable = true;
settings = {
load.__raw = "vim.cmd.packadd";
};
};
};
# single-plugin and priority of plugins.lz-n.settings to globals.lz-n
example-single-plugin =
{ pkgs, lib, ... }:
{
extraPlugins = optionalPlugins [ pkgs.vimPlugins.neo-tree-nvim ];
2024-07-16 01:02:44 -03:00
plugins.lz-n = {
enable = true;
settings = {
load = lib.mkDefault "vim.cmd.packadd";
};
plugins = [
# enabled, on keys as rawLua
{
__unkeyed-1 = "neo-tree.nvim";
enabled = ''
function()
return true
end
'';
keys = [
{
__unkeyed-1 = "<leader>ft";
__unkeyed-2 = "<CMD>Neotree toggle<CR>";
desc = "NeoTree toggle";
}
];
after = # lua
''
2024-07-16 01:02:44 -03:00
function()
require("neo-tree").setup()
2024-07-16 01:02:44 -03:00
end
'';
}
];
2024-07-16 01:02:44 -03:00
};
};
2024-07-16 01:02:44 -03:00
example-multiple-plugin =
{ pkgs, lib, ... }:
{
extraPlugins =
with pkgs.vimPlugins;
[ onedarker-nvim ]
++ (optionalPlugins [
neo-tree-nvim
dial-nvim
vimtex
telescope-nvim
nvim-biscuits
crates-nvim
]);
2024-07-16 01:02:44 -03:00
plugins.treesitter.enable = true;
2024-07-16 01:02:44 -03:00
plugins.lz-n = {
enable = true;
plugins = [
# enabled, on keys
{
__unkeyed-1 = "neo-tree.nvim";
enabled = ''
function()
return true
end
'';
keys = [
{
__unkeyed-1 = "<leader>ft";
__unkeyed-2 = "<CMD>Neotree toggle<CR>";
desc = "NeoTree toggle";
}
];
after = # lua
''
2024-07-16 01:02:44 -03:00
function()
require("neo-tree").setup()
2024-07-16 01:02:44 -03:00
end
'';
}
# on keys as list of str and rawLua
{
__unkeyed-1 = "dial.nvim";
keys = [
"<C-a>"
{ __raw = "{ '<C-x>'; mode = 'n' }"; }
];
}
# beforeAll, before, on filetype
{
__unkeyed-1 = "vimtex";
ft = [ "plaintex" ];
beforeAll = # lua
''
2024-07-16 01:02:44 -03:00
function()
vim.g.vimtex_compiler_method = "latexrun"
2024-07-16 01:02:44 -03:00
end
'';
before = # lua
''
function()
vim.g.vimtex_compiler_method = "latexmk"
end
2024-07-16 01:02:44 -03:00
'';
}
# On event
{
__unkeyed-1 = "nvim-biscuits";
event.__raw = "{ 'BufEnter *.lua' }";
after.__raw = ''
function()
require('nvim-biscuits').setup({})
end
'';
}
# On command no setup function, priority
{
__unkeyed-1 = "telescope.nvim";
cmd = [ "Telescope" ];
priority = 500;
}
# On colorschme
{
__unkeyed-1 = "onedarker.nvim";
colorscheme = [ "onedarker" ];
}
# raw value
{
__raw = ''
{
"crates.nvim",
ft = "toml",
}
'';
}
];
2024-07-16 01:02:44 -03:00
};
};
2024-07-16 01:02:44 -03:00
}