Serve formatting through clang-format

Per the user's decision, textDocument/formatting runs clang-format as a
bounded child process with a 5s deadline and capped streams. A bounded
core builds the arguments (workspace .clang-format when present,
otherwise the LSP tab options as an explicit LLVM style) and the
whole-document edit, refusing output over 32 MiB. Registered feature
tests cover the arguments, bounds and edit shape; a real stdio session
formatted a misindented document. clang-format becomes a runtime
dependency of formatting.
This commit is contained in:
faumaray committed 2026-12-05 21:30:44 +03:00
1 parent 7acbfc4029
commit 3344a9f170
12 files changed
+247 -5

No files matched your search

@@ -60,6 +60,10 @@ class EditorDiagnostics {
selection_ranges(std::string_view uri, std::span<const Documents::Position>) const;
// Foldable brace blocks, comments, regions and include groups.
[[nodiscard]] Void::LanguageServer::Protocol::Json folding_ranges(std::string_view uri) const;
// Whole-document formatting through clang-format. Empty when the text is
// already formatted; null when the formatter is unavailable or failed.
[[nodiscard]] Void::LanguageServer::Protocol::Json
format(std::string_view uri, std::uint32_t tab_size, bool insert_spaces) const;
// Reference-count lenses for the records the index holds for one document.
[[nodiscard]] Void::LanguageServer::Protocol::Json code_lenses(std::string_view uri) const;
// Quick fixes suggested by the compiler for diagnostics overlapping the