# Neovim froze in Insert mode waiting for tmux list-panes


On a remote machine, Neovim stopped responding when I entered Insert mode inside tmux. I was running Neovim 0.10.2 with LazyVim, `nvim-cmp`, and `cmp-tmux`, which suggests words from other tmux panes.

The frozen editor was waiting for `tmux list-panes`. **Removing just `cmp-tmux` fixed the freeze.** The other completion sources stayed enabled.

&lt;!--more--&gt;

## Ask the frozen process what it is waiting for

Instead of restarting the frozen editor, I inspected it from a second shell on the same machine:

```bash
ps -u &#34;$USER&#34; -o pid,ppid,stat,wchan:24,args | grep -E &#39;[n]vim&#39;
# Use the PID of the editor process (the --embed child if there are two).
ps --ppid 43971 -o pid,ppid,stat,wchan:24,args
```

The relevant lines from the process listing (columns trimmed):

```text
  PID  PPID WCHAN                 COMMAND
43971 43970 pipe_wait             nvim --embed nord-status-content.conf
44758 43971 poll_schedule_timeout tmux list-panes -F #{pane_id} -a
```

![Process listing showing Neovim in pipe_wait and its tmux list-panes child](featured-image.png)

*Rendered excerpt of the process listing. The `PPID` on the boxed line matches the PID of the blocked Neovim process.*

The parent-child relationship was the first clue. The file descriptor listing made the connection: the tmux client&#39;s stdout and one of Neovim&#39;s read descriptors pointed to the **same pipe**. Neovim was stuck reading from it.

## Why a completion source could freeze the editor

The `cmp-tmux` source calls `get_panes()` to find panes to scan. I had `all_panes = true`, so it added `-a` to `tmux list-panes -F &#39;#{pane_id}&#39;`. The blocking part is in `lua/cmp_tmux/tmux.lua`, before the plugin starts any asynchronous jobs to capture pane contents:

```lua
local handle = io.popen(cmd)
if handle ~= nil then
    local data = handle:read(&#39;*all&#39;)
    -- Parse the pane IDs, then close the handle.
end
```

`read(&#39;*all&#39;)` waits for end-of-file. If the tmux client doesn&#39;t finish, that read holds up Neovim&#39;s main loop. Completion made the whole editor look frozen, not just the popup menu.

A fresh request from another shell did return later:

```bash
timeout 2s tmux list-panes -F &#39;#{pane_id}&#39; -a
```

That check showed tmux could answer a new request. It didn&#39;t explain why the original client stalled, and I didn&#39;t need to solve that to remove the blocking call from my editor.

## Workaround: skip tmux completion for one launch

```bash
env -u TMUX nvim path/to/file
```

`cmp-tmux` checks for the `TMUX` environment variable. Unsetting it for this launch makes the plugin skip pane completion without changing the parent shell or any config files. This won&#39;t unfreeze an existing editor, and other tmux-aware features in the new process may behave differently too.

## Fix: remove only the tmux source

My setup builds on the [nvim-cmp configuration]({{&lt; relref &#34;2024-07-02-nvim-cmp&#34; &gt;}}). On the affected machine I backed up the active spec before editing it:

```bash
config=&#34;$HOME/.config/nvim/lua/plugins/nvim-cmp.lua&#34;
cp -p -- &#34;$config&#34; &#34;$config.bak.$(date &#43;%Y%m%d)&#34;
```

In `~/.config/nvim/lua/plugins/nvim-cmp.lua`, I removed two things:

1. `&#39;andersevenrud/cmp-tmux&#39;,` from the `nvim-cmp` dependencies.
2. The `name = &#39;tmux&#39;` source and its options from `cmp.config.sources(...)`. It was the only source in the last group, so I removed that group and the comma that had separated it from the previous one.

Then I opened a fresh Neovim session. I didn&#39;t need to restart tmux, change terminal settings, or turn off `nvim-cmp`.

## Verify that Insert mode and completion still work

To check the active source list in a fresh editor, first load the plugin, then print its sources:

```vim
:Lazy! load nvim-cmp
:lua print(vim.inspect(vim.tbl_map(function(s) return s.name end, require(&#39;cmp&#39;).get_config().sources)))
```

```text
{ &#34;nvim_lsp&#34;, &#34;nvim_lua&#34;, &#34;luasnip&#34;, &#34;buffer&#34;, &#34;path&#34;, &#34;neorg&#34;, &#34;orgmode&#34;, &#34;dotenv&#34; }
```

The new config passed a Lua syntax check. With `TMUX` set and `nvim-cmp` loaded, a fresh headless Neovim processed `i` followed by test text and reported `Mode: i; buffer: insertmodetest`. Reopening Neovim in the normal terminal session fixed the original symptom too.

The only feature I lost was suggestions from other tmux panes. If the whole editor stops responding during completion, check its child processes before disabling every plugin: a single synchronous call can make an otherwise healthy editor look dead.


---

> 作者: william  
> URL: https://williamlfang.github.io/2026-11-25-nvim-insert-mode-cmp-tmux/  

