|
@@ -32,6 +32,37 @@ vim.api.nvim_create_autocmd('BufLeave', {
|
|
|
command = 'stopinsert',
|
|
|
})
|
|
|
|
|
|
+-- rename
|
|
|
+vim.api.nvim_create_autocmd('User', {
|
|
|
+ pattern = 'MiniFilesActionRename',
|
|
|
+ callback = function(opts)
|
|
|
+ local params = {
|
|
|
+ files = {{
|
|
|
+ oldUri = vim.uri_from_fname(opts.data.from),
|
|
|
+ newUri = vim.uri_from_fname(opts.data.to),
|
|
|
+ }}
|
|
|
+ }
|
|
|
+ local bufnr = vim.fn.bufadd(opts.data.to)
|
|
|
+
|
|
|
+ local clients = vim.lsp.get_clients({ bufnr = bufnr })
|
|
|
+ for _, client in ipairs(clients) do
|
|
|
+ if client:supports_method('workspace/willRenameFiles') then
|
|
|
+ local resp = client:request_sync('workspace/willRenameFiles', params, 5000, bufnr)
|
|
|
+ if resp and resp.result ~= nil then
|
|
|
+ vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding)
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ for _, client in ipairs(clients) do
|
|
|
+ if client:supports_method('workspace/didRenameFiles') then
|
|
|
+ client:notify('workspace/didRenameFiles', params)
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end,
|
|
|
+ nested = true,
|
|
|
+})
|
|
|
+
|
|
|
-- formatting
|
|
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
|
|
callback = function(opts)
|