diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 3059dc84..8465ca89 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -59,6 +59,27 @@ return { }, }, config = function(_, opts) + opts.event_handlers = opts.event_handlers or {} + + local function on_move(data) + local clients = vim.lsp.get_active_clients() + for _, client in ipairs(clients) do + if client:supports_method("workspace/willRenameFiles") then + local resp = client.request_sync("workspace/willRenameFiles", { + files = { { oldUri = vim.uri_from_fname(data.source), newUri = vim.uri_from_fname(data.destination) } }, + }, 1000) + if resp and resp.result ~= nil then + vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) + end + end + end + end + + local events = require("neo-tree.events") + vim.list_extend(opts.event_handlers, { + { event = events.FILE_MOVED, handler = on_move }, + { event = events.FILE_RENAMED, handler = on_move }, + }) require("neo-tree").setup(opts) vim.api.nvim_create_autocmd("TermClose", { pattern = "*lazygit",