Skip to content

bug: Extend LSP go-to-definition fallback to context menu and cmd+click#10102

Merged
Light2Dark merged 5 commits into
mainfrom
fix/go-to-definition-lsp-fallback
Jul 9, 2026
Merged

bug: Extend LSP go-to-definition fallback to context menu and cmd+click#10102
Light2Dark merged 5 commits into
mainfrom
fix/go-to-definition-lsp-fallback

Conversation

@Light2Dark

Copy link
Copy Markdown
Member

This pull request was authored by a coding agent.

📝 Summary

Follow-up to #10099 / #7135.

F12 go-to-definition already falls through to the language server when marimo cannot resolve a symbol. This PR extends that same fallback to the other entry points:

  • Context menu "Go to Definition"
  • Cmd/Ctrl+click navigation

Adds a shared goToDefinitionWithLspFallback helper that tries marimo's notebook resolver first, then triggers the LSP keybinding via runScopeHandlers.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

Made with Cursor

F12 already falls through to the language server when marimo cannot
resolve a symbol; route the context menu and cmd+click entry points
through the same fallback so external definitions work consistently.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Light2Dark Light2Dark added the bug Something isn't working label Jul 8, 2026
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jul 8, 2026 4:31pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Architecture diagram
sequenceDiagram
    participant User
    participant EdView as EditorView
    participant GotoDef as goToDefinitionWithLspFallback
    participant Marimo as goToDefinitionAtCursorPosition
    participant LSPTrig as requestLspGoToDefinition
    participant LSPHandler as LSP Keymap Handler

    Note over User,LSPHandler: Go‑to‑definition flows (F12 / context menu / cmd+click)

    alt F12 keybinding
        User->>EdView: F12 keydown
        EdView->>GotoDef: run callback
    else Context menu item click
        User->>CellActionsContextMenu: click "Go to Definition"
        CellActionsContextMenu->>GotoDef: call with editorView
    else Cmd+click on underlined symbol
        User->>MetaUnderlineVariablePlugin: click
        Note over MetaUnderlineVariablePlugin: Moves cursor to clicked position first
        MetaUnderlineVariablePlugin->>GotoDef: call with editorView
    end

    GotoDef->>Marimo: try marimo's notebook resolver
    Marimo->>EdView: check variables state, navigate if found
    alt Marimo resolved symbol
        Marimo-->>GotoDef: true
        GotoDef-->>User: true (navigated)
    else Marimo cannot resolve (e.g. external library)
        Marimo-->>GotoDef: false
        GotoDef->>LSPTrig: fallback to LSP
        LSPTrig->>EdView: keyboard event (F12) + runScopeHandlers
        EdView->>LSPHandler: trigger F12 keybinding
        LSPHandler-->>User: navigate (if LSP responds)
    end
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread frontend/src/core/codemirror/go-to-definition/utils.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the existing “marimo resolver → LSP fallback” go-to-definition behavior beyond the F12 keybinding to additional entry points (context menu and Cmd/Ctrl+click) by introducing a shared helper that triggers the LSP handler when marimo can’t resolve a symbol.

Changes:

  • Added goToDefinitionWithLspFallback (and requestLspGoToDefinition) to unify resolution logic and invoke LSP via CodeMirror scope handlers when needed.
  • Updated the underline (Cmd/Ctrl+click) plugin to dispatch the cursor selection before resolving, so the LSP uses the clicked position.
  • Updated the cell context menu action to use the new fallback helper and added tests for the fallback behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
frontend/src/core/codemirror/go-to-definition/utils.ts Adds LSP fallback helper and a function to programmatically request LSP go-to-definition via keymap handlers.
frontend/src/core/codemirror/go-to-definition/underline.ts Changes Cmd/Ctrl+click handling to move cursor first and then resolve via the shared helper.
frontend/src/core/codemirror/go-to-definition/extension.ts Switches underline click action to call goToDefinitionWithLspFallback.
frontend/src/core/codemirror/go-to-definition/tests/utils.test.ts Adds tests covering fallback-to-LSP and “don’t call LSP when marimo resolves”.
frontend/src/components/editor/cell/cell-context-menu.tsx Context menu “Go to Definition” now uses the shared LSP-fallback helper.

Comment thread frontend/src/core/codemirror/go-to-definition/utils.ts
Translate CodeMirror shortcut strings like Ctrl-F12 into synthetic
keyboard events with proper modifier flags so customized hotkeys still
trigger the language-server fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread frontend/src/core/hotkeys/shortcuts.ts Outdated
Comment thread frontend/src/core/hotkeys/shortcuts.ts Outdated
Replace synthetic keyboard event parsing with a direct keymap lookup,
which handles customized shortcuts without extra shortcut translation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Compare the configured go-to-definition hotkey against each binding's
platform-specific key when invoking keymap handlers programmatically.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread frontend/src/core/codemirror/go-to-definition/utils.ts Outdated
Keep keymap binding platform selection aligned with the platform used
to resolve configured hotkeys from hotkeysAtom.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@Light2Dark
Light2Dark requested a review from kirangadhave July 8, 2026 17:03
@Light2Dark
Light2Dark merged commit 4d91af0 into main Jul 9, 2026
32 checks passed
@Light2Dark
Light2Dark deleted the fix/go-to-definition-lsp-fallback branch July 9, 2026 03:40
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.14-dev39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants