Bug 451530

Summary: Format document action
Product: [Applications] kate Reporter: Nicolas Fella <nicolas.fella>
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: christoph, nate, waqar.17a
Priority: NOR    
Version First Reported In: Git   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 23.04
Sentry Crash Report:

Description Nicolas Fella 2022-03-15 13:57:36 UTC
Kate can format various types of files (C++, JSON, XML, Go, ...) through the external command integration.

It would be nice to have a central action for this (e.g. Extras > Format current file). That way the action does not depend on the filetype and there can be one shortcut to invoke this
Comment 1 Christoph Cullmann 2022-03-15 19:27:20 UTC
That is true, that is a valid wish..
But I am not sure how to implement that easily, ATM there is no way to bind X external tools to the same action and choose the "right" one per document highlighting/mode/mimetype, at least not if I am not wrong.
Comment 2 Nicolas Fella 2022-03-15 19:57:35 UTC
perhaps it would make sense to have a "Format" plugin that maintains a list of languages/formats/tools and remove the relevant external tools definitions?

Something to consider is that the LSP integration does have a Format action, but for stuff like JSON and XML LSP doesn't make much sense otherwise, does it?
Comment 3 Waqar Ahmed 2022-03-16 04:07:14 UTC
A dedicated plugin would be the right way to solve this problem, imo. But if we go that route, the plugin must not be a simple list of X processes mapping to Y languages. It should be smart enough to apply formatting where things have changed and allow preserving undo history etc.
Comment 4 Waqar Ahmed 2022-12-28 05:42:45 UTC
Implemented in c3ed28b47bda340c7515eb47234cec9ec232dacd