Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/docs/ClangFormat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
CSharp: .cs
Java: .java
JavaScript: .js .mjs .cjs .ts
Json: .json
Json: .json .ipynb
Objective-C: .m .mm
Proto: .proto .protodevel
TableGen: .td
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4086,8 +4086,10 @@ static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
return FormatStyle::LK_TableGen;
if (FileName.ends_with_insensitive(".cs"))
return FormatStyle::LK_CSharp;
if (FileName.ends_with_insensitive(".json"))
if (FileName.ends_with_insensitive(".json") ||
FileName.ends_with_insensitive(".ipynb")) {
return FormatStyle::LK_Json;
}
if (FileName.ends_with_insensitive(".sv") ||
FileName.ends_with_insensitive(".svh") ||
FileName.ends_with_insensitive(".v") ||
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/clang-format/ClangFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static cl::opt<std::string> AssumeFileName(
" CSharp: .cs\n"
" Java: .java\n"
" JavaScript: .js .mjs .cjs .ts\n"
" Json: .json\n"
" Json: .json .ipynb\n"
" Objective-C: .m .mm\n"
" Proto: .proto .protodevel\n"
" TableGen: .td\n"
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/clang-format/clang-format-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def main():
"-iregex",
metavar="PATTERN",
default=r".*\.(?:cpp|cc|c\+\+|cxx|cppm|ccm|cxxm|c\+\+m|c|cl|h|hh|hpp"
r"|hxx|m|mm|inc|js|ts|proto|protodevel|java|cs|json|s?vh?)",
r"|hxx|m|mm|inc|js|ts|proto|protodevel|java|cs|json|ipynb|s?vh?)",
help="custom pattern selecting file paths to reformat "
"(case insensitive, overridden by -regex)",
)
Expand Down
3 changes: 2 additions & 1 deletion clang/tools/clang-format/git-clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def main():
"cjs", # JavaScript
"ts", # TypeScript
"cs", # C Sharp
"json", # Json
"json",
"ipynb", # Json
"sv",
"svh",
"v",
Expand Down
Loading