Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ require('femaco').setup({
post_open_float = function(winnr)
vim.wo.signcolumn = 'no'
end
-- create the path to a temporary file
-- create the path to a temporary file, which will clear automatically
create_tmp_filepath = function(filetype)
return os.tmpname()
end,
Expand Down
5 changes: 3 additions & 2 deletions lua/femaco/edit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ M.edit_code_block = function()
}))

local filetype = settings.ft_from_lang(match_data.lang)
vim.cmd('file ' .. settings.create_tmp_filepath(filetype))
local tempfile = settings.create_tmp_filepath(filetype)
vim.cmd('file ' .. tempfile)
vim.bo.filetype = filetype
vim.api.nvim_buf_set_lines(vim.fn.bufnr(), 0, -1, true, match_lines)
-- use nvim_exec to do this silently
Expand All @@ -181,7 +182,7 @@ M.edit_code_block = function()
buffer = 0,
callback = function()
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, true)

vim.loop.fs_unlink(tempfile)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, should this only be for WinClosed and not for BufWritePost?

if tbl_equal(match_lines, lines) then return end

if lines[#lines] ~= '' and settings.ensure_newline(base_filetype) then
Expand Down