[utilities/kate] /: Add 3 new formatters
Waqar Ahmed
null at kde.org
Mon Oct 21 19:50:52 BST 2024
Git commit 6a7cff61d3ec2a687201f50c8d3c825827813156 by Waqar Ahmed.
Committed on 21/10/2024 at 18:50.
Pushed by waqar into branch 'master'.
Add 3 new formatters
java/glsl/gdscript/swift/erlang are now supported
M +17 -0 addons/format/FormatterSettings.json
M +11 -1 addons/format/Formatters.cpp
M +4 -1 doc/kate/plugins.docbook
https://invent.kde.org/utilities/kate/-/commit/6a7cff61d3ec2a687201f50c8d3c825827813156
diff --git a/addons/format/FormatterSettings.json b/addons/format/FormatterSettings.json
index 69b5057e8f..809f8a4ed7 100644
--- a/addons/format/FormatterSettings.json
+++ b/addons/format/FormatterSettings.json
@@ -104,5 +104,22 @@
"command": [
"odinfmt"
]
+ },
+ "swiftformat": {
+ "command": [
+ "swiftformat"
+ ]
+ },
+ "erlfmt": {
+ "command": [
+ "erlfmt",
+ "-"
+ ]
+ },
+ "gdformat": {
+ "command": [
+ "gdformat",
+ "-"
+ ]
}
}
diff --git a/addons/format/Formatters.cpp b/addons/format/Formatters.cpp
index 85ab2de2bb..d24e86db39 100644
--- a/addons/format/Formatters.cpp
+++ b/addons/format/Formatters.cpp
@@ -99,6 +99,10 @@ static QString filenameFromMode(KTextEditor::Document *doc)
return prefix.append(QLatin1String(".html"));
} else if (is("yaml")) {
return prefix.append(QLatin1String(".yml"));
+ } else if (is("java")) {
+ return prefix.append(u".java");
+ } else if (is("glsl")) {
+ return prefix.append(u".glsl");
}
return {};
}
@@ -298,7 +302,7 @@ static Formatter makeFormatter(KTextEditor::Document *doc, const QJsonObject &co
// NOTE: When adding a new formatter ensure that it is documented in plugins.docbook
- if (is_or_contains("c++") || is("c") || is("objective-c") || is("objective-c++") || is("protobuf")) {
+ if (is_or_contains("c++") || is("c") || is("objective-c") || is("objective-c++") || is("protobuf") || is("glsl") || is("java")) {
return newStdinFmt("clang-format", {S("--assume-filename=%1").arg(filenameFromMode(doc))});
} else if (is("dart")) {
return newStdinFmt("dart",
@@ -366,6 +370,12 @@ static Formatter makeFormatter(KTextEditor::Document *doc, const QJsonObject &co
return newStdinFmt("opsi-script-beautifier", {});
} else if (is("odin")) {
return newStdinFmt("odinfmt", {S("--stdin")});
+ } else if (is("swift")) {
+ return newStdinFmt("swiftformat", {});
+ } else if (is("erlang")) {
+ return newStdinFmt("erlfmt", {});
+ } else if (is("godot")) {
+ return newStdinFmt("gdformat", {});
}
return {};
#undef S
diff --git a/doc/kate/plugins.docbook b/doc/kate/plugins.docbook
index 18df02c36c..ae2d71e273 100644
--- a/doc/kate/plugins.docbook
+++ b/doc/kate/plugins.docbook
@@ -4441,7 +4441,7 @@ It allows the user to format code in two ways:
The current list of supported languages and formatters are as follows:
<itemizedlist>
-<listitem><para>C/C++/ObjectiveC/ObjectiveC++/Protobuf - <command>clang-format</command>
+<listitem><para>C/C++/ObjectiveC/ObjectiveC++/Protobuf/GLSL/Java - <command>clang-format</command>
</para></listitem>
<listitem><para>Javascript/Typescript/JSX/TSX - <command>prettier</command>
@@ -4467,6 +4467,9 @@ The current list of supported languages and formatters are as follows:
<listitem><para>Nix - <command>nixfmt</command></para></listitem>
<listitem><para>QML - <command>qmlformat</command></para></listitem>
<listitem><para>HTML - <command>prettier</command></para></listitem>
+<listitem><para>Swift - <command>swiftformat</command></para></listitem>
+<listitem><para>Erlang - <command>erlfmt</command></para></listitem>
+<listitem><para>Godot Script - <command>gdformat</command></para></listitem>
<listitem><para>Python
<itemizedlist>
More information about the kde-doc-english
mailing list