marimo
marimo copied to clipboard
vim: escape key should always immediately exit input mode
If a completion/suggestion popup appears when entering text using vim mode in Marimo, then the first escape just clears the suggestion and stays in insert mode. Sometimes. due to timing, you may barely notice the popup just before you press escape so the user assumes he is in normal mode, but marimo leaves him in insert mode which is a bad user experience.
In vim mode, escape should not be recognized to clear completion/suggestion hints. Escape should always just immediately exit insert mode. Any pending completion/suggestion should just be ignored. This is how vim, neovim, vscode+vim, zed+vim, and pycharm+vim all work.
Refer also this discussion.
Environment
$ marimo env
{
"marimo": "0.13.2",
"OS": "Linux",
"OS Version": "6.14.4-arch1-1",
"Processor": "",
"Python Version": "3.13.3",
"Binaries": {
"Browser": "--",
"Node": "v23.9.0"
},
"Dependencies": {
"click": "8.1.8",
"docutils": "0.21.2",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.8",
"narwhals": "1.37.0",
"packaging": "24.2",
"psutil": "7.0.0",
"pygments": "2.19.1",
"pymdown-extensions": "10.15",
"pyyaml": "6.0.2",
"starlette": "0.46.2",
"tomlkit": "0.13.2",
"typing-extensions": "4.13.2",
"uvicorn": "0.34.2",
"websockets": "15.0.1"
},
"Optional Dependencies": {
"altair": "5.5.0",
"anywidget": "0.9.18",
"duckdb": "1.2.2",
"nbformat": "5.10.4",
"openai": "1.76.0",
"pandas": "2.2.3",
"polars": "1.28.1",
"pyarrow": "20.0.0",
"pycrdt": "0.11.1",
"python-lsp-ruff": "2.2.2",
"python-lsp-server": "1.12.2",
"ruff": "0.11.7",
"sqlglot": "26.16.2"
},
"Experimental Flags": {
"inline_ai_tooltip": true,
"lsp": true
}
}
Code to reproduce
No response
@akshayka this commit (as included in marimo 0.13.3) does not fix this issue. If you have both an LSP and an AI completion/suggestion presented then the escape only closes the AI suggestion and still leaves you in input mode.
Thanks, sorry about that. I only tested with LSP.
I've reopened and marked as a good first issue for those looking to contribute.
@bulletmark - we'd love your help / expertise on this, so we can avoid the back and forth. happy to pair on this with you, but I don't use vim so I don't quite know what correct looks like.
@mscolnick, simply, when using vim mode and you press escape, you should always immediately exit input mode.
Prior to marimo 0.13.3, if you have any completion/suggestion presented then pressing escape would just remove that completion/suggestion but erroneously leave you still in input mode. @akshayka changed it in 0.3.13 so that escape also exits input mode, but this only works if either a single LSP (completion) or AI (suggestion) is presented. The current bug in 0.13.3 (and 0.13.4) is that if BOTH are presented then escape clears both the completion and suggestion but still leaves you in input mode. From @akshayka 's response above I am pretty sure he understands this issue.
BTW, I tested all these scenarios in vim, neovim, vscode+vim, zed+vim, and pycharm+vim and they all work correctly. They clear both the LSP completion and AI suggestion and also immediately exit input mode.
I've just lived with this bug and only bothered to write up this issue when I saw that discord post from another vim user complaining about input/normal mode switching. It would be really handy if the next developer you guys employ is a vim user!
My description of this problem is wrong. Escape fails to vim exit input mode whenever an AI suggestion is displayed, regardless of whether an LSP completion is displayed or not. So it seems 0.13.3 fixed the problem for LSP completions, and now marimo (currently = 0.13.6) just needs fixing for AI suggestions.
@akshayka, I built from latest main and this appears to be fixed. Thank you very much.
Of course. Thank you for reporting the issue.
On Mon, May 19, 2025 at 6:22 PM Mark Blakeney @.***> wrote:
bulletmark left a comment (marimo-team/marimo#4716) https://github.com/marimo-team/marimo/issues/4716#issuecomment-2892635820
@akshayka https://github.com/akshayka, I built from latest main and this appears to be fixed. Thank you very much.
— Reply to this email directly, view it on GitHub https://github.com/marimo-team/marimo/issues/4716#issuecomment-2892635820, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPG4REZPEPDTO6LFHMFKET27J7VJAVCNFSM6AAAAAB4BRGVF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOJSGYZTKOBSGA . You are receiving this because you were mentioned.Message ID: @.***>