Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger FocusGained after closing the terminal window #86

Open
mjakl opened this issue Mar 31, 2023 · 1 comment
Open

Trigger FocusGained after closing the terminal window #86

mjakl opened this issue Mar 31, 2023 · 1 comment

Comments

@mjakl
Copy link

mjakl commented Mar 31, 2023

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 if autoread is active. E.g. when I call echo 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 the autoread option.

It looks like NeoVim has an API for that nvim_ui_set_focus since 0.8.0 (see this ticket).

@mjakl
Copy link
Author

mjakl commented Mar 31, 2023

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant