Skip to content

vim: escape key should always immediately exit input mode #4716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bulletmark opened this issue Apr 28, 2025 · 5 comments · Fixed by #4735
Open

vim: escape key should always immediately exit input mode #4716

bulletmark opened this issue Apr 28, 2025 · 5 comments · Fixed by #4735
Assignees
Labels
bug Something isn't working good first issue (typescript) Good first issue on the frontend/typescript

Comments

@bulletmark
Copy link
Contributor

bulletmark commented Apr 28, 2025

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

@bulletmark
Copy link
Contributor Author

bulletmark commented Apr 30, 2025

@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.

@akshayka akshayka reopened this Apr 30, 2025
@akshayka akshayka added the good first issue (typescript) Good first issue on the frontend/typescript label Apr 30, 2025
@akshayka
Copy link
Contributor

Thanks, sorry about that. I only tested with LSP.

I've reopened and marked as a good first issue for those looking to contribute.

@mscolnick
Copy link
Contributor

@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.

@bulletmark
Copy link
Contributor Author

@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!

@bulletmark
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue (typescript) Good first issue on the frontend/typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants