diff options
Diffstat (limited to 'modules/common/editorconfig.nix')
-rw-r--r-- | modules/common/editorconfig.nix | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/modules/common/editorconfig.nix b/modules/common/editorconfig.nix new file mode 100644 index 0000000..822acf6 --- /dev/null +++ b/modules/common/editorconfig.nix @@ -0,0 +1,129 @@ +{ + config, + lib, + ... +}: +with lib; let + cfg = config.nixfiles.modules.editorconfig; +in { + options.nixfiles.modules.editorconfig.enable = mkEnableOption "Editorconfig"; + + config = mkIf cfg.enable { + hm.editorconfig = { + enable = true; + settings = { + "*" = { + charset = "utf-8"; + end_of_line = "lf"; + indent_size = 2; + indent_style = "space"; + insert_final_newline = true; + max_line_length = 80; + trim_trailing_whitespace = true; + }; + + # https://google.github.io/styleguide/cppguide.html#Spaces_vs._Tabs + "*.{c,cc,cpp,cxx,h,hh,hpp,hxx}" = { + indent_size = 2; + indent_style = "space"; + }; + + # https://go.dev/doc/effective_go#formatting + "*.go" = { + indent_size = 2; + indent_style = "tab"; + }; + + # https://google.github.io/styleguide/pyguide.html#s3.4-indentation + # https://peps.python.org/pep-0008/#indentation + "*.py" = { + indent_size = 4; + indent_style = "space"; + }; + + # https://google.github.io/styleguide/shellguide.html#s5-formatting + "*.{sh,bash}" = { + indent_size = 2; + indent_style = "space"; + }; + + # https://www.haskell.org/onlinereport/haskell2010/haskellch10.html#x17-17800010.3 + # https://en.wikibooks.org/wiki/Haskell/Indentation + "*.hs" = { + indent_size = 2; + indent_style = "space"; + }; + + # https://google.github.io/styleguide/lispguide.xml#Formatting + "*.{lisp,cl,rkt,scm,el}" = { + indent_size = 2; + indent_style = "space"; + }; + + # https://github.com/ziglang/zig/wiki/FAQ#why-does-zig-fmt-use-spaces-instead-of-tabs + "*.zig" = { + indent_size = 4; + indent_style = "space"; + }; + + "*.{asm,s}" = { + indent_size = 4; + indent_style = "spaces"; + }; + + # https://www.gnu.org/software/make/manual/html_node/Rule-Syntax.html + "{Makefile*,*.mk}" = { + indent_size = 4; + indent_style = "tab"; + }; + + # https://cmake-format.readthedocs.io/en/latest/configopts.html#tab-size + # https://cmake-format.readthedocs.io/en/latest/configopts.html#use-tabchars + "{CMakeLists.txt,*.cmake}" = { + indent_size = 2; + indent_style = "space"; + }; + + # https://github.com/NixOS/rfcs/pull/166 + "*.nix" = { + indent_size = 2; + indent_style = "space"; + }; + + # https://developer.hashicorp.com/terraform/language/syntax/style + "*.{tf,hcl}" = { + indent_size = 2; + indent_style = "space"; + }; + + "*.{json,jsn}" = { + indent_size = 2; + indent_style = "space"; + }; + + # https://yaml.org/spec/1.2.2/#61-indentation-spaces + "*.{yaml,yml}" = { + indent_size = 2; + indent_style = "space"; + }; + + "*.{toml,tml}" = { + indent_size = 2; + indent_style = "space"; + }; + + # https://google.github.io/styleguide/htmlcssguide.html#Indentation + "*.{html,css}" = { + indent_size = 2; + indent_style = "space"; + }; + + # https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html + "*.{tex,cls}" = { + indent_size = 4; + indent_style = "tab"; + }; + }; + }; + }; +} |