akinsho / akinsho/toggleterm.nvim

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

Đang mở
#219 8 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Lua
Star
5.6k
Fork
206
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.