diff --git a/README.md b/README.md index 9679fd7..606cbb2 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,8 @@ require("oil").setup({ -- Note that the cleanup process only starts when none of the oil buffers are currently displayed cleanup_delay_ms = 2000, lsp_file_methods = { + -- Enable or disable LSP file operations + enabled = true, -- 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 diff --git a/doc/oil.txt b/doc/oil.txt index 1877be3..d028480 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -55,6 +55,8 @@ CONFIG *oil-confi -- Note that the cleanup process only starts when none of the oil buffers are currently displayed cleanup_delay_ms = 2000, lsp_file_methods = { + -- Enable or disable LSP file operations + enabled = true, -- 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 diff --git a/lua/oil/config.lua b/lua/oil/config.lua index 32da34e..e3fcc10 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -40,6 +40,8 @@ local default_config = { -- Note that the cleanup process only starts when none of the oil buffers are currently displayed cleanup_delay_ms = 2000, lsp_file_methods = { + -- Enable or disable LSP file operations + enabled = true, -- 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 @@ -247,10 +249,12 @@ local M = {} ---@field keymaps_help? oil.SetupSimpleWindowConfig Configuration for the floating keymaps help window ---@class (exact) oil.LspFileMethods +---@field enabled boolean ---@field timeout_ms integer ---@field autosave_changes boolean|"unmodified" Set to true to autosave buffers that are updated with LSP willRenameFiles. Set to "unmodified" to only save unmodified buffers. ---@class (exact) oil.SetupLspFileMethods +---@field enabled? boolean Enable or disable LSP file operations ---@field timeout_ms? integer Time to wait for LSP file operations to complete before skipping. ---@field autosave_changes? boolean|"unmodified" Set to true to autosave buffers that are updated with LSP willRenameFiles. Set to "unmodified" to only save unmodified buffers. diff --git a/lua/oil/mutator/init.lua b/lua/oil/mutator/init.lua index ab24a91..8b72a01 100644 --- a/lua/oil/mutator/init.lua +++ b/lua/oil/mutator/init.lua @@ -389,7 +389,11 @@ M.process_actions = function(actions, cb) "User", { pattern = "OilActionsPre", modeline = false, data = { actions = actions } } ) - local did_complete = lsp_helpers.will_perform_file_operations(actions) + + local did_complete = nil + if config.lsp_file_methods.enabled then + did_complete = lsp_helpers.will_perform_file_operations(actions) + end -- Convert some cross-adapter moves to a copy + delete for _, action in ipairs(actions) do @@ -442,7 +446,9 @@ M.process_actions = function(actions, cb) return end if idx > #actions then - did_complete() + if did_complete then + did_complete() + end finish() return end