-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
Thanks for this plugin.
I have a slight issue with Femaco, when I use FeMaco to edit inline code block in a floating window, the formatter tool don't be affected by config (e.g., .stylua.tomal for stylua). I realized that FeMaco create temp file use os.tmpname() default, which return /temp/lua_xxxx, it is out of source folder.
So I add customize post_open_float and create_tmp_filepath for the purpose of creating tempfile in source folder
local function femaco()
local cache_filename
require("femaco").setup({
post_open_float = function(winnr)
print(string.format("post_open_float: %s", winnr))
vim.api.nvim_create_autocmd("WinClosed", {
pattern = "*",
callback = function()
local closed_win = vim.fn.expand("<amatch>")
if tonumber(closed_win)== winnr then
print(string.format("remove temp file %s", cache_filename))
vim.loop.fs_unlink(cache_filename)
end
end,
})
end,
create_tmp_filepath = function(filetype)
cache_filename = string.format("%s/.femaco_%d_%s", vim.fn.getcwd(), math.random(100, 999), filetype)
return cache_filename
end,
})
endeverything works perfect until I open multiple FeMaco floating windows to edit different code blocks. the cache_filename will be override, so some tempfile will not be clean right.
could FeMaco add ability to cleanup temp file?
Refer to null-ls.nvim, which need tempfile to format file sameily
Metadata
Metadata
Assignees
Labels
No labels