When mitmproxy runs inside a Neovim :terminal and you edit a flow, it normally
spawns a nested editor inside the terminal buffer. This plugin intercepts that
and opens the file in a real Neovim buffer instead.
- The plugin sets
$MITMPROXY_EDITORto a helper script. - When mitmproxy triggers an edit (e.g. pressing
eon a request body), it invokes the helper script instead of a nestedvim. - The helper script detects the parent Neovim via the
$NVIMsocket and usesnvim --server --remote-exprto open the temp file in a split. - The script blocks until you save and close the buffer (
:wq), then mitmproxy reads back the edited content.
- Neovim >= 0.7 (needs
--server/--remote-exprsupport) - mitmproxy
{
"jdearmas/mitmproxy-editor.nvim",
opts = {},
}{
dir = "~/git/mitmproxy-editor.nvim",
opts = {},
}require("mitmproxy_editor").setup()These are the defaults:
require("mitmproxy_editor").setup({
-- How to open the editor buffer: "split", "vsplit", "tabedit"
open_cmd = "split",
-- Jump back to the terminal buffer and enter insert mode after editing
auto_return = true,
-- Also override $EDITOR/$VISUAL (applies to git, crontab, etc.)
-- When false, only $MITMPROXY_EDITOR is set (mitmproxy-specific)
set_editor = false,
})Launch mitmproxy in a terminal buffer with optional arguments:
:Mitmproxy
:Mitmproxy -p 8888
:Mitmproxy --mode reverse:http://localhost:3000
You can also just run mitmproxy manually in any Neovim terminal —
$MITMPROXY_EDITOR is set process-wide so it's inherited automatically.
- Open mitmproxy in a terminal (
:Mitmproxyor:terminal mitmproxy) - Select a flow and press
eto edit the request/response - The temp file opens in a Neovim split instead of a nested editor
- Edit, then
:wqto send changes back to mitmproxy - Cursor returns to the mitmproxy terminal automatically
Set set_editor = true to also redirect $EDITOR and $VISUAL. This makes
git commit, kubectl edit, crontab -e, and anything else that spawns an
editor open in the parent Neovim when run inside a :terminal.
MIT