blob: 54fd68315561c5d565e9a1471ce3f20fc1a269fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
{
config,
lib,
...
}: let
cfg = config.soispha.programs.nvim;
in {
config.home-manager.users.soispha = lib.mkIf cfg.enable {
programs.nixvim = {
autoGroups = {
cursor_off = {clear = true;};
colorcolumn_toggle = {clear = true;};
numbertoggle = {clear = true;};
coloroverride = {clear = true;};
highlight_on_yank = {clear = true;};
create_dir = {clear = true;};
};
autoCmd = [
{
# Taken from: https://github.com/jghauser/mkdir.nvim
event = ["BufWritePre"];
pattern = ["*"];
callback = {
__raw = ''
function()
-- Get current filename, get full path (:p) and leave only the head (:h)
local dir = vim.fn.expand('<afile>:p:h')
-- This handles URLs using netrw. See ':help netrw-transparent' for details.
if dir:find('%l+://') == 1 then
return
end
if vim.fn.isdirectory(dir) == 0 then
vim.fn.mkdir(dir, 'p')
end
end
'';
};
group = "create_dir";
desc = "Create the directory of the target file on write";
}
{
event = ["TextYankPost"];
pattern = ["*"];
callback = {
__raw = ''
function()
vim.highlight.on_yank()
end
'';
};
group = "highlight_on_yank";
desc = "Highlight the yanked text";
}
{
event = ["BufWritePre"];
pattern = ["*"];
command = ''
ks | if search("\\s\\+$", 'n') != 0 | :%s/\s\+$// | endif | 's
'';
desc = ''
Remove trailing whitespace on safe
:%s/\s\+$\| \+\ze\t//g >> For trailing spaces and spaces before tabstops
'';
}
{
event = ["WinLeave"];
pattern = ["*"];
command = "set nocursorline"; # TODO: possible also nocursorcolumn
group = "cursor_off";
desc = "Display cursorline and cursorcolumn ONLY in active window.";
}
{
event = ["WinEnter"];
pattern = ["*"];
command = "set cursorline"; # TODO: possible also cursorcolumn
group = "cursor_off";
desc = "Display cursorline and cursorcolumn ONLY in active window.";
}
{
event = ["InsertEnter"];
pattern = ["*"];
command = "set colorcolumn=${config.home-manager.users.soispha.programs.nixvim.opts.colorcolumn}";
group = "colorcolumn_toggle";
desc = "Only activate the colorcolumn when focused";
}
{
event = ["BufLeave" "FocusLost" "InsertLeave" "WinLeave"];
pattern = ["*"];
command = "set colorcolumn=0";
group = "colorcolumn_toggle";
desc = "Only activate the colorcolumn when focused";
}
{
event = ["BufEnter" "FocusGained" "InsertLeave" "WinEnter"];
pattern = ["*"];
command = "if &nu && mode() != \"i\" | set rnu | endif";
group = "numbertoggle";
desc = "Change line numbers, when not focused";
}
{
event = ["BufLeave" "FocusLost" "InsertEnter" "WinLeave"];
pattern = ["*"];
command = "if &nu | set nornu | endif";
group = "numbertoggle";
desc = "Change line numbers, when not focused";
}
{
# Override LineNr
event = ["ColorScheme"];
pattern = ["*"];
command = "highlight LineNr ctermfg=DarkGrey guifg=DarkGrey ";
group = "coloroverride";
desc = "Changes Line number colors";
}
{
# Override CursorLineNr
event = ["ColorScheme"];
pattern = ["*"];
command = "highlight CursorLineNr ctermfg=White guifg=White ";
group = "coloroverride";
desc = "Changes Line number colors";
}
];
};
};
}
|