zaphyra's git: nixfiles

zaphyra's nixfiles

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 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
227 
{
  config,
  systemConfig,
  pkgs,
  lib,
  ...
}:

{
  options = {
    zaphyra.programs.micro.enable = lib.mkOption {
      type = lib.types.bool;
      default = true;
    };

    programs.micro.lsp-servers = lib.mkOption {
      default = { };
      type = lib.types.attrsOf (
        lib.types.submodule {
          options = {
            command = lib.mkOption {
              type = lib.types.str;
            };
            options = lib.mkOption {
              inherit ((pkgs.formats.json { })) type;
              default = { };
            };
          };
        }
      );
    };
  };

  config = lib.mkIf config.zaphyra.programs.micro.enable {
    programs = {
      micro = {
        enable = true;
        package =
          if systemConfig.modules.presets.graphical.enable then pkgs.micro-with-wl-clipboard else pkgs.micro;
        settings = {
          "*.nix".tabstospaces = true;
          "*.nix".tabmovement = true;
          "*.nix".tabsize = 2;

          "*.nim".tabstospaces = true;
          "*.nim".tabmovement = true;
          "*.nim".tabsize = 2;

          clipboard = "terminal";

          scrollbar = true;
          eofnewline = false;
          wordwrap = true;
          softwrap = true;

          ignorecase = true;
          savehistory = false;

          "lsp.formatOnSave" = true;
          "lsp.tabcompletion" = true;
          "lsp.autocompleteDetails" = false;
          "lsp.server" =
            if !systemConfig.modules.presets.graphical.enable then
              ""
            else
              (lib.concatMapAttrsStringSep "," (
                name: value:
                lib.concatStringsSep "=" (
                  [
                    name
                    value.command
                  ]
                  ++ (lib.optionals (lib.hasAttr "options" value) [
                    (builtins.toJSON value.options)
                  ])
                )
              ) config.programs.micro.lsp-servers);
        };
      };
    };

    home = {
      sessionVariables.EDITOR = "micro";
      shellAliases.nano = "micro";
      file = {
        # keybindings
        "${config.xdg.configHome}/micro/bindings.json".source = pkgs.writeText "micro-keybindings.json" (
          builtins.toJSON {
            "Alt-," = "PreviousTab";
            "Alt-." = "NextTab";
            "Alt-Backspace" = "DeleteWordLeft";
            "Alt-CtrlH" = "DeleteWordLeft";
            "Alt-F" = "FindLiteral";
            "Alt-[" = "DiffPrevious|CursorStart";
            "Alt-]" = "DiffNext|CursorEnd";
            "Alt-a" = "StartOfLine";
            "Alt-b" = "WordLeft";
            "Alt-c" = "RemoveAllMultiCursors";
            "Alt-e" = "EndOfLine";
            "Alt-f" = "WordRight";
            "Alt-g" = "ToggleKeyMenu";
            "Alt-m" = "SpawnMultiCursorSelect";
            "Alt-n" = "SpawnMultiCursor";
            "Alt-p" = "RemoveMultiCursor";
            "Alt-x" = "SkipMultiCursor";
            "Alt-{" = "ParagraphPrevious";
            "Alt-}" = "ParagraphNext";
            "AltDown" = "MoveLinesDown";
            "AltLeft" = "StartOfTextToggle";
            "AltRight" = "EndOfLine";
            "AltShiftDown" = "SpawnMultiCursorDown";
            "AltShiftLeft" = "SelectToStartOfTextToggle";
            "AltShiftRight" = "SelectToEndOfLine";
            "AltShiftUp" = "SpawnMultiCursorUp";
            "AltUp" = "MoveLinesUp";
            "Backspace" = "Backspace";
            "Backtab" = "OutdentSelection|OutdentLine";
            "Ctrl-MouseLeft" = "MouseMultiCursor";
            "Ctrl-a" = "SelectAll";
            "Ctrl-b" = "ShellMode";
            "Ctrl-c" = "Copy|CopyLine";
            "Ctrl-d" = "DuplicateLine";
            "Ctrl-e" = "CommandMode";
            "Ctrl-f" = "Find";
            "Ctrl-g" = "ToggleHelp";
            "Ctrl-h" = "Backspace";
            "Ctrl-j" = "PlayMacro";
            "Ctrl-k" = "CutLine";
            "Ctrl-l" = "command-edit:goto ";
            "Ctrl-n" = "FindNext";
            "Ctrl-o" = "OpenFile";
            "Ctrl-p" = "FindPrevious";
            "Ctrl-q" = "Quit";
            "Ctrl-r" = "ToggleRuler";
            "Ctrl-s" = "Save";
            "Ctrl-t" = "AddTab";
            "Ctrl-u" = "ToggleMacro";
            "Ctrl-v" = "Paste";
            "Ctrl-w" = "NextSplit";
            "Ctrl-x" = "Cut|CutLine";
            "Ctrl-y" = "Redo";
            "Ctrl-z" = "Undo";
            "CtrlDown" = "CursorEnd";
            "CtrlEnd" = "CursorEnd";
            "CtrlHome" = "CursorStart";
            "CtrlPageDown" = "NextTab";
            "CtrlPageUp" = "PreviousTab";
            "AltPageDown" = "NextTab";
            "AltPageUp" = "PreviousTab";
            "CtrlShiftDown" = "SelectToEnd";
            "CtrlShiftLeft" = "SelectWordLeft";
            "CtrlShiftRight" = "SelectWordRight";
            "CtrlShiftUp" = "SelectToStart";
            "CtrlUp" = "CursorStart";
            "Delete" = "Delete";
            "Down" = "CursorDown";
            "End" = "EndOfLine";
            "Enter" = "InsertNewline";
            "Esc" = "Escape";
            "F10" = "Quit";
            "F2" = "Save";
            "F3" = "Find";
            "F4" = "Quit";
            "F7" = "Find";
            "Home" = "StartOfText";
            "Insert" = "ToggleOverwriteMode";
            "Left" = "CursorLeft";
            "MouseLeft" = "MousePress";
            "MouseLeftDrag" = "MouseDrag";
            "MouseLeftRelease" = "MouseRelease";
            "MouseMiddle" = "PastePrimary";
            "MouseWheelDown" = "ScrollDown";
            "MouseWheelUp" = "ScrollUp";
            "PageDown" = "CursorPageDown";
            "PageUp" = "CursorPageUp";
            "Right" = "CursorRight";
            "ShiftDown" = "SelectDown";
            "ShiftEnd" = "SelectToEndOfLine";
            "ShiftHome" = "SelectToStartOfTextToggle";
            "ShiftLeft" = "SelectLeft";
            "ShiftPageDown" = "SelectPageDown";
            "ShiftPageUp" = "SelectPageUp";
            "ShiftRight" = "SelectRight";
            "ShiftUp" = "SelectUp";
            "Tab" = "Autocomplete|IndentSelection|InsertTab";
            "Up" = "CursorUp";

            # plugins
            "Alt-/" = "lua:comment.comment";
            "Alt-d" = "command:definition";
            #      "Alt-f" = "command:format";
            "Alt-k" = "command:hover";
            "Alt-r" = "command:references";
            "CtrlSpace" = "command:lspcompletion";
            "CtrlUnderscore" = "lua:comment.comment";
            "F1" = "command:cheat";
            #      "F4" = "command:jumptag";
            "F5" = "lua:wc.wordCount";
          }
        );

        # plugins
        "${config.xdg.configHome}/micro/plug/lsp".source = pkgs.fetchFromGitHub {
          owner = "AndCake";
          repo = "micro-plugin-lsp";
          rev = "v0.6.3";
          sha256 = "sha256-rZ9Vw9WPGNaJBGHKU40F6cBIYQ1JFtSKPDrheazKkPY=";
        };

        "${config.xdg.configHome}/micro/plug/detectindent".source = pkgs.fetchFromGitHub {
          owner = "dmaluka";
          repo = "micro-detectindent";
          rev = "v1.1.0";
          sha256 = "sha256-5bKEkOnhz0pyBR2UNw5vvYiTtpd96fBPTYW9jnETvq4=";
        };

        "${config.xdg.configHome}/micro/plug/wc".source = pkgs.fetchFromGitHub {
          owner = "adamnpeace";
          repo = "micro-wc-plugin";
          rev = "b2c9957e521770eadc1ecae9d54c0a30f40a0a3d";
          sha256 = "sha256-Z6MC2cet8+7XHv41G+SlAZViCqlh/9dk0CSt7HklnTg=";
        };
      };
    };
  };

}