plugins/projections: init

This commit is contained in:
Gaetan Lepage 2025-01-10 22:51:39 +01:00 committed by nix-infra-bot
parent 4527abba58
commit 5f3785feb8
2 changed files with 177 additions and 0 deletions

View file

@ -0,0 +1,120 @@
{ lib, ... }:
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts literalLua;
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "projections";
packPathName = "projections.nvim";
package = "projections-nvim";
maintainers = [ lib.maintainers.GaetanLepage ];
settingsOptions =
let
hookGroupType =
action:
types.maybeRaw (
types.submodule {
options = {
pre = defaultNullOpts.mkRaw null ''
Callback to execute before `${action}`.
'';
post = defaultNullOpts.mkRaw null ''
Callback to execute after `${action}`.
'';
};
}
);
defaultHookGroup = {
pre = null;
post = null;
};
in
{
store_hooks = defaultNullOpts.mkNullable' {
type = hookGroupType "store_session";
pluginDefault = defaultHookGroup;
description = ''
Pre and post hooks for `store_session`.
'';
example = {
pre.__raw = ''
function()
-- nvim-tree
local nvim_tree_present, api = pcall(require, "nvim-tree.api")
if nvim_tree_present then api.tree.close() end
-- neo-tree
if pcall(require, "neo-tree") then vim.cmd [[Neotree action=close]] end
end
'';
};
};
restore_hooks = defaultNullOpts.mkNullable (hookGroupType "restore_session") defaultHookGroup ''
Pre and post hooks for `restore_session`.
'';
workspaces = defaultNullOpts.mkListOf' {
type = with types; either str (listOf (either str (listOf str)));
pluginDefault = [ ];
example = [
[
"~/Documents/dev"
[ ".git" ]
]
[
"~/repos"
[ ]
]
"~/dev"
];
description = ''
Default workspaces to search for.
'';
};
patterns = defaultNullOpts.mkListOf types.str [ ".git" ".svn" ".hg" ] ''
Default patterns to use if none were specified. These are NOT regexps.
'';
workspaces_file = defaultNullOpts.mkStr' {
pluginDefault = literalLua "vim.fn.stdpath('data') .. 'projections_workspaces.json'";
example = "path/to/file";
description = ''
Path to workspaces json file.
'';
};
sessions_directory = defaultNullOpts.mkStr' {
pluginDefault = literalLua "vim.fn.stdpath('cache') .. 'projections_sessions'";
example = "path/to/dir";
description = ''
Directory where sessions are stored.
'';
};
};
settingsExample = {
workspaces = [
[
"~/Documents/dev"
[ ".git" ]
]
[
"~/repos"
[ ]
]
"~/dev"
];
patterns = [
".git"
".svn"
".hg"
];
workspaces_file = "path/to/file";
sessions_directory = "path/to/dir";
};
}

View file

@ -0,0 +1,57 @@
{
empty = {
plugins.projections.enable = true;
};
defaults = {
plugins.projections = {
enable = true;
settings = {
store_hooks = {
pre = null;
post = null;
};
restore_hooks = {
pre = null;
post = null;
};
workspaces = [ ];
patterns = [
".git"
".svn"
".hg"
];
workspaces_file.__raw = "vim.fn.stdpath('data') .. 'projections_workspaces.json'";
sessions_directory.__raw = "vim.fn.stdpath('cache') .. 'projections_sessions'";
};
};
};
example = {
plugins.projections = {
enable = true;
settings = {
workspaces = [
[
"~/Documents/dev"
[ ".git" ]
]
[
"~/repos"
[ ]
]
"~/dev"
];
patterns = [
".git"
".svn"
".hg"
];
workspaces_file = "path/to/file";
sessions_directory = "path/to/dir";
};
};
};
}