numToStr / FTerm.nvim

:fire: No-nonsense floating terminal plugin for neovim :fire:
MIT License
743 stars 23 forks source link

Callback for scratch terminals #42

Closed cempassi closed 2 years ago

cempassi commented 2 years ago

After a process in a scratch terminal is executed, it would be useful to be able to execute a lua function taking the exit_status of the job as it's input.

I think the implementation should be pretty straight-forward as the building blocks already seems to be in place ([jobwait](https://neovim.io/doc/user/eval.html#jobwait())).

I'm thinking about two main api:

My main goal is to be able to interact with nvim-notify nicely.

numToStr commented 2 years ago

I haven't looked at it for myself to how to implement this. This plugin only contains a single Lua class that is the base of all the terminal features ie. default, custom, and scratch. If this gets implemented then every terminal will get the benefit of it 😄 .

Implementation wise I'll probably go with this

lua require('FTerm').scratch({ cmd = 'yarn build' , on_exit = function(code) end})

Also, PR is welcome if you wanna give this a shot.