Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/disable lsp file methods #477

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/oil.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lua/oil/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
10 changes: 8 additions & 2 deletions lua/oil/mutator/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down