stevearc / dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
MIT License
1.73k stars 32 forks source link

Run FZF cancel callback based on v:event #10

Closed gbrlsnchs closed 2 years ago

gbrlsnchs commented 2 years ago

Inspired by this plugin, I'm experimenting with fzf#run myself, and its terminal command returns 1 if there's an error with the command or 130 if nothing is chosen (I tested pressing both Esc and Ctrl+C).

Therefore, you can check v:event to capture the fzf command exit status and only run the cancel callback when the status is not 0 (or only when it's 130 depending on how you want to handle errors). You can do that in a TermClose autocmd, instead of deferring a callback using BufLeave.

stevearc commented 2 years ago

Yeah, I do like that better than the deferred function. Thanks for the tip!