mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/projections: init
This commit is contained in:
parent
4527abba58
commit
5f3785feb8
2 changed files with 177 additions and 0 deletions
120
plugins/by-name/projections/default.nix
Normal file
120
plugins/by-name/projections/default.nix
Normal 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";
|
||||||
|
};
|
||||||
|
}
|
57
tests/test-sources/plugins/by-name/projections/default.nix
Normal file
57
tests/test-sources/plugins/by-name/projections/default.nix
Normal 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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue