Skip to content

Maintain context across calls #2

Description

@ChrisPenner

Figured I'd drop a note here to ask your opinion before I go implement anything; for context:

My goal is to rig up some fzf vim commands to very quickly search docs without leaving the editor.

I'm imagining running something like this:

hdc $currentWord | rg '^\d+' | fzf --tac | rg '^(\d+)' -or '$1' | hdc 

Breaking it down:

  1. hdc $currentWord: Search hoogle for the word under the cursor (or type one myself)
  2. rg '^\d+' use ripgrep to find the list of possible results (all result rows start with a number)
  3. fzf --tac use the fzf fuzzyfinder to interactively select which result I want docs for
  4. rg '^(\d+)' -or '$1' | hdc pull out only the number from the selected line and pass it to hdc to give me the docs.

Currently this doesn't work because hdc loses all of its context in between invocations.

I'm wondering, do you have ideas on how best to solve this? Ideally hdc would have fuzzy-find built-in, but that might be a bit too much to ask, and would only help support this very specific workflow.

Although it's a bit of a hack since it might cause confusion if multiple scripts are running at once, I'm wondering if stashing the context on exit and re-loading it on startup would be a reasonable solution here?

Perhaps a more reasonable solution would be to simply rely on the search being cached and provide a full query as the second search?

Let me know your thoughts, thanks!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions