Vim icon indicating copy to clipboard operation
Vim copied to clipboard

[Feature Request] navigate peeked definitions

Open nagibyro opened this issue 7 years ago • 4 comments

Is this a BUG REPORT or FEATURE REQUEST? (choose one):

  • Feature Request

What happened: I've recently become quite a fan of the peek definition feature in vscode but noticed that vim doesn't gain focus/no cursor is placed inside the window. It'd be nice to be able to navigate and scroll through the peeked definitions with vim key commands.

How to reproduce it (as minimally and precisely as possible): Use the peek definition command and try and navigate with vim key commands.

nagibyro avatar May 23 '18 01:05 nagibyro

Adding @ecotner's description from #4187 as it gives a clearer view of the request

Is your feature request related to a problem? Please describe.

I frequently find myself using the "peek reference" and "peek definition" shortcuts to inspect function definitions that I don't want to scroll up to or open a new file in order to view. However, when I do use these peek commands, if I want to scroll or edit the code in the popup, I need to click into the popup with my mouse, which is frustrating because it takes my fingers away from the home row.

Describe the solution you'd like

I would like if upon using one of the peek commands (especially "peek definition") I could immediately start scrolling or manipulating text in the popup rather than having to click into it with the mouse first.

Describe alternatives you've considered

As mentioned before, clicking into the popup transfers control to the popup, which I can then use vim commands in. It's not that bad but breaks my flow.

Additional context

When I say "popup", this is what I mean (which I get by using Alt + F12): https://user-images.githubusercontent.com/10482181/67017035-23b91100-f0c7-11e9-8dff-f10f3fb2ba92.png

nagibyro avatar Apr 04 '21 04:04 nagibyro

VS Code by default focuses the tree view (the view to the right in the "popup"). You can by default switch to the editor with Cmd/Ctrl+K F2.

You can also configure VS Code to by default focus the editor when quick peek is opened. Change the setting of editor.peekWidgetDefaultFocus to editor.

fregren avatar Oct 05 '21 14:10 fregren

I added the following keybinding to make Tab toggle focus between the right side tree view and the peek editor:

  {
    "key": "tab",
    "command": "togglePeekWidgetFocus",
    "when": "inReferenceSearchEditor && vim.active && vim.mode != 'Insert' || referenceSearchVisible"
  },

mogelbrod avatar Nov 05 '22 17:11 mogelbrod

The above keybinding is great, however switches focus to the nav list when pressing tab in insert mode.

This is because referenceSearchVisible is always true when the peek popup is open.

This version fixes that by checking:

  • isPeekPopupOpen & isEditorFocused & isVimInInsertMode
  • or isPeekPopupOpen & !isEditorFocused (e.g. focused on the sidebar nav)
  • see vscode where clauses for reference
{
  "key": "tab",
  "command": "togglePeekWidgetFocus",
  "when": "referenceSearchVisible && inReferenceSearchEditor && vim.active && vim.mode != 'Insert' || referenceSearchVisible  && !inReferenceSearchEditor"
}

francisashley avatar Aug 06 '24 11:08 francisashley