Skip to content

ALEFindReferences: add -fzf flag to show output in fzf#5018

Merged
hsanson merged 2 commits intodense-analysis:masterfrom
bretello:preview-fzf
Dec 21, 2025
Merged

ALEFindReferences: add -fzf flag to show output in fzf#5018
hsanson merged 2 commits intodense-analysis:masterfrom
bretello:preview-fzf

Conversation

@bretello
Copy link
Contributor

@bretello bretello commented Jul 28, 2025

This adds :ALEFindReferences -fzf to list/matches found by the LSP Server using fzf and fzf.vim.

Enable this with. This is what's working:

  • Listing/selecting files matched by the LSP using fzf/fzf.vim
  • Showing previews for matches
  • Opening multiple files in splits, buffers, tabs (using fzf's ctrl-t/ctrl-x/ctrl-v fzf.vim's default keybindings)
  • Populating quickfix with matches selected in fzf results

How to use this?

Either:

  • Set g:ale_references_use_fzf = 1 to have fzf be the default ALEFindreferences method

  • Call AleFindReferences -fzf, for example I use:

    nmap <leader>n :ALEFindReferences -relative -fzf -quickfix <CR>
    

Demo

Here's what this looks like:

asciicast

alefindreferences-fzf

Related: #2252, #3321, #5001

Copy link
Member

@w0rp w0rp left a comment

Choose a reason for hiding this comment

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

Seems like a decent idea to me for fzf users. You could move the fzf specific code to an autoload/ale/fzf.vim script so it's only loaded on demand. You could edit the HandleLSPResponse function back to how it was without the early return as it was fine how it was and we don't need such a big diff.

\)
endfor
function! ale#references#ShowInFzf(item_list, options) abort
let name = "LSP References"
Copy link
Member

Choose a reason for hiding this comment

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

Use the l: variable prefix for local variables to be consistent with the rest of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, done in the latest force push

@bretello bretello force-pushed the preview-fzf branch 3 times, most recently from 10c1594 to 9cdd54b Compare November 29, 2025 18:49
@bretello
Copy link
Contributor Author

bretello commented Nov 29, 2025

Thanks for the review @w0rp. I finally had some time to get back to this. In the last force push:

  • moved the fzf support function to autoload/ale/fzf.vim
  • minor cleanups (linting fixes mostly)
  • cleaned up tests so that they don't fail

The only thing that's missing is unit tests, which I'm not really sure how to handle at this point. I've been using this for the past few months and I think it works ok, maybe we can add it for now and then iterate some more.

edit:

I also added docs and squashed commits

@bretello bretello marked this pull request as ready for review November 29, 2025 18:51
@bretello bretello changed the title WIP: ALEFindReferences: add -fzf flag to show output in fzf ALEFindReferences: add -fzf flag to show output in fzf Dec 4, 2025
@bretello bretello force-pushed the preview-fzf branch 2 times, most recently from 67038d4 to b649b6c Compare December 6, 2025 17:29
Allows using -fzf to show previews using fzf.vim. Includes:

- add support for opening in bufers, splits, tabs and for adding matches quickfix
- add support for -relative
- add fzf preview `--highlight-line` option
- add fzf.vim autoload module
Copy link
Contributor

@hsanson hsanson left a comment

Choose a reason for hiding this comment

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

Thanks, looks like a very useful feature.

@hsanson hsanson merged commit dd6e6f1 into dense-analysis:master Dec 21, 2025
8 checks passed
@bretello bretello deleted the preview-fzf branch December 21, 2025 19:37
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.

3 participants