Skip to content
New issue

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

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

Already on GitHub? # to your account

Question. Why there is no support for file icons in live_grep, live_grep native? #168

Closed
LoydAndrew opened this issue Oct 5, 2021 · 13 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@LoydAndrew
Copy link

There is no file icons in live_grep, live_grep_native providers. Is this a deliberate choice or some sort of a bug?

@ibhagwan ibhagwan added the question Further information is requested label Oct 5, 2021
@ibhagwan
Copy link
Owner

ibhagwan commented Oct 5, 2021

This is not a bug, the issue is that when using the change:reload event fzf populates the entries on it’s own so fzf-lua wasn’t able to parse the lines and add the icons.

But now that you mention it, since then things have changed and the live_grep_resume version works differently and feeds the reloaded lines into fzf so I can probably solve that now, will keep this thread updated.

ibhagwan added a commit that referenced this issue Oct 6, 2021
Warning: this may cause a performance degradation so you have to
manually enable this by setting `grep.experimental = true` or directly
via `:lua require'fzf-lua'.live_grep({ experimental = true })`
@ibhagwan ibhagwan added the enhancement New feature or request label Oct 6, 2021
@ibhagwan
Copy link
Owner

ibhagwan commented Oct 6, 2021

a499bd7

Worked hard on adding this properly, tried to improve performance as much as I could but there's still a non-negligible difference when running with or without this feature, this is due to the fact that I can no longer simply passthrough the data from rg directly to fzf but rather have to parse the data (find the extension, add the icon, etc, check against git change map, etc) which adds a significant load.

It's not very noticeable in small projects but when running on my home directory with millions of files you can clearly feel the difference so I decided to disable it by default.

To enable it, you have to either enable experimental under grep options during setup:

require'fzf-lua'.setup {
  grep = {
    experimental      = true,
  }
}

Or direcltly with each call:

:lua require'fzf-lua'.live_grep({ experimental = true })

I've enabled it for myself by default and unless I'm running nvim at $HOME it works great and the performance difference is barely noticeable but YMMV.

Let me know if this works well for you?

@LoydAndrew
Copy link
Author

Wow. That was really quick. I tried it on a project with 50 thousand files and it just hangs after first input. On a small project with one thousand files it works just good enough.

@ibhagwan
Copy link
Owner

ibhagwan commented Oct 6, 2021

Wow. That was really quick. I tried it on a project with 50 thousand files and it just hangs after first input. On a small project with one thousand files it works just good enough.

Yes, it was hanging for me too but then after a couple of seconds it “releases” somehow, I still haven’t given up on this but for now it does seem to work fine on small-medium projects which are the majority I would assume.

@LoydAndrew
Copy link
Author

LoydAndrew commented Oct 6, 2021

Sorry for annoyance. But I notice now that custom script ( I modified this script https://github.com/fanliver/vimrg for my needs) for rg command stops working. The last commit where it works is 510aca8
I am using it like live_grep({cmd=vimrg}) or by using setup function .setup {grep = { cmd = "vimrg"} }
I doesn't use vimrg as a custom command just default rg.

@ibhagwan
Copy link
Owner

ibhagwan commented Oct 6, 2021

Sorry for annoyance. But I notice now that custom script ( I modified this script https://github.com/fanliver/vimrg for my needs) for rg command stops working. The last commit where it works is 510aca8 I am using it like live_grep({cmd=vimrg}) or by using setup function .setup {grep = { cmd = "vimrg"} } I doesn't use vimrg as a custom command just default rg.

Probably because I restored the original live_grep function (after the icon and performance enhancements), try running live_grep_native({cmd=vimrg}), this should work as before as live_grep was mapped to the native version.

Now if you can post your modified script here I'll make sure it works in both live_grep and live_grep_native.

@LoydAndrew
Copy link
Author

Yes, it works with a live_grep_native. I just customize go script from https://github.com/fanliver/vimrg . You can do go build and paste it to your HOME dir.

@ibhagwan
Copy link
Owner

ibhagwan commented Oct 6, 2021

I just tried and both versions work, see below with and without filtering, you can see I'm running the non-native version as I have icons in my result set.

Without filtering:
screenshot-1633507214

Excluding all files with *key* - you can see all results from which_key.lua are excluded:
screenshot-1633507195

@LoydAndrew
Copy link
Author

Yes, I can confirm that too now. It doesn't work only if setup function has this line {grep = { cmd = "vimrg"} } and then you invoke FzfLua live_grep . But maybe this is how it should be.

@ibhagwan
Copy link
Owner

ibhagwan commented Oct 6, 2021

Yes, I can confirm that too now. It doesn't work only if setup function has this line {grep = { cmd = "vimrg"} } and then you invoke FzfLua live_grep . But maybe this is how it should be.

Just tried with cmd = "vimrg" in the setup and it works with both native and non-native, there should be no difference where you define the cmd, the one sent to the command at runtime takes precedence but there should be no reason why the one in setup wouldn't work.

@ibhagwan
Copy link
Owner

ibhagwan commented Oct 6, 2021

In any event I just looked at the code of vimrg it's very simple, so while I cannot add that functionality to live_grep_native (as the query arguments are handled directly by fzf) I can easily add this to live_grep - just need to make sure it has enough customization so it doesn't conflict with other operations users might want to do (such as searching for the separator).

@LoydAndrew
Copy link
Author

LoydAndrew commented Oct 6, 2021

Yeah that's kind of a thing. I replace for myself this separator > to / cause if you want to search some html or jsx/tsx it doesn't conflict that much.
And change the glob order so it becomes second like this
Rg>command /*.rs *.go<
Cause again it's more often that you initially search for something like command and then you want to filter it by filetype to narrow down search or maybe it's just me. And big thanks for your quick and great response!

@ibhagwan
Copy link
Owner

ibhagwan commented Oct 6, 2021

Closing this issue, will update in #167 as it makes more sense there.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants