diff options
author | Tomasz N <przepompownia@users.noreply.github.com> | 2024-02-08 22:06:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-08 13:06:54 -0800 |
commit | f0e61e6d92b5ce115388f8a03f8d34f00a3dea92 (patch) | |
tree | 6e0ac4b09c53f4fe8b9176a4845fbcca33197f66 /runtime/lua/vim/lsp/util.lua | |
parent | 52b6a9a93b06bc897d9982139c143127003f42dc (diff) | |
download | rneovim-f0e61e6d92b5ce115388f8a03f8d34f00a3dea92.tar.gz rneovim-f0e61e6d92b5ce115388f8a03f8d34f00a3dea92.tar.bz2 rneovim-f0e61e6d92b5ce115388f8a03f8d34f00a3dea92.zip |
fix(lsp): rename fails on missing parent directory #27291
Problem:
If a rename results in a path that has missing parent directory(s), it
will fail.
Solution:
Do a recursive mkdir before attempting the rename.
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index b5e15e135c..86bef1ac8a 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -693,6 +693,9 @@ function M.rename(old_fname, new_fname, opts) end) end + local newdir = assert(vim.fs.dirname(new_fname)) + vim.fn.mkdir(newdir, 'p') + local ok, err = os.rename(old_fname, new_fname) assert(ok, err) |