about summary refs log tree commit diff stats
path: root/home-manager/soispha/config/neovim/nixvim/autocmds/default.nix
blob: d736443eba0a44f13a8348a508ae6492145a28c2 (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
{...}: {
  programs.nixvim = {
    autoGroups = {
      cursor_off = {clear = true;};
      numbertoggle = {clear = true;};
    };
    autoCmd = [
      {
        event = ["BufWritePre"];
        pattern = ["*"];
        command = ''
          ks | if search("\\s\\+$", 'n') != 0 :%s/\s\+//g 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 = ["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 fucused";
      }

      {
        # 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";
      }
    ];
  };
}