From 4e97712607bfdcadc097823339599e5bf05f97f9 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sun, 7 Jul 2024 18:27:01 -0700 Subject: doc: remove recipe for auto-detecting slow formatters There are no significant downsides to using format_after_save. Users that are concerned about slow formatters should just use that for all of their formatters. We shouldn't be encouraging anything of this complexity. --- README.md | 1 - doc/recipes.md | 30 ------------------------------ 2 files changed, 31 deletions(-) diff --git a/README.md b/README.md index 8d9de18..ac69ec1 100644 --- a/README.md +++ b/README.md @@ -435,7 +435,6 @@ require("conform").formatters.shfmt = { - [Format command](doc/recipes.md#format-command) - [Autoformat with extra features](doc/recipes.md#autoformat-with-extra-features) - [Command to toggle format-on-save](doc/recipes.md#command-to-toggle-format-on-save) -- [Automatically run slow formatters async](doc/recipes.md#automatically-run-slow-formatters-async) - [Lazy loading with lazy.nvim](doc/recipes.md#lazy-loading-with-lazynvim) - [Leave visual mode after range format](doc/recipes.md#leave-visual-mode-after-range-format) - [Run the first available formatter followed by more formatters](doc/recipes.md#run-the-first-available-formatter-followed-by-more-formatters) diff --git a/doc/recipes.md b/doc/recipes.md index 3c230b3..fe7bbd2 100644 --- a/doc/recipes.md +++ b/doc/recipes.md @@ -5,7 +5,6 @@ - [Format command](#format-command) - [Autoformat with extra features](#autoformat-with-extra-features) - [Command to toggle format-on-save](#command-to-toggle-format-on-save) -- [Automatically run slow formatters async](#automatically-run-slow-formatters-async) - [Lazy loading with lazy.nvim](#lazy-loading-with-lazynvim) - [Leave visual mode after range format](#leave-visual-mode-after-range-format) - [Run the first available formatter followed by more formatters](#run-the-first-available-formatter-followed-by-more-formatters) @@ -108,35 +107,6 @@ end, { }) ``` -## Automatically run slow formatters async - -This snippet will automatically detect which formatters take too long to run synchronously and will run them async on save instead. - -```lua -local slow_format_filetypes = {} -require("conform").setup({ - format_on_save = function(bufnr) - if slow_format_filetypes[vim.bo[bufnr].filetype] then - return - end - local function on_format(err) - if err and err:match("timeout$") then - slow_format_filetypes[vim.bo[bufnr].filetype] = true - end - end - - return { timeout_ms = 200, lsp_format = "fallback" }, on_format - end, - - format_after_save = function(bufnr) - if not slow_format_filetypes[vim.bo[bufnr].filetype] then - return - end - return { lsp_format = "fallback" } - end, -}) -``` - ## Lazy loading with lazy.nvim Here is the recommended config for lazy-loading using lazy.nvim -- cgit v1.2.3-70-g09d2