Skip to content

Commit 5a1abc9

Browse files
committed
feat: support nested directory for tmpfile_format
1 parent afce105 commit 5a1abc9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lua/conform/runner.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,14 @@ local function run_formatter(bufnr, formatter, config, ctx, input_lines, opts, c
375375
uv.fs_write(fd, buffer_text)
376376
uv.fs_close(fd)
377377
callback = util.wrap_callback(callback, function()
378+
local rel_dirname = vim.fs.dirname(vim.fs.relpath(ctx.dirname, ctx.filename))
378379
log.debug("Cleaning up temp file %s", ctx.filename)
379380
uv.fs_unlink(ctx.filename)
381+
if rel_dirname ~= "." then
382+
local dirname = vim.fs.joinpath(ctx.dirname, rel_dirname)
383+
log.debug("Cleaning up temp dir %s", dirname)
384+
uv.fs_rmdir(dirname)
385+
end
380386
end)
381387
end
382388

0 commit comments

Comments
 (0)