blob: a466568120a7121958bc3f9c185e990cfbde5aa9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-- Updates references (imports, etc.) when a file or folder is renamed/moved in mini.files
local function update_references(from, to)
local params = { files = { { oldUri = vim.uri_from_fname(from), newUri = vim.uri_from_fname(to) } } }
for _, client in ipairs(vim.lsp.get_clients()) do
if client:supports_method("workspace/willRenameFiles") then
local response = client:request_sync("workspace/willRenameFiles", params, 3000, 0)
if response and response.result then
vim.lsp.util.apply_workspace_edit(response.result, client.offset_encoding)
end
end
if client:supports_method("workspace/didRenameFiles") then
client:notify("workspace/didRenameFiles", params)
end
end
end
vim.api.nvim_create_autocmd("User", {
pattern = { "MiniFilesActionRename", "MiniFilesActionMove" },
callback = function(event)
update_references(event.data.from, event.data.to)
end,
})
|