Open mjakl opened 1 year ago
Small sidenote: when toggling FTerm, it is possible to include :checktime
to check for file-changes and reload on demand. For example: vim.keymap.set("t", "<F7>", "<C-\\><C-n><CMD>lua require('FTerm').toggle()<CR>:checktime<CR>")
To trigger this behavior on exit (FTerm close), I can add a on_exit
callback:
on_exit = function()
vim.cmd(":checktime")
end,
When I manipulate an open file through FTerm (like resetting the file via LazyGit, or simply
echo test >> file.txt
, I need to manually reload the file from disk when I close/toggle FTerm.NeoVim usually checks for modifications on
FocusGained
events, and reloads the files automatically ifautoread
is active. E.g. when I callecho anothertest >> file.txt
in a separate terminal, and then switch back to Vim, the file is reloaded automatically.Is it possible for FTerm to issue the
FocusGained
event to trigger the check if the file has been modified when closing FTerm? Users can decide how to deal with this through theautoread
option.It looks like NeoVim has an API for that
nvim_ui_set_focus
since 0.8.0 (see this ticket).