From 665ff1bb8c287e4378fcf28b06d396daeae66adf Mon Sep 17 00:00:00 2001
From: Mingshi Wang <mingshiwang123@gmail.com>
Date: Tue, 27 Feb 2024 14:20:21 -0600
Subject: [PATCH 1/9] feat: add ability to alter lsp file operation timeout

---
 README.md               | 2 ++
 doc/oil.txt             | 2 ++
 lua/oil/config.lua      | 4 ++++
 lua/oil/lsp/helpers.lua | 7 ++++---
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index c3291966..c7ed5b64 100644
--- a/README.md
+++ b/README.md
@@ -166,6 +166,8 @@ require("oil").setup({
   -- Set to true to autosave buffers that are updated with LSP willRenameFiles
   -- Set to "unmodified" to only save unmodified buffers
   lsp_rename_autosave = false,
+  -- The amount of time LSP waits for file operation before it errors
+  lsp_file_operation_timeout_ms = 5000,
   -- Constrain the cursor to the editable parts of the oil buffer
   -- Set to `false` to disable, or "name" to keep it on the file names
   constrain_cursor = "editable",
diff --git a/doc/oil.txt b/doc/oil.txt
index 24ff83e9..c388eefe 100644
--- a/doc/oil.txt
+++ b/doc/oil.txt
@@ -57,6 +57,8 @@ CONFIG                                                                *oil-confi
       -- Set to true to autosave buffers that are updated with LSP willRenameFiles
       -- Set to "unmodified" to only save unmodified buffers
       lsp_rename_autosave = false,
+      -- The amount of time LSP waits for file operation before it errors
+      lsp_file_operation_timeout_ms = 5000,
       -- Constrain the cursor to the editable parts of the oil buffer
       -- Set to `false` to disable, or "name" to keep it on the file names
       constrain_cursor = "editable",
diff --git a/lua/oil/config.lua b/lua/oil/config.lua
index 5026f78c..2c1c2523 100644
--- a/lua/oil/config.lua
+++ b/lua/oil/config.lua
@@ -40,6 +40,10 @@ local default_config = {
   -- Set to true to autosave buffers that are updated with LSP willRenameFiles
   -- Set to "unmodified" to only save unmodified buffers
   lsp_rename_autosave = false,
+
+  -- The amount of time LSP waits for file operation before it errors
+  lsp_file_operation_timeout_ms = 5000,
+
   -- Constrain the cursor to the editable parts of the oil buffer
   -- Set to `false` to disable, or "name" to keep it on the file names
   constrain_cursor = "editable",
diff --git a/lua/oil/lsp/helpers.lua b/lua/oil/lsp/helpers.lua
index e0a14513..ee32940a 100644
--- a/lua/oil/lsp/helpers.lua
+++ b/lua/oil/lsp/helpers.lua
@@ -68,9 +68,10 @@ M.will_perform_file_operations = function(actions)
       end
     end
   end
-  accum(workspace.will_create_files(creates))
-  accum(workspace.will_delete_files(deletes))
-  accum(workspace.will_rename_files(moves))
+  local timeout_ms = config.lsp_file_operation_timeout_ms
+  accum(workspace.will_create_files(creates, { timeout_ms }))
+  accum(workspace.will_delete_files(deletes, { timeout_ms }))
+  accum(workspace.will_rename_files(moves, { timeout_ms }))
   if final_err then
     vim.notify(
       string.format("[lsp] file operation error: %s", vim.inspect(final_err)),

From bbe739e0d5a0bcad08991862af968f22043ec3bd Mon Sep 17 00:00:00 2001
From: Mingshi Wang <mingshiwang123@gmail.com>
Date: Tue, 27 Feb 2024 14:25:03 -0600
Subject: [PATCH 2/9] change default

---
 README.md                 | 2 +-
 doc/oil.txt               | 2 +-
 lua/oil/config.lua        | 2 +-
 lua/oil/lsp/workspace.lua | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index c7ed5b64..eaf5f8bd 100644
--- a/README.md
+++ b/README.md
@@ -167,7 +167,7 @@ require("oil").setup({
   -- Set to "unmodified" to only save unmodified buffers
   lsp_rename_autosave = false,
   -- The amount of time LSP waits for file operation before it errors
-  lsp_file_operation_timeout_ms = 5000,
+  lsp_file_operation_timeout_ms = 1000,
   -- Constrain the cursor to the editable parts of the oil buffer
   -- Set to `false` to disable, or "name" to keep it on the file names
   constrain_cursor = "editable",
diff --git a/doc/oil.txt b/doc/oil.txt
index c388eefe..d931907d 100644
--- a/doc/oil.txt
+++ b/doc/oil.txt
@@ -58,7 +58,7 @@ CONFIG                                                                *oil-confi
       -- Set to "unmodified" to only save unmodified buffers
       lsp_rename_autosave = false,
       -- The amount of time LSP waits for file operation before it errors
-      lsp_file_operation_timeout_ms = 5000,
+      lsp_file_operation_timeout_ms = 1000,
       -- Constrain the cursor to the editable parts of the oil buffer
       -- Set to `false` to disable, or "name" to keep it on the file names
       constrain_cursor = "editable",
diff --git a/lua/oil/config.lua b/lua/oil/config.lua
index 2c1c2523..4cd5e2fb 100644
--- a/lua/oil/config.lua
+++ b/lua/oil/config.lua
@@ -42,7 +42,7 @@ local default_config = {
   lsp_rename_autosave = false,
 
   -- The amount of time LSP waits for file operation before it errors
-  lsp_file_operation_timeout_ms = 5000,
+  lsp_file_operation_timeout_ms = 1000,
 
   -- Constrain the cursor to the editable parts of the oil buffer
   -- Set to `false` to disable, or "name" to keep it on the file names
diff --git a/lua/oil/lsp/workspace.lua b/lua/oil/lsp/workspace.lua
index 49065a05..92117a68 100644
--- a/lua/oil/lsp/workspace.lua
+++ b/lua/oil/lsp/workspace.lua
@@ -260,7 +260,7 @@ function M.will_rename_files(files, options)
       }
       local result, err =
         ---@diagnostic disable-next-line: invisible
-        client.request_sync(ms.workspace_willRenameFiles, params, options.timeout_ms or 1000, 0)
+        client.request_sync(ms.workspace_willRenameFiles, params, options.timeout_ms, 0)
       if result and result.result then
         if options.apply_edits ~= false then
           vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)

From 7cccc08236dcc3e9f20c1fbb32767e475059a1fb Mon Sep 17 00:00:00 2001
From: Mingshi Wang <mingshiwang123@gmail.com>
Date: Tue, 27 Feb 2024 14:47:40 -0600
Subject: [PATCH 3/9] fix table

---
 lua/oil/lsp/helpers.lua | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lua/oil/lsp/helpers.lua b/lua/oil/lsp/helpers.lua
index ee32940a..646dce00 100644
--- a/lua/oil/lsp/helpers.lua
+++ b/lua/oil/lsp/helpers.lua
@@ -69,9 +69,9 @@ M.will_perform_file_operations = function(actions)
     end
   end
   local timeout_ms = config.lsp_file_operation_timeout_ms
-  accum(workspace.will_create_files(creates, { timeout_ms }))
-  accum(workspace.will_delete_files(deletes, { timeout_ms }))
-  accum(workspace.will_rename_files(moves, { timeout_ms }))
+  accum(workspace.will_create_files(creates, { timeout_ms = timeout_ms }))
+  accum(workspace.will_delete_files(deletes, { timeout_ms = timeout_ms }))
+  accum(workspace.will_rename_files(moves, { timeout_ms = timeout_ms }))
   if final_err then
     vim.notify(
       string.format("[lsp] file operation error: %s", vim.inspect(final_err)),

From cb16c3867ae59d7f50605df7b7ba35d5688e4d52 Mon Sep 17 00:00:00 2001
From: Mingshi Wang <mingshiwang123@gmail.com>
Date: Tue, 27 Feb 2024 15:03:17 -0600
Subject: [PATCH 4/9] add missing

---
 lua/oil/lsp/workspace.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lua/oil/lsp/workspace.lua b/lua/oil/lsp/workspace.lua
index 92117a68..b8f72abb 100644
--- a/lua/oil/lsp/workspace.lua
+++ b/lua/oil/lsp/workspace.lua
@@ -146,7 +146,7 @@ local function will_file_operation(method, capability_name, files, options)
         end, matching_files),
       }
       ---@diagnostic disable-next-line: invisible
-      local result, err = client.request_sync(method, params, options.timeout_ms or 1000, 0)
+      local result, err = client.request_sync(method, params, options.timeout_ms, 0)
       if result and result.result then
         if options.apply_edits ~= false then
           vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)

From 52642eda1abc57b81d5b2b9d78afcb0e7bb1dedd Mon Sep 17 00:00:00 2001
From: Mingshi Wang <mingshiwang123@gmail.com>
Date: Fri, 1 Mar 2024 19:12:57 -0600
Subject: [PATCH 5/9] move inside table

---
 README.md               | 10 ++++++++--
 doc/oil.txt             | 10 ++++++++--
 lua/oil/config.lua      | 15 ++++++++-------
 lua/oil/lsp/helpers.lua | 10 ++++++++--
 4 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index eaf5f8bd..a122f9ac 100644
--- a/README.md
+++ b/README.md
@@ -166,8 +166,14 @@ require("oil").setup({
   -- Set to true to autosave buffers that are updated with LSP willRenameFiles
   -- Set to "unmodified" to only save unmodified buffers
   lsp_rename_autosave = false,
-  -- The amount of time LSP waits for file operation before it errors
-  lsp_file_operation_timeout_ms = 1000,
+  -- set various LSP file operation options
+  lsp_file_methods = {
+    -- Time to wait for LSP file operations to complete before skipping
+    timeout_ms = 1000,
+    -- Set to true to autosave buffers that are updated with LSP willRenameFiles
+    -- Set to "unmodified" to only save unmodified buffers
+    lsp_rename_autosave = false,
+  },
   -- Constrain the cursor to the editable parts of the oil buffer
   -- Set to `false` to disable, or "name" to keep it on the file names
   constrain_cursor = "editable",
diff --git a/doc/oil.txt b/doc/oil.txt
index d931907d..31f3ad94 100644
--- a/doc/oil.txt
+++ b/doc/oil.txt
@@ -57,8 +57,14 @@ CONFIG                                                                *oil-confi
       -- Set to true to autosave buffers that are updated with LSP willRenameFiles
       -- Set to "unmodified" to only save unmodified buffers
       lsp_rename_autosave = false,
-      -- The amount of time LSP waits for file operation before it errors
-      lsp_file_operation_timeout_ms = 1000,
+      -- set various LSP file operation options
+      lsp_file_methods = {
+        -- Time to wait for LSP file operations to complete before skipping
+        timeout_ms = 1000,
+        -- Set to true to autosave buffers that are updated with LSP willRenameFiles
+        -- Set to "unmodified" to only save unmodified buffers
+        lsp_rename_autosave = false,
+      },
       -- Constrain the cursor to the editable parts of the oil buffer
       -- Set to `false` to disable, or "name" to keep it on the file names
       constrain_cursor = "editable",
diff --git a/lua/oil/config.lua b/lua/oil/config.lua
index 4cd5e2fb..58c54435 100644
--- a/lua/oil/config.lua
+++ b/lua/oil/config.lua
@@ -37,13 +37,14 @@ local default_config = {
   -- You can set the delay to false to disable cleanup entirely
   -- Note that the cleanup process only starts when none of the oil buffers are currently displayed
   cleanup_delay_ms = 2000,
-  -- Set to true to autosave buffers that are updated with LSP willRenameFiles
-  -- Set to "unmodified" to only save unmodified buffers
-  lsp_rename_autosave = false,
-
-  -- The amount of time LSP waits for file operation before it errors
-  lsp_file_operation_timeout_ms = 1000,
-
+  -- set various LSP file operation options
+  lsp_file_methods = {
+    -- Time to wait for LSP file operations to complete before skipping
+    timeout_ms = 1000,
+    -- Set to true to autosave buffers that are updated with LSP willRenameFiles
+    -- Set to "unmodified" to only save unmodified buffers
+    lsp_rename_autosave = false,
+  },
   -- Constrain the cursor to the editable parts of the oil buffer
   -- Set to `false` to disable, or "name" to keep it on the file names
   constrain_cursor = "editable",
diff --git a/lua/oil/lsp/helpers.lua b/lua/oil/lsp/helpers.lua
index 646dce00..1b51f68b 100644
--- a/lua/oil/lsp/helpers.lua
+++ b/lua/oil/lsp/helpers.lua
@@ -68,7 +68,7 @@ M.will_perform_file_operations = function(actions)
       end
     end
   end
-  local timeout_ms = config.lsp_file_operation_timeout_ms
+  local timeout_ms = config.lsp_file_methods.timeout_ms
   accum(workspace.will_create_files(creates, { timeout_ms = timeout_ms }))
   accum(workspace.will_delete_files(deletes, { timeout_ms = timeout_ms }))
   accum(workspace.will_rename_files(moves, { timeout_ms = timeout_ms }))
@@ -84,7 +84,13 @@ M.will_perform_file_operations = function(actions)
     workspace.did_delete_files(deletes)
     workspace.did_rename_files(moves)
 
-    local autosave = config.lsp_rename_autosave
+    local autosave = config.lsp_file_methods.lsp_rename_autosave or config.lsp_rename_autosave
+    if config.lsp_rename_autosave ~= nil then
+      vim.deprecate("lsp_rename_autosave will be deprecated. Move the flag inside lsp_file_methods", nil, 'v2.7.0',
+        'oil.nvim',
+        false)
+    end
+
     if autosave == false then
       return
     end

From f49bc003f46728ce150879234ee0c17c1e56f163 Mon Sep 17 00:00:00 2001
From: Mingshi Wang <mingshiwang123@gmail.com>
Date: Fri, 1 Mar 2024 19:17:27 -0600
Subject: [PATCH 6/9] remove duplicate

---
 README.md   | 3 ---
 doc/oil.txt | 3 ---
 2 files changed, 6 deletions(-)

diff --git a/README.md b/README.md
index a122f9ac..fa05f181 100644
--- a/README.md
+++ b/README.md
@@ -163,9 +163,6 @@ require("oil").setup({
   -- You can set the delay to false to disable cleanup entirely
   -- Note that the cleanup process only starts when none of the oil buffers are currently displayed
   cleanup_delay_ms = 2000,
-  -- Set to true to autosave buffers that are updated with LSP willRenameFiles
-  -- Set to "unmodified" to only save unmodified buffers
-  lsp_rename_autosave = false,
   -- set various LSP file operation options
   lsp_file_methods = {
     -- Time to wait for LSP file operations to complete before skipping
diff --git a/doc/oil.txt b/doc/oil.txt
index 31f3ad94..199868b9 100644
--- a/doc/oil.txt
+++ b/doc/oil.txt
@@ -54,9 +54,6 @@ CONFIG                                                                *oil-confi
       -- You can set the delay to false to disable cleanup entirely
       -- Note that the cleanup process only starts when none of the oil buffers are currently displayed
       cleanup_delay_ms = 2000,
-      -- Set to true to autosave buffers that are updated with LSP willRenameFiles
-      -- Set to "unmodified" to only save unmodified buffers
-      lsp_rename_autosave = false,
       -- set various LSP file operation options
       lsp_file_methods = {
         -- Time to wait for LSP file operations to complete before skipping

From a7df1a256e9980134ed778bd75ef9e9b7d55936b Mon Sep 17 00:00:00 2001
From: Mingshi Wang <mingshiwang123@gmail.com>
Date: Fri, 1 Mar 2024 19:37:00 -0600
Subject: [PATCH 7/9] reuse default

---
 lua/oil/lsp/workspace.lua | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lua/oil/lsp/workspace.lua b/lua/oil/lsp/workspace.lua
index b8f72abb..49065a05 100644
--- a/lua/oil/lsp/workspace.lua
+++ b/lua/oil/lsp/workspace.lua
@@ -146,7 +146,7 @@ local function will_file_operation(method, capability_name, files, options)
         end, matching_files),
       }
       ---@diagnostic disable-next-line: invisible
-      local result, err = client.request_sync(method, params, options.timeout_ms, 0)
+      local result, err = client.request_sync(method, params, options.timeout_ms or 1000, 0)
       if result and result.result then
         if options.apply_edits ~= false then
           vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)
@@ -260,7 +260,7 @@ function M.will_rename_files(files, options)
       }
       local result, err =
         ---@diagnostic disable-next-line: invisible
-        client.request_sync(ms.workspace_willRenameFiles, params, options.timeout_ms, 0)
+        client.request_sync(ms.workspace_willRenameFiles, params, options.timeout_ms or 1000, 0)
       if result and result.result then
         if options.apply_edits ~= false then
           vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)

From d6ea9fe84394343191193291efd9a5ef0767d575 Mon Sep 17 00:00:00 2001
From: Mingshi Wang <mingshiwang123@gmail.com>
Date: Fri, 1 Mar 2024 19:40:45 -0600
Subject: [PATCH 8/9] change message

---
 lua/oil/lsp/helpers.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lua/oil/lsp/helpers.lua b/lua/oil/lsp/helpers.lua
index 1b51f68b..2eb6e713 100644
--- a/lua/oil/lsp/helpers.lua
+++ b/lua/oil/lsp/helpers.lua
@@ -86,7 +86,7 @@ M.will_perform_file_operations = function(actions)
 
     local autosave = config.lsp_file_methods.lsp_rename_autosave or config.lsp_rename_autosave
     if config.lsp_rename_autosave ~= nil then
-      vim.deprecate("lsp_rename_autosave will be deprecated. Move the flag inside lsp_file_methods", nil, 'v2.7.0',
+      vim.deprecate("lsp_rename_autosave at root level", nil, 'v2.7.0',
         'oil.nvim',
         false)
     end

From 9b42217b560b90aee65fd39eaa03ce96a31cc9b7 Mon Sep 17 00:00:00 2001
From: Steven Arcangeli <stevearc@stevearc.com>
Date: Sat, 2 Mar 2024 09:01:24 -0800
Subject: [PATCH 9/9] refactor: rename autosave config option

---
 README.md               |  3 +--
 doc/oil.txt             |  3 +--
 lua/oil/config.lua      | 12 ++++++++++--
 lua/oil/lsp/helpers.lua |  8 +-------
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index fa05f181..1f4bd184 100644
--- a/README.md
+++ b/README.md
@@ -163,13 +163,12 @@ require("oil").setup({
   -- You can set the delay to false to disable cleanup entirely
   -- Note that the cleanup process only starts when none of the oil buffers are currently displayed
   cleanup_delay_ms = 2000,
-  -- set various LSP file operation options
   lsp_file_methods = {
     -- Time to wait for LSP file operations to complete before skipping
     timeout_ms = 1000,
     -- Set to true to autosave buffers that are updated with LSP willRenameFiles
     -- Set to "unmodified" to only save unmodified buffers
-    lsp_rename_autosave = false,
+    autosave_changes = false,
   },
   -- Constrain the cursor to the editable parts of the oil buffer
   -- Set to `false` to disable, or "name" to keep it on the file names
diff --git a/doc/oil.txt b/doc/oil.txt
index 199868b9..9e6eec34 100644
--- a/doc/oil.txt
+++ b/doc/oil.txt
@@ -54,13 +54,12 @@ CONFIG                                                                *oil-confi
       -- You can set the delay to false to disable cleanup entirely
       -- Note that the cleanup process only starts when none of the oil buffers are currently displayed
       cleanup_delay_ms = 2000,
-      -- set various LSP file operation options
       lsp_file_methods = {
         -- Time to wait for LSP file operations to complete before skipping
         timeout_ms = 1000,
         -- Set to true to autosave buffers that are updated with LSP willRenameFiles
         -- Set to "unmodified" to only save unmodified buffers
-        lsp_rename_autosave = false,
+        autosave_changes = false,
       },
       -- Constrain the cursor to the editable parts of the oil buffer
       -- Set to `false` to disable, or "name" to keep it on the file names
diff --git a/lua/oil/config.lua b/lua/oil/config.lua
index 58c54435..8753903f 100644
--- a/lua/oil/config.lua
+++ b/lua/oil/config.lua
@@ -37,13 +37,12 @@ local default_config = {
   -- You can set the delay to false to disable cleanup entirely
   -- Note that the cleanup process only starts when none of the oil buffers are currently displayed
   cleanup_delay_ms = 2000,
-  -- set various LSP file operation options
   lsp_file_methods = {
     -- Time to wait for LSP file operations to complete before skipping
     timeout_ms = 1000,
     -- Set to true to autosave buffers that are updated with LSP willRenameFiles
     -- Set to "unmodified" to only save unmodified buffers
-    lsp_rename_autosave = false,
+    autosave_changes = false,
   },
   -- Constrain the cursor to the editable parts of the oil buffer
   -- Set to `false` to disable, or "name" to keep it on the file names
@@ -177,6 +176,15 @@ M.setup = function(opts)
     new_conf.keymaps = opts.keymaps or {}
   end
 
+  if new_conf.lsp_rename_autosave ~= nil then
+    new_conf.lsp_file_methods.autosave_changes = new_conf.lsp_rename_autosave
+    new_conf.lsp_rename_autosave = nil
+    vim.notify_once(
+      "oil config value lsp_rename_autosave has moved to lsp_file_methods.autosave_changes.\nCompatibility will be removed on 2024-09-01.",
+      vim.log.levels.WARN
+    )
+  end
+
   for k, v in pairs(new_conf) do
     M[k] = v
   end
diff --git a/lua/oil/lsp/helpers.lua b/lua/oil/lsp/helpers.lua
index 2eb6e713..89c54696 100644
--- a/lua/oil/lsp/helpers.lua
+++ b/lua/oil/lsp/helpers.lua
@@ -84,13 +84,7 @@ M.will_perform_file_operations = function(actions)
     workspace.did_delete_files(deletes)
     workspace.did_rename_files(moves)
 
-    local autosave = config.lsp_file_methods.lsp_rename_autosave or config.lsp_rename_autosave
-    if config.lsp_rename_autosave ~= nil then
-      vim.deprecate("lsp_rename_autosave at root level", nil, 'v2.7.0',
-        'oil.nvim',
-        false)
-    end
-
+    local autosave = config.lsp_file_methods.autosave_changes
     if autosave == false then
       return
     end