diff options
| author | Skladnayazebra <skladnayazebra@gmail.com> | 2026-11-06 17:02:20 +0100 |
|---|---|---|
| committer | Skladnayazebra <skladnayazebra@gmail.com> | 2026-11-06 17:02:20 +0100 |
| commit | d5dbfc4512f2a9f176ae06136ca08cba9f010083 (patch) | |
| tree | 464898f6c30bcdb54f242eaf65db66ffbced3739 /nvim/lua/config | |
| parent | 797548367e710b9a1b4ff71a30899c4026d1eac2 (diff) | |
Diffstat (limited to 'nvim/lua/config')
| -rw-r--r-- | nvim/lua/config/file-rename.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/nvim/lua/config/file-rename.lua b/nvim/lua/config/file-rename.lua index a466568..0d56e73 100644 --- a/nvim/lua/config/file-rename.lua +++ b/nvim/lua/config/file-rename.lua @@ -1,3 +1,19 @@ +-- Saves the files changed by a workspace edit. Only those, not all buffers like :wall would +local function save_edited_files(edit) + local uris = vim.tbl_keys(edit.changes or {}) + for _, change in ipairs(edit.documentChanges or {}) do + table.insert(uris, change.textDocument and change.textDocument.uri or change.uri) + end + for _, uri in ipairs(uris) do + local buf = vim.uri_to_bufnr(uri) + if vim.api.nvim_buf_is_loaded(buf) and vim.bo[buf].modified then + vim.api.nvim_buf_call(buf, function() + vim.cmd("silent update") + end) + end + end +end + -- 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) } } } @@ -6,6 +22,7 @@ local function update_references(from, to) 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) + save_edited_files(response.result) end end if client:supports_method("workspace/didRenameFiles") then |
