mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/pckr: init
This commit is contained in:
parent
77c5fe808a
commit
ada161d0bb
2 changed files with 240 additions and 0 deletions
114
plugins/by-name/pckr/default.nix
Normal file
114
plugins/by-name/pckr/default.nix
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
in
|
||||||
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
|
name = "pckr";
|
||||||
|
packPathName = "pckr.nvim";
|
||||||
|
package = "pckr-nvim";
|
||||||
|
|
||||||
|
maintainers = [ lib.maintainers.GaetanLepage ];
|
||||||
|
|
||||||
|
extraOptions = {
|
||||||
|
gitPackage = lib.mkPackageOption pkgs "git" {
|
||||||
|
nullable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
plugins = lib.mkOption {
|
||||||
|
default = [ ];
|
||||||
|
type =
|
||||||
|
let
|
||||||
|
pluginType = lib.types.either types.str (
|
||||||
|
types.submodule {
|
||||||
|
freeformType = with types; attrsOf anything;
|
||||||
|
options = {
|
||||||
|
path = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
example = "nvim-treesitter/nvim-treesitter";
|
||||||
|
description = ''
|
||||||
|
Repo/path to the plugin.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
requires = mkOption {
|
||||||
|
type = types.listOf pluginType;
|
||||||
|
default = [ ];
|
||||||
|
example = [
|
||||||
|
"kyazdani42/nvim-web-devicons"
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
Dependencies for this plugin.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
in
|
||||||
|
types.listOf pluginType;
|
||||||
|
example = [
|
||||||
|
"9mm/vim-closer"
|
||||||
|
"~/projects/personal/hover.nvim"
|
||||||
|
{
|
||||||
|
path = "tpope/vim-dispatch";
|
||||||
|
cond = [
|
||||||
|
{ __raw = "require('pckr.loader.cmd')('Dispatch')"; }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
path = "nvim-treesitter/nvim-treesitter";
|
||||||
|
run = ":TSUpdate";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
List of plugins to install with pckr.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
settingsExample = {
|
||||||
|
autoremove = true;
|
||||||
|
pack_dir.__raw = "vim.env.VIM .. '/pckr'";
|
||||||
|
lockfile.path.__raw = "vim.fn.stdpath('config') .. '/pckr/lockfile.lua'";
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = cfg: {
|
||||||
|
extraPackages = [ cfg.gitPackage ];
|
||||||
|
|
||||||
|
plugins.pckr.luaConfig = {
|
||||||
|
# Otherwise pckr can't find itself
|
||||||
|
pre = ''
|
||||||
|
vim.opt.rtp:prepend("${cfg.package}")
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Add plugins after calling require('pckr').setup()
|
||||||
|
post =
|
||||||
|
let
|
||||||
|
normalizePlugin =
|
||||||
|
p:
|
||||||
|
if builtins.isString p then
|
||||||
|
p
|
||||||
|
else
|
||||||
|
builtins.removeAttrs p [
|
||||||
|
"path"
|
||||||
|
"requires"
|
||||||
|
]
|
||||||
|
// {
|
||||||
|
__unkeyed = p.path;
|
||||||
|
requires = normalizePlugins p.requires;
|
||||||
|
};
|
||||||
|
|
||||||
|
normalizePlugins = lib.map normalizePlugin;
|
||||||
|
|
||||||
|
plugins = normalizePlugins cfg.plugins;
|
||||||
|
|
||||||
|
packedPlugins = if lib.length plugins == 1 then builtins.head plugins else plugins;
|
||||||
|
in
|
||||||
|
lib.mkIf (cfg.plugins != [ ]) ''
|
||||||
|
require('pckr').add(${lib.nixvim.toLuaObject packedPlugins})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
126
tests/test-sources/plugins/by-name/pckr/default.nix
Normal file
126
tests/test-sources/plugins/by-name/pckr/default.nix
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.pckr.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
defaults = {
|
||||||
|
plugins.pckr = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
pack_dir.__raw = "require('pckr.util').join_paths(vim.fn.stdpath('data'), 'site')";
|
||||||
|
max_jobs = null;
|
||||||
|
autoremove = false;
|
||||||
|
autoinstall = true;
|
||||||
|
git = {
|
||||||
|
cmd = "git";
|
||||||
|
clone_timeout = 60;
|
||||||
|
default_url_format = "https://github.com/%s";
|
||||||
|
};
|
||||||
|
log = {
|
||||||
|
level = "warn";
|
||||||
|
};
|
||||||
|
lockfile = {
|
||||||
|
path.__raw = "require('pckr.util').join_paths(vim.fn.stdpath('config'), 'pckr', 'lockfile.lua')";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
plugins.pckr = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
# https://github.com/lewis6991/pckr.nvim?tab=readme-ov-file#example
|
||||||
|
plugins = [
|
||||||
|
# Simple plugins can be specified as strings
|
||||||
|
"9mm/vim-closer"
|
||||||
|
|
||||||
|
# Lazy loading:
|
||||||
|
# Load on a specific command
|
||||||
|
{
|
||||||
|
path = "tpope/vim-dispatch";
|
||||||
|
cond = [
|
||||||
|
{ __raw = "require('pckr.loader.cmd')('Dispatch')"; }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load on specific keymap
|
||||||
|
{
|
||||||
|
path = "tpope/vim-commentary";
|
||||||
|
cond.__raw = "require('pckr.loader.keys')('n', 'gc')";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load on specific commands
|
||||||
|
# Also run code after load (see the "config" key)
|
||||||
|
{
|
||||||
|
path = "w0rp/ale";
|
||||||
|
cond.__raw = "require('pckr.loader.cmd')('ALEEnable')";
|
||||||
|
config.__raw = ''
|
||||||
|
function()
|
||||||
|
vim.cmd[[ALEEnable]]
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
|
# Local plugins can be included
|
||||||
|
"~/projects/personal/hover.nvim"
|
||||||
|
|
||||||
|
# Plugins can have post-install/update hooks
|
||||||
|
{
|
||||||
|
path = "iamcco/markdown-preview.nvim";
|
||||||
|
run = "cd app && yarn install";
|
||||||
|
cond.__raw = "require('pckr.loader.cmd')('MarkdownPreview')";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Post-install/update hook with neovim command
|
||||||
|
{
|
||||||
|
path = "nvim-treesitter/nvim-treesitter";
|
||||||
|
run = ":TSUpdate";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Post-install/update hook with call of vimscript function with argument
|
||||||
|
{
|
||||||
|
path = "glacambre/firenvim";
|
||||||
|
run.__raw = ''
|
||||||
|
function()
|
||||||
|
vim.fn['firenvim#install'](0)
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
|
# Use specific branch, dependency and run lua file after load
|
||||||
|
{
|
||||||
|
path = "glepnir/galaxyline.nvim";
|
||||||
|
branch = "main";
|
||||||
|
requires = [
|
||||||
|
"kyazdani42/nvim-web-devicons"
|
||||||
|
];
|
||||||
|
config.__raw = ''
|
||||||
|
function()
|
||||||
|
require'statusline'
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run config *before* the plugin is loaded
|
||||||
|
{
|
||||||
|
path = "whatyouhide/vim-lengthmatters";
|
||||||
|
config_pre.__raw = ''
|
||||||
|
function()
|
||||||
|
vim.g.lengthmatters_highlight_one_column = 1
|
||||||
|
vim.g.lengthmatters_excluded = {'pckr'}
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
no-packages = {
|
||||||
|
plugins.pckr = {
|
||||||
|
enable = true;
|
||||||
|
gitPackage = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue