Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question/idea: feasibility of scope-aware completions #6

Open
matu3ba opened this issue Jul 15, 2022 · 3 comments
Open

question/idea: feasibility of scope-aware completions #6

matu3ba opened this issue Jul 15, 2022 · 3 comments

Comments

@matu3ba
Copy link

matu3ba commented Jul 15, 2022

In theory one should be able to use treesitter to get the current scope attached to the cursor and filter search results based on that.

Do there exist any experiments with performance numbers based on that approach?
It is very frustrating to get completion results for things, which are never in scope (although only a lsp can rule this out in all cases for macro resolution).

@prurigro
Copy link

prurigro commented Mar 4, 2024

Even an option that limits responses to the current filetype would be ideal

@quangnguyen30192
Copy link
Owner

With response limit, you can achieve this using cmp config https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L614C1-L615C1

@prurigro
Copy link

prurigro commented Mar 6, 2024

Hey, thanks for the response!

I tried setting the max_item_count to 5, and while it does limit the responses to 5 (which is good to avoid getting flooded with irrelevant values), the responses at the top don't seem any more likely to be from files that have the same filetype/extension as the current buffer.

The entry_filter option seemed like it might work, but neither entry nor ctx seem to include the information that pops up showing the file it originated from. If I was able to access just the originating file, I could compare the matching file extension against string.match(vim.fn.expand('%'), "[^%.]*$"), but maybe the data in that popup doesn't make it out of cmp-nvim-tags?

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

No branches or pull requests

3 participants