feat: add support for LSP willRenameFiles (#184)

This commit is contained in:
Steven Arcangeli 2023-10-01 16:41:51 -07:00
parent 956d7fc89b
commit 8f3c1d2d2e
3 changed files with 195 additions and 0 deletions

View file

@ -2,6 +2,7 @@ local cache = require("oil.cache")
local columns = require("oil.columns")
local config = require("oil.config")
local constants = require("oil.constants")
local lsp_helpers = require("oil.lsp_helpers")
local oil = require("oil")
local parser = require("oil.mutator.parser")
local pathutil = require("oil.pathutil")
@ -376,6 +377,19 @@ M.process_actions = function(actions, cb)
end
end
-- send all renames to LSP servers
local moves = {}
for _, action in ipairs(actions) do
if action.type == "move" then
local src_adapter = assert(config.get_adapter_by_scheme(action.src_url))
local dest_adapter = assert(config.get_adapter_by_scheme(action.dest_url))
if src_adapter.name == "files" and dest_adapter.name == "files" then
table.insert(moves, action)
end
end
end
lsp_helpers.will_rename_files(moves)
-- Convert cross-adapter moves to a copy + delete
for _, action in ipairs(actions) do
if action.type == "move" then