joshmu / periscope

Ripgrep powered peek search in VSCode 🫧
https://marketplace.visualstudio.com/items?itemName=joshmu.periscope
Other
21 stars 5 forks source link

Feature request: transforming rg -e/-F queries with vscode regular expressions #51

Open PiotrSokol opened 6 months ago

PiotrSokol commented 6 months ago

Hi, I just came across this project and I love it!

The idea to use vscode regexp can potentially save a lot of time while writing complicated queries for rg.

My example use case is querying '^\h*\\begin\{$2[\w\*]*?\}\s*(?:\\label\{([^\}])\}|\[(.*)\])', where $2 is transformed according to

"periscope.rgQueryParams": [
        {
            "regex": "((?<=(?<![\\w\\#\\@]))@([a-zA-Z]+(?:\\\\*)?)(?=(?:$|\\s)))",
            "param": "-e '^\\h*\\\\begin\\{$2[\\w\\*]*?\\}\\s*(?:\\\\label\\{([^\\}])\\}|\\[(.*)\\])'"
        }
]

I clumsily implemented this-- I pass the query as and additional flag -e .... If you're interested I can make a PR and discuss the specifics.

joshmu commented 6 months ago

Hey @PiotrSokol

If you think there is value for others then feel free to raise a PR.

I'm always curious to understand how periscope is being used. :) glad you like it 👍