|
| 1 | +# ------------------------------------------------------------------- |
| 2 | +# Common Editor Config |
| 3 | +# Repository : https://github.com/jonas-merkle/Common-Editor-Config |
| 4 | +# Author : Jonas Merkle |
| 5 | +# License : GNU Lesser General Public License v3.0 (LGPLv3) |
| 6 | +# Versioning : Semantic Versioning (SemVer) via Git tags |
| 7 | +# Version : v1.0.0 |
| 8 | +# Description: Cross-language editor style configuration. |
| 9 | +# © 2025 Jonas Merkle. Licensed under the LGPLv3. |
| 10 | +# ------------------------------------------------------------------- |
| 11 | + |
| 12 | +# ------------------------------------------------------------------- |
| 13 | +# Root EditorConfig |
| 14 | +# ------------------------------------------------------------------- |
| 15 | +root = true |
| 16 | + |
| 17 | +# ------------------------------------------------------------------- |
| 18 | +# GLOBAL DEFAULTS (apply to all files unless overridden below) |
| 19 | +# ------------------------------------------------------------------- |
| 20 | +[*] |
| 21 | +charset = utf-8 |
| 22 | +end_of_line = lf |
| 23 | +insert_final_newline = true |
| 24 | +trim_trailing_whitespace = true |
| 25 | + |
| 26 | +# Use spaces by default; override where tabs are required (e.g. Makefiles) |
| 27 | +indent_style = space |
| 28 | +indent_size = 4 |
| 29 | +tab_width = 4 |
| 30 | + |
| 31 | +# Not an official core property, but widely respected by many tools. |
| 32 | +# Use 'off' for prose-heavy formats where hard-wrapping is unhelpful. |
| 33 | +max_line_length = 100 |
| 34 | + |
| 35 | +# ------------------------------------------------------------------- |
| 36 | +# TEXT & DOCS |
| 37 | +# ------------------------------------------------------------------- |
| 38 | +[*.{md,mdx,txt,adoc,rst}] |
| 39 | +indent_style = space |
| 40 | +indent_size = 2 |
| 41 | +# Trailing spaces at line ends are meaningful in Markdown for hard line breaks |
| 42 | +trim_trailing_whitespace = false |
| 43 | +max_line_length = off |
| 44 | + |
| 45 | +# ------------------------------------------------------------------- |
| 46 | +# MARKUP (HTML, XML) & STYLES (CSS, SCSS) |
| 47 | +# ------------------------------------------------------------------- |
| 48 | +[*.{html,htm,xml,xaml,vue}] |
| 49 | +indent_style = space |
| 50 | +indent_size = 2 |
| 51 | + |
| 52 | +[*.{css,scss,less}] |
| 53 | +indent_style = space |
| 54 | +indent_size = 2 |
| 55 | + |
| 56 | +# ------------------------------------------------------------------- |
| 57 | +# JAVASCRIPT / TYPESCRIPT |
| 58 | +# (Core formatting via EditorConfig; lint/format specifics typically come from ESLint/Prettier) |
| 59 | +# ------------------------------------------------------------------- |
| 60 | +[*.{js,mjs,cjs,jsx}] |
| 61 | +indent_style = space |
| 62 | +indent_size = 2 |
| 63 | +max_line_length = 100 |
| 64 | + |
| 65 | +[*.{ts,tsx,cts,mts}] |
| 66 | +indent_style = space |
| 67 | +indent_size = 2 |
| 68 | +max_line_length = 100 |
| 69 | + |
| 70 | +# JSON & JSON with Comments (VS Code, etc.) |
| 71 | +[*.{json,jsonc}] |
| 72 | +indent_style = space |
| 73 | +indent_size = 2 |
| 74 | +# Keep whitespace strict in data files |
| 75 | +trim_trailing_whitespace = true |
| 76 | +insert_final_newline = true |
| 77 | + |
| 78 | +# ------------------------------------------------------------------- |
| 79 | +# YAML / TOML / INI |
| 80 | +# ------------------------------------------------------------------- |
| 81 | +[*.{yml,yaml}] |
| 82 | +indent_style = space |
| 83 | +indent_size = 2 |
| 84 | + |
| 85 | +[*.{toml,ini}] |
| 86 | +indent_style = space |
| 87 | +indent_size = 2 |
| 88 | + |
| 89 | +# ------------------------------------------------------------------- |
| 90 | +# CSV / TSV / DATA |
| 91 | +# ------------------------------------------------------------------- |
| 92 | +[*.{csv,tsv}] |
| 93 | +# Keep trailing whitespace (sometimes significant for empty columns) |
| 94 | +trim_trailing_whitespace = false |
| 95 | +insert_final_newline = true |
| 96 | +indent_style = space |
| 97 | +indent_size = 2 |
| 98 | +end_of_line = lf |
| 99 | + |
| 100 | +# ------------------------------------------------------------------- |
| 101 | +# C / C++ |
| 102 | +# (Detailed code style usually comes from .clang-format; here we set editor basics.) |
| 103 | +# ------------------------------------------------------------------- |
| 104 | +[*.{c,cc,cpp,cxx,h,hpp,hxx,ixx}] |
| 105 | +indent_style = space |
| 106 | +indent_size = 4 |
| 107 | +tab_width = 4 |
| 108 | +# Keep preprocessor columns neat; editors will still respect spaces |
| 109 | +trim_trailing_whitespace = true |
| 110 | +max_line_length = 100 |
| 111 | + |
| 112 | +# ------------------------------------------------------------------- |
| 113 | +# C# |
| 114 | +# Includes Roslyn/.NET code-style options supported in .editorconfig |
| 115 | +# Severity levels: suggestion, warning, error (tune to your preference) |
| 116 | +# ------------------------------------------------------------------- |
| 117 | +[*.cs] |
| 118 | +indent_style = space |
| 119 | +indent_size = 4 |
| 120 | +tab_width = 4 |
| 121 | +max_line_length = 100 |
| 122 | + |
| 123 | +# usings |
| 124 | +dotnet_sort_system_directives_first = true:suggestion |
| 125 | +dotnet_separate_import_directive_groups = true:suggestion |
| 126 | +dotnet_style_qualification_for_field = false:suggestion |
| 127 | +dotnet_style_qualification_for_property = false:suggestion |
| 128 | +dotnet_style_qualification_for_method = false:suggestion |
| 129 | +dotnet_style_qualification_for_event = false:suggestion |
| 130 | + |
| 131 | +# var preferences |
| 132 | +csharp_style_var_for_built_in_types = true:suggestion |
| 133 | +csharp_style_var_when_type_is_apparent = true:suggestion |
| 134 | +csharp_style_var_elsewhere = false:suggestion |
| 135 | + |
| 136 | +# expression-bodied members |
| 137 | +csharp_style_expression_bodied_methods = when_on_single_line:suggestion |
| 138 | +csharp_style_expression_bodied_constructors = when_on_single_line:suggestion |
| 139 | +csharp_style_expression_bodied_properties = when_on_single_line:suggestion |
| 140 | +csharp_style_expression_bodied_accessors = when_on_single_line:suggestion |
| 141 | + |
| 142 | +# pattern matching & modern features |
| 143 | +csharp_style_prefer_switch_expression = true:suggestion |
| 144 | +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
| 145 | +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
| 146 | +csharp_style_inlined_variable_declaration = true:suggestion |
| 147 | +csharp_style_prefer_index_operator = true:suggestion |
| 148 | +csharp_style_prefer_range_operator = true:suggestion |
| 149 | +csharp_style_prefer_tuple_swap = true:suggestion |
| 150 | +csharp_style_deconstructed_variable_declaration = true:suggestion |
| 151 | + |
| 152 | +# nullability & coalescing |
| 153 | +csharp_style_throw_expression = true:suggestion |
| 154 | +csharp_style_prefer_null_check_over_type_check = true:suggestion |
| 155 | +csharp_style_prefer_conditional_expression_over_assignment = true:suggestion |
| 156 | +csharp_style_prefer_conditional_expression_over_return = true:suggestion |
| 157 | +dotnet_style_coalesce_expression = true:suggestion |
| 158 | +dotnet_style_null_propagation = true:suggestion |
| 159 | + |
| 160 | +# braces, newlines, and layout |
| 161 | +csharp_prefer_braces = true:warning |
| 162 | +csharp_new_line_before_open_brace = all |
| 163 | +csharp_new_line_between_query_expression_clauses = true |
| 164 | + |
| 165 | +# modifiers & accessibility |
| 166 | +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion |
| 167 | +dotnet_style_readonly_field = true:suggestion |
| 168 | +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion |
| 169 | +dotnet_style_predefined_type_for_member_access = true:suggestion |
| 170 | + |
| 171 | +# using directives placement (outside namespace is common in modern .NET) |
| 172 | +csharp_using_directive_placement = outside_namespace:suggestion |
| 173 | + |
| 174 | +# file-scoped namespaces |
| 175 | +csharp_style_namespace_declarations = file_scoped:suggestion |
| 176 | + |
| 177 | +# prefer 'new()' target-typed |
| 178 | +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion |
| 179 | + |
| 180 | +# analyzers: common hygiene |
| 181 | +dotnet_diagnostic.IDE0005.severity = warning # Remove unnecessary usings |
| 182 | +dotnet_diagnostic.IDE0060.severity = suggestion # Remove unused parameter |
| 183 | +dotnet_diagnostic.IDE0044.severity = suggestion # Make field readonly |
| 184 | +dotnet_diagnostic.IDE0051.severity = suggestion # Remove unused private members |
| 185 | +dotnet_diagnostic.IDE0090.severity = suggestion # 'new()' with target-typed |
| 186 | + |
| 187 | +# ------------------------------------------------------------------- |
| 188 | +# LaTeX (TeX/LaTeX/BibTeX) |
| 189 | +# Trailing spaces can be meaningful (line breaks with two spaces), so keep them. |
| 190 | +# ------------------------------------------------------------------- |
| 191 | +[*.{tex,sty,cls,bib,latex}] |
| 192 | +indent_style = space |
| 193 | +indent_size = 2 |
| 194 | +trim_trailing_whitespace = false |
| 195 | +max_line_length = off |
| 196 | + |
| 197 | +# ------------------------------------------------------------------- |
| 198 | +# SHELL / SCRIPTS / MAKE |
| 199 | +# ------------------------------------------------------------------- |
| 200 | +[*.{sh,bash,zsh}] |
| 201 | +indent_style = space |
| 202 | +indent_size = 2 |
| 203 | + |
| 204 | +# Makefiles require tabs |
| 205 | +[Makefile] |
| 206 | +indent_style = tab |
| 207 | +tab_width = 8 |
| 208 | + |
| 209 | +# ------------------------------------------------------------------- |
| 210 | +# PROJECT / SOLUTION / MSBUILD & XML-LIKE |
| 211 | +# ------------------------------------------------------------------- |
| 212 | +[*.{sln,props,targets,csproj,vcxproj,nuspec,resx,config}] |
| 213 | +indent_style = space |
| 214 | +indent_size = 2 |
| 215 | + |
| 216 | +# ------------------------------------------------------------------- |
| 217 | +# PYTHON (if present in repo) |
| 218 | +# ------------------------------------------------------------------- |
| 219 | +[*.py] |
| 220 | +indent_style = space |
| 221 | +indent_size = 4 |
| 222 | +max_line_length = 100 |
| 223 | + |
| 224 | +# ------------------------------------------------------------------- |
| 225 | +# BATCH / POWERSHELL (Windows scripting) |
| 226 | +# ------------------------------------------------------------------- |
| 227 | +[*.{bat,cmd}] |
| 228 | +end_of_line = crlf |
| 229 | + |
| 230 | +[*.ps1] |
| 231 | +indent_style = space |
| 232 | +indent_size = 2 |
| 233 | + |
| 234 | +# ------------------------------------------------------------------- |
| 235 | +# GIT & DOTFILES |
| 236 | +# ------------------------------------------------------------------- |
| 237 | +[*.{gitattributes,gitignore,gitmodules}] |
| 238 | +indent_style = space |
| 239 | +indent_size = 2 |
| 240 | + |
| 241 | +# ------------------------------------------------------------------- |
| 242 | +# MISC: SVG (XML), SQL, CSV variants, lockfiles |
| 243 | +# ------------------------------------------------------------------- |
| 244 | +[*.svg] |
| 245 | +indent_style = space |
| 246 | +indent_size = 2 |
| 247 | + |
| 248 | +[*.sql] |
| 249 | +indent_style = space |
| 250 | +indent_size = 2 |
| 251 | +max_line_length = off |
| 252 | + |
| 253 | +# Common lockfiles prefer 2 spaces and no trimming surprises |
| 254 | +[*.{lock,lockb,package-lock.json,pnpm-lock.yaml,yarn.lock}] |
| 255 | +indent_style = space |
| 256 | +indent_size = 2 |
| 257 | +trim_trailing_whitespace = false |
| 258 | +insert_final_newline = true |
0 commit comments