Skip to content

Comments

Ability to filter treesitter nodes#2576

Open
kozorork wants to merge 1 commit intoibhagwan:mainfrom
kozorork:main
Open

Ability to filter treesitter nodes#2576
kozorork wants to merge 1 commit intoibhagwan:mainfrom
kozorork:main

Conversation

@kozorork
Copy link

It seems like the treesitter function can only be used to fuzzy-search all symbols. Maybe searching only through specific nodes could be useful (for example to find a function and jump to it)

@gemini-code-assist
Copy link

Summary of Changes

Hello @kozorork, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the treesitter provider by introducing a new filtering mechanism. Previously, the function could only fuzzy-search all available symbols. With this change, users can now provide a custom filter function to narrow down the search to specific types of nodes, such as functions or variables, improving the precision and utility of treesitter-based searches.

Highlights

  • Treesitter Node Filtering: Introduced a new node_filter option to the treesitter function, enabling users to provide a custom function to filter nodes based on their properties and kind.
  • Node Kind Processing: Adjusted the order of node.kind processing to ensure the simplified kind is available before applying the new node_filter.
Changelog
  • lua/fzf-lua/providers/buffers.lua
    • Added node_filter option to the treesitter function to allow custom filtering of nodes.
    • Adjusted the order of node.kind processing to ensure the simplified kind is available for filtering.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a node_filter option to the treesitter provider, which is a great feature. The implementation is sound, but it leaves behind a stale comment after refactoring the code. I've suggested removing it to improve maintainability.

node.kind = node.kind and node.kind:gsub(".*%.", "")
if node.node and (not opts.node_filter or opts.node_filter(node, node.kind)) then
vim.schedule(function()
-- Remove node prefix, e.g. `locals.definition.var`

Choose a reason for hiding this comment

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

medium

The code that removes the node prefix has been moved out of this vim.schedule block to line 595. This comment is now stale and should be removed to avoid confusion.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant