From 219d2c25156a496ed2923d4cef256352bb1302e5 Mon Sep 17 00:00:00 2001 From: PiergiorgioZagaria Date: Thu, 4 Aug 2022 06:01:48 +0200 Subject: Change default formatter for any language (#2942) * Change default formatter for any language * Fix clippy error * Close stdin for Stdio formatters * Better indentation and pattern matching * Return Result> for fn format instead of Option * Remove unwrap for stdin * Handle FormatterErrors instead of Result> * Use Transaction instead of LspFormatting * Use Transaction directly in Document::format * Perform stdin type formatting asynchronously * Rename formatter.type values to kebab-case * Debug format for displaying io::ErrorKind (msrv fix) * Solve conflict? * Use only stdio type formatters * Remove FormatterType enum * Remove old comment * Check if the formatter exited correctly * Add formatter configuration to the book * Avoid allocations when writing to stdin and formatting errors * Remove unused import Co-authored-by: Gokul Soumya --- book/src/languages.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'book') diff --git a/book/src/languages.md b/book/src/languages.md index a9d5bea8..841b1377 100644 --- a/book/src/languages.md +++ b/book/src/languages.md @@ -40,6 +40,7 @@ file-types = ["mylang", "myl"] comment-token = "#" indent = { tab-width = 2, unit = " " } language-server = { command = "mylang-lsp", args = ["--stdio"] } +formatter = { command = "mylang-formatter" , args = ["--stdin"] } ``` These configuration keys are available: @@ -59,6 +60,7 @@ These configuration keys are available: | `language-server` | The Language Server to run. See the Language Server configuration section below. | | `config` | Language Server configuration | | `grammar` | The tree-sitter grammar to use (defaults to the value of `name`) | +| `formatter` | The formatter for the language, it will take precedence over the lsp when defined. The formatter must be able to take the original file as input from stdin and write the formatted file to stdout | ### Language Server configuration -- cgit v1.2.3-70-g09d2