## Description
I was trying to create a simple `select` picker to choose terminals to
open.
With the current implementation only the fields `cmd` and `id` are
exposed. `cwd` and `env` are not which are used to get the terminal id
as well.
`M.list()` uses `vim.tbl_filter` which turns `terminals` into a list
removing the keys terminal ids. Even if that was not the case (i.e using
a normal `for` loop to add to `terminals`) the keys would be a string
due to `vim.inspect` and one would have to use patterns to extract
information from them.
It's easier to just add `cwd` and `env` to `vim.b[buf].snacks_terminal`
to have that information available and be easier for users to manipulate
which terminal they want to choose and open.
Also added `opts.count` as an option to be able to programmatically
choose the terminal with exactly the same options when it was created,
so one can just do
```lua
local term = vim.b[buf].snacks_terminal
Snacks.terminal(term.cmd, { cwd = term.cwd, env = term.env, count = term.id })
```
to programmatically invoke a certain terminal.
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
## Related Issue(s)
Solves my issue and #2271 as well.
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Description
1. Currently `gf` only search in current working directory. Use `**` in
`findfile()` to do a recursive search. Otherwise, `gf` can't open a file
down a nested directory.
2. `vim.schedule` the command `vim.cmd("e ", f)`, because otherwise it
opens the file but goes to the buffer that was already opened. Not sure
why this happens, but if we schedule it correctly goes to the opened
buffer by `gf`.
3. Also changed `self:close()` to `self:toggle()`, so as not to reset
the state of the terminal unless a user specifically exits the terminal.
This is rather personal and also based on a [LazyVim
Discussion](https://github.com/LazyVim/LazyVim/discussions/4741), but I
can understand if it's not wanted in the scope of `snacks.nvim` and
probably users could change the behavior of the `gf` key in their
personal configuration.
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
## Related Issue(s)
[A LazyVim
discussion](https://github.com/LazyVim/LazyVim/discussions/4741)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->