aboutsummaryrefslogtreecommitdiffstats
path: root/hm/soispha/conf/nvim/autocmds
diff options
context:
space:
mode:
Diffstat (limited to 'hm/soispha/conf/nvim/autocmds')
-rw-r--r--hm/soispha/conf/nvim/autocmds/default.nix99
1 files changed, 99 insertions, 0 deletions
diff --git a/hm/soispha/conf/nvim/autocmds/default.nix b/hm/soispha/conf/nvim/autocmds/default.nix
new file mode 100644
index 00000000..cb0311fb
--- /dev/null
+++ b/hm/soispha/conf/nvim/autocmds/default.nix
@@ -0,0 +1,99 @@
+{config, ...}: {
+ programs.nixvim = {
+ autoGroups = {
+ cursor_off = {clear = true;};
+ colorcolumn_toggle = {clear = true;};
+ numbertoggle = {clear = true;};
+ coloroverride = {clear = true;};
+ highlight_on_yank = {clear = true;};
+ };
+ autoCmd = [
+ {
+ event = ["TextYankPost"];
+ pattern = ["*"];
+ callback = {
+ __raw = ''
+ function()
+ vim.highlight.on_yank()
+ end
+ '';
+ };
+ group = "highlight_on_yank";
+ description = "Highlight the yanked text";
+ }
+ {
+ event = ["BufWritePre"];
+ pattern = ["*"];
+ command = ''
+ ks | if search("\\s\\+$", 'n') != 0 | :%s/\s\+$// | endif | 's
+ '';
+ description = ''
+ 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";
+ description = "Display cursorline and cursorcolumn ONLY in active window.";
+ }
+ {
+ event = ["WinEnter"];
+ pattern = ["*"];
+ command = "set cursorline"; # TODO: possible also cursorcolumn
+ group = "cursor_off";
+ description = "Display cursorline and cursorcolumn ONLY in active window.";
+ }
+
+ {
+ event = ["InsertEnter"];
+ pattern = ["*"];
+ command = "set colorcolumn=${config.programs.nixvim.options.colorcolumn}";
+ group = "colorcolumn_toggle";
+ description = "Only activate the colorcolumn when focused";
+ }
+ {
+ event = ["BufLeave" "FocusLost" "InsertLeave" "WinLeave"];
+ pattern = ["*"];
+ command = "set colorcolumn=0";
+ group = "colorcolumn_toggle";
+ description = "Only activate the colorcolumn when focused";
+ }
+
+ {
+ event = ["BufEnter" "FocusGained" "InsertLeave" "WinEnter"];
+ pattern = ["*"];
+ command = "if &nu && mode() != \"i\" | set rnu | endif";
+ group = "numbertoggle";
+ description = "Change line numbers, when not focused";
+ }
+ {
+ event = ["BufLeave" "FocusLost" "InsertEnter" "WinLeave"];
+ pattern = ["*"];
+ command = "if &nu | set nornu | endif";
+ group = "numbertoggle";
+ description = "Change line numbers, when not focused";
+ }
+
+ {
+ # Override LineNr
+ event = ["ColorScheme"];
+ pattern = ["*"];
+ command = "highlight LineNr ctermfg=DarkGrey guifg=DarkGrey ";
+ group = "coloroverride";
+ description = "Changes Line number colors";
+ }
+ {
+ # Override CursorLineNr
+ event = ["ColorScheme"];
+ pattern = ["*"];
+ command = "highlight CursorLineNr ctermfg=White guifg=White ";
+ group = "coloroverride";
+ description = "Changes Line number colors";
+ }
+ ];
+ };
+}