akinsho / akinsho/toggleterm.nvim

[BUG] Navigating inside an already open and showing terminal does not enter insert mode

未关闭
#455 5 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Lua
星标
5.6k
派生
206
PR 合并指标
30 天内没有已合并 PR

描述

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

When a terminal is already open and showing and I navigate into another buffer split and go back to the terminal again, it does not enter inser mode. I have terminal_mapping and inser_mapping set to true. When opening the terminal with the mapping it works but once I navigate out and let it open, it does not enter insert automatically again.

I tried setting up a autocmd for TermEnter and BufEnter for term://* pattern but was not able to manage to do it.
Like so:

```lua
-- Auto insert mode when entering terminal
local augroup_term_insert = vim.api.nvim_create_augroup("Term-Insert", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter", "WinEnter", "TermOpen", "TermEnter" }, {
group = augroup_term_insert,
pattern = 'term://*',
command = 'startinsert'
})
```

I am not sure if this should already work and is a configuration issue on my side or if the terminal_mapping only works for opening and closing the terminal by design.

### Expected Behavior

navigating out and inside to the terminal buffer should work as expected. when coming back to the terminal buffer, enter insert mode, like when opening it with mapping.

### Steps To Reproduce

setup toggleterm with the default config

### Environment

```Markdown
- OS: macOS 13.4.1 (22F82)
- neovim version: v0.9.1
- Shell: zsh 5.9 (x86_64-apple-darwin22.0)
```

### Anything else?

_No response_

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。