Skip to content

Commit 5a602de

Browse files
ihuguetmasahir0y
authored andcommitted
Add .editorconfig file for basic formatting
EditorConfig is a specification to define the most basic code formatting stuff, and it's supported by many editors and IDEs, either directly or via plugins, including VSCode/VSCodium, Vim, emacs and more. It allows to define formatting style related to indentation, charset, end of lines and trailing whitespaces. It also allows to apply different formats for different files based on wildcards, so for example it is possible to apply different configs to *.{c,h}, *.py and *.rs. In linux project, defining a .editorconfig might help to those people that work on different projects with different indentation styles, so they cannot define a global style. Now they will directly see the correct indentation on every fresh clone of the project. See https://editorconfig.org Co-developed-by: Danny Lin <[email protected]> Signed-off-by: Danny Lin <[email protected]> Signed-off-by: Íñigo Huguet <[email protected]> Acked-by: Mickaël Salaün <[email protected]> Reviewed-by: Vincent Mailhol <[email protected]> Tested-by: Vincent Mailhol <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent ac14947 commit 5a602de

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

.editorconfig

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
root = true
4+
5+
[{*.{awk,c,dts,dtsi,dtso,h,mk,s,S},Kconfig,Makefile,Makefile.*}]
6+
charset = utf-8
7+
end_of_line = lf
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
indent_style = tab
11+
indent_size = 8
12+
13+
[*.{json,py,rs}]
14+
charset = utf-8
15+
end_of_line = lf
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
indent_style = space
19+
indent_size = 4
20+
21+
# this must be below the general *.py to overwrite it
22+
[tools/{perf,power,rcu,testing/kunit}/**.py,]
23+
indent_style = tab
24+
indent_size = 8
25+
26+
[*.yaml]
27+
charset = utf-8
28+
end_of_line = lf
29+
trim_trailing_whitespace = unset
30+
insert_final_newline = true
31+
indent_style = space
32+
indent_size = 2

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ modules.order
9696
#
9797
!.clang-format
9898
!.cocciconfig
99+
!.editorconfig
99100
!.get_maintainer.ignore
100101
!.gitattributes
101102
!.gitignore

Documentation/process/4.Coding.rst

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ for aligning variables/macros, for reflowing text and other similar tasks.
6666
See the file :ref:`Documentation/process/clang-format.rst <clangformat>`
6767
for more details.
6868

69+
Some basic editor settings, such as indentation and line endings, will be
70+
set automatically if you are using an editor that is compatible with
71+
EditorConfig. See the official EditorConfig website for more information:
72+
https://editorconfig.org/
6973

7074
Abstraction layers
7175
******************

Documentation/process/coding-style.rst

+4
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,10 @@ for aligning variables/macros, for reflowing text and other similar tasks.
735735
See the file :ref:`Documentation/process/clang-format.rst <clangformat>`
736736
for more details.
737737

738+
Some basic editor settings, such as indentation and line endings, will be
739+
set automatically if you are using an editor that is compatible with
740+
EditorConfig. See the official EditorConfig website for more information:
741+
https://editorconfig.org/
738742

739743
10) Kconfig configuration files
740744
-------------------------------

0 commit comments

Comments
 (0)