blob: 99cdf2bcbcaa7ab88dd883340555894eeab75111 [file] [log] [blame]
Samuel Shuert219cf0b2024-03-30 17:53:08 -04001{ config, lib, ... }:
2{
3 options.chimera.editor.editorconfig = {
4 enable = lib.mkEnableOption "Enable default .editorconfig file";
5 };
6
7 config = lib.mkIf config.chimera.editor.editorconfig.enable {
8 editorconfig = {
9 enable = true;
10 settings = {
11 "*" = {
12 charset = "utf-8";
13 end_of_line = "lf";
14 trim_trailing_whitespace = true;
15 insert_final_newline = true;
16 indent_style = "tab";
17 };
18 # JS Files
19 "*.{ts,js,cjs,mjs}" = {
20 indent_size = 4;
21 };
22 "*.{jsx,tsx}" = {
23 indent_size = 2;
24 };
25 # Python
26 "*.py" = {
27 indent_size = 4;
28 };
29 # Nix
30 "*.nix" = {
31 indent_style = "space";
32 indent_size = 2;
33 };
34 # Web Files
35 "*.{htm,html,less,svg,vue}" = {
36 indent_size = 2;
37 };
38 # Rust
39 "*.rs" = {
40 indent_size = 4;
41 };
42 # C Files
43 "*.{c,cpp,cs,h,hpp,C,H,cxx,hxx}" = {
44 indent_size = 4;
45 };
46 "*.{sln,csproj,vbproj,vcxproj.filters,proj,projitems,shproj}" = {
47 indent_size = 2;
48 };
49 # CSS Files
50 "*.{css,sass,scss,less}" = {
51 indent_size = 2;
52 };
53 # Script Files
54 "*.{sh,zsh,bash,bat,cmd,ps1,psm1}" = {
55 indent_size = 4;
56 };
57 # Git Files
58 "*.{diff,patch}" = {
59 end_of_line = "unset";
60 insert_final_newline = "unset";
61 trim_trailing_whitespace = "unset";
62 };
63 ".{gitignore,gitreview,gitmodules}" = {
64 indent_style = "unset";
65 indent_size = 0;
66 };
67 # Key Files
68 "*.{asc,key,ovpn}" = {
69 end_of_line = "unset";
70 insert_final_newline = "unset";
71 trim_trailing_whitespace = "unset";
72 };
73 # Lockfile
74 "*.lock" = {
75 indent_style = "unset";
76 insert_final_newline = "unset";
77 };
78 # Markdown
79 "*.md" = {
80 indent_size = 2;
81 trim_trailing_whitespace = false;
82 };
83 # JSON a/ YAML Files
84 "*.{json,json5,webmanifest,yaml,yml}" = {
85 indent_style = "space";
86 indent_size = 2;
87 };
88 # TOML
89 "*.toml" = {
90 indent_style = "unset";
91 indent_size = 0;
92 };
93 # *RC Files
94 ".*rc" = {
95 indent_size = 2;
96 };
97 };
98 };
99 };
100}