akinsho / akinsho/toggleterm.nvim

Spawn terminal job using a list (and other jobstart() opts)

オープン
#219 コメント 8 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
Lua
スター
5.6k
フォーク
206
PR マージ指標
30日以内にマージされた PR はありません

説明

Would it be possible to use a list as terminal command instead of using a string? The [jobstart() api](https://neovim.io/doc/user/builtin.html#jobstart()) it is possible to supply a list, which is often convenient when calling a process, because all the argument quoting will be done by `jobstart()`.

I looked [at the code of task:__spawn()](https://github.com/akinsho/toggleterm.nvim/blob/6c7f5dbdd69bc5611a85194ddca83ac2c8ee84d6/lua/toggleterm/terminal.lua#L313-L333) and it seems that every command gets a comment with terminal id appended, e.g. `;#toggleterm#1`. I was wondering what is the reason for doing this? Are these id/filetype used somewhere else? Or would it be safe to remove it? This way it would be possible to just pass shell directly.

I guess that this is also the reason why https://github.com/akinsho/toggleterm.nvim/issues/184 happens. In `local cmd = self.cmd or config.get("shell")` a new shell invocation is created, but later `termopen` also starts a shell process, so there are 2 shells.

And a follow up question: would it be possible to pass other opts to [jobstart() api](https://neovim.io/doc/user/builtin.html#jobstart()). The interesting option is `env` which can be helpful for starting jobs that e.g. need to first load some environment like when using Python virtual environments. Then we could just pass `PYTHONPATH` via `env` instead of doing things like `cmd = "sh -c 'source venv/bin/activate && python script.py'"`.

I could create a PR, but wanted to hear your opinion first.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。