Skip to content

Commit 37a6d08

Browse files
committed
plugins/oil-git-status: init
1 parent c26f5c2 commit 37a6d08

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
lib,
3+
config,
4+
options,
5+
...
6+
}:
7+
lib.nixvim.plugins.mkNeovimPlugin {
8+
name = "oil-git-status";
9+
packPathName = "oil-git-status.nvim";
10+
package = "oil-git-status-nvim";
11+
12+
description = ''
13+
Add Git Status to oil.nvim directory listings.
14+
15+
Git status is added to the listing asynchronously after creating the oil directory
16+
17+
listing so it won't slow oil down on big repositories. The plugin puts the status in two new sign columns
18+
19+
the left being the status of the index, the right being the status of the working directory
20+
21+
`win_options.signcolumn` needs to be configured in `plugins.oil.settings`:
22+
```nix
23+
plugins.oil = {
24+
enable = true;
25+
settings = {
26+
win_options = {
27+
signcolumn = "yes:2,";
28+
};
29+
};
30+
};
31+
```
32+
'';
33+
34+
maintainers = [ lib.maintainers.FKouhai ];
35+
36+
# Ensure oil-git-status is set up after oil is loaded
37+
configLocation = lib.mkOrder 1100 "extraConfigLua";
38+
39+
dependencies = [
40+
"git"
41+
];
42+
43+
extraConfig = cfg: {
44+
warnings = lib.nixvim.mkWarnings "plugins.oil-git-status" [
45+
{
46+
when = !config.plugins.oil.enable;
47+
message = ''
48+
This plugin requires `plugins.oil` to be enabled
49+
${options.plugins.oil.enable} = true;
50+
'';
51+
}
52+
{
53+
when =
54+
let
55+
value = config.plugins.oil.settings.win_options.signcolumn or null;
56+
isKnownBadStr = lib.lists.elem value [
57+
"yes"
58+
"yes:"
59+
"yes:0"
60+
"yes:1"
61+
];
62+
hasYes = lib.strings.hasInfix "yes" value;
63+
in
64+
!(lib.strings.isString value && hasYes && !isKnownBadStr);
65+
66+
message = ''
67+
This plugin requires the following `plugins.oil` setting:
68+
${options.plugins.oil.settings} = {
69+
win_options= {
70+
signcolumn = "yes:2";
71+
};
72+
};`
73+
'';
74+
}
75+
];
76+
};
77+
78+
settingsExample = {
79+
show_ignored = false;
80+
};
81+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
# empty test case is not needed since having it would make the warning throw an error
3+
combine-plugins = {
4+
performance.combinePlugins.enable = true;
5+
plugins.oil = {
6+
enable = true;
7+
settings = {
8+
win_options = {
9+
signcolumn = "yes:2,";
10+
};
11+
};
12+
};
13+
plugins.oil-git-status = {
14+
enable = true;
15+
settings = {
16+
show_ignored = false;
17+
};
18+
};
19+
};
20+
21+
with-oil = {
22+
# set settings.win_options.signcolumn since oil-git-status relies on that particular setting in order to function
23+
plugins.oil = {
24+
enable = true;
25+
settings = {
26+
win_options = {
27+
signcolumn = "yes:2,";
28+
};
29+
};
30+
};
31+
plugins.oil-git-status.enable = true;
32+
};
33+
34+
}

0 commit comments

Comments
 (0)