Last active
July 15, 2022 20:00
-
-
Save davidmh/f35fba1f9cde176d1ec9b4919769653a to your computer and use it in GitHub Desktop.
Filter the quickfix list with fzf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:format_qf_line(line) | |
let parts = split(a:line, ':') | |
return { 'filename': parts[0] | |
\,'lnum': parts[1] | |
\,'col': parts[2] | |
\,'text': join(parts[3:], ':') | |
\ } | |
endfunction | |
function! s:qf_to_fzf(key, line) abort | |
let l:filepath = expand('#' . a:line.bufnr . ':p') | |
return l:filepath . ':' . a:line.lnum . ':' . a:line.col . ':' . a:line.text | |
endfunction | |
function! s:fzf_to_qf(filtered_list) abort | |
let list = map(a:filtered_list, 's:format_qf_line(v:val)') | |
if len(list) > 0 | |
call setqflist(list) | |
copen | |
endif | |
endfunction | |
command! FzfQF call fzf#run({ | |
\ 'source': map(getqflist(), function('<sid>qf_to_fzf')), | |
\ 'down': '20', | |
\ 'sink*': function('<sid>fzf_to_qf'), | |
\ 'options': '--reverse --multi --bind=ctrl-a:select-all,ctrl-d:deselect-all --prompt "quickfix> "', | |
\ }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment