From 0b3d25969e2da2f5de90cc02ccd6446aa68dd895 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sat, 13 Jul 2024 14:28:18 -0700 Subject: feat: format parameter to only run the first available formatter --- doc/conform.txt | 73 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 32 deletions(-) (limited to 'doc') diff --git a/doc/conform.txt b/doc/conform.txt index 002e46c..589289b 100644 --- a/doc/conform.txt +++ b/doc/conform.txt @@ -132,11 +132,12 @@ setup({opts}) *conform.setu This can also be a function that returns the table. {default_format_opts} `nil|conform.DefaultFormatOpts` The default options to use when calling conform.format() - {timeout_ms} `nil|integer` Time in milliseconds to block for - formatting. Defaults to 1000. No effect if async = - true. - {lsp_format} `nil|conform.LspFormatOpts` Configure if and when LSP - should be used for formatting. Defaults to "never". + {timeout_ms} `nil|integer` Time in milliseconds to block for + formatting. Defaults to 1000. No effect if + async = true. + {lsp_format} `nil|conform.LspFormatOpts` Configure if and + when LSP should be used for formatting. + Defaults to "never". `"never"` never use the LSP for formatting (default) `"fallback"` LSP formatting is used when no other formatters are available @@ -145,8 +146,10 @@ setup({opts}) *conform.setu other formatters `"last"` other formatters are used then LSP formatting when available - {quiet} `nil|boolean` Don't show any notifications for - warnings or failures. Defaults to false. + {quiet} `nil|boolean` Don't show any notifications for + warnings or failures. Defaults to false. + {stop_after_first} `nil|boolean` Only run the first available + formatter in the list. Defaults to false. {format_after_save} `nil|conform.FormatOpts|fun(bufnr: integer): nil|conform.FormatOpts` If this is set, Conform will run the formatter asynchronously after save. It will pass the table @@ -166,20 +169,23 @@ format({opts}, {callback}): boolean *conform.forma Parameters: {opts} `nil|conform.FormatOpts` - {timeout_ms} `nil|integer` Time in milliseconds to block for - formatting. Defaults to 1000. No effect if async = true. - {bufnr} `nil|integer` Format this buffer (default 0) - {async} `nil|boolean` If true the method won't block. Defaults to - false. If the buffer is modified before the formatter - completes, the formatting will be discarded. - {dry_run} `nil|boolean` If true don't apply formatting changes to - the buffer - {undojoin} `nil|boolean` Use undojoin to merge formatting changes - with previous edit (default false) - {formatters} `nil|string[]` List of formatters to run. Defaults to all - formatters for the buffer filetype. - {lsp_format} `nil|conform.LspFormatOpts` Configure if and when LSP - should be used for formatting. Defaults to "never". + {timeout_ms} `nil|integer` Time in milliseconds to block for + formatting. Defaults to 1000. No effect if async = + true. + {bufnr} `nil|integer` Format this buffer (default 0) + {async} `nil|boolean` If true the method won't block. + Defaults to false. If the buffer is modified before + the formatter completes, the formatting will be + discarded. + {dry_run} `nil|boolean` If true don't apply formatting + changes to the buffer + {undojoin} `nil|boolean` Use undojoin to merge formatting + changes with previous edit (default false) + {formatters} `nil|string[]` List of formatters to run. Defaults + to all formatters for the buffer filetype. + {lsp_format} `nil|conform.LspFormatOpts` Configure if and when + LSP should be used for formatting. Defaults to + "never". `"never"` never use the LSP for formatting (default) `"fallback"` LSP formatting is used when no other formatters are available @@ -188,19 +194,22 @@ format({opts}, {callback}): boolean *conform.forma formatters `"last"` other formatters are used then LSP formatting when available - {quiet} `nil|boolean` Don't show any notifications for warnings - or failures. Defaults to false. - {range} `nil|conform.Range` Range to format. Table must contain - `start` and `end` keys with {row, col} tuples using (1,0) - indexing. Defaults to current selection in visual mode + {stop_after_first} `nil|boolean` Only run the first available + formatter in the list. Defaults to false. + {quiet} `nil|boolean` Don't show any notifications for + warnings or failures. Defaults to false. + {range} `nil|conform.Range` Range to format. Table must + contain `start` and `end` keys with {row, col} + tuples using (1,0) indexing. Defaults to current + selection in visual mode {start} `integer[]` {end} `integer[]` - {id} `nil|integer` Passed to |vim.lsp.buf.format| when using - LSP formatting - {name} `nil|string` Passed to |vim.lsp.buf.format| when using - LSP formatting - {filter} `nil|fun(client: table): boolean` Passed to - |vim.lsp.buf.format| when using LSP formatting + {id} `nil|integer` Passed to |vim.lsp.buf.format| when + using LSP formatting + {name} `nil|string` Passed to |vim.lsp.buf.format| when + using LSP formatting + {filter} `nil|fun(client: table): boolean` Passed to |vim.ls + p.buf.format| when using LSP formatting {callback} `nil|fun(err: nil|string, did_edit: nil|boolean)` Called once formatting has completed Returns: -- cgit v1.2.3-70-g09d2