Skip to content

Commit

Permalink
add fzfquickfix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyangze committed Dec 22, 2022
1 parent 352d25a commit 15137c3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 30 deletions.
62 changes: 59 additions & 3 deletions layers/common/tool-fzf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ command! -bang -nargs=* FzfWPHookDef
\ <bang>0
\ )




function! s:fzfdir(e)
let l:filename = trim(a:e, './')
if exists(":NERDTreeFind")
Expand Down Expand Up @@ -306,3 +303,62 @@ function! s:fzf_neighbouring_files()
\ 'window': { 'width': 0.8, 'height': 0.6, 'border': 'rounded' } }))
endfunction
command! FZFNeigh call s:fzf_neighbouring_files()

function! FzfGetQuickFixList(cmdstr)
let l:quickhistory = trim(execute(a:cmdstr))
let l:newQuickfixHistoryList = []
if l:quickhistory == "No entries"
return l:newQuickfixHistoryList
endif
let l:quickHistoryList = split(l:quickhistory, "\n")
if len(l:quickHistoryList) == 0 || l:quickhistory == "No entries"
echomsg "no quick fix list"
return l:newQuickfixHistoryList
endif

let l:quickHistoryList = reverse(l:quickHistoryList)

for item in l:quickHistoryList
let itemInfo = split(item, ";")
let numsList = split(itemInfo[0], " ")
let nums = 0
for subItem in numsList
if subItem == "of"
break
endif
let nums = subItem
endfor
if nums != ""
call add(l:newQuickfixHistoryList, nums . ':' . itemInfo[1])
endif
endfor

return l:newQuickfixHistoryList
endfunction

function! s:FzfQuickfixOpen(line)
if a:line == ""
return
endif
let lineInfo = split(a:line, ":")
let nums = lineInfo[0]
exec nums . "chi"
copen
endfunction
function! s:FzfQuickfixLocalOpen(line)
if a:line == ""
return
endif
let lineInfo = split(a:line, ":")
let nums = lineInfo[0]
exec nums . "lhi"
lopen
endfunction



command! -bang FzfQuiclfixHistory
\ call fzf#run(fzf#wrap('fzfquickfix', {'source': FzfGetQuickFixList('chi'), 'sink': function('s:FzfQuickfixOpen')}, 0))

command! -bang FzfQuiclfixLocalHistory
\ call fzf#run(fzf#wrap('fzfquickfix', {'source': FzfGetQuickFixList('lhi'), 'sink': function('s:FzfQuickfixLocalOpen')}, 0))
25 changes: 0 additions & 25 deletions layers/common/tool-quickfix.vim

This file was deleted.

4 changes: 2 additions & 2 deletions layers/user/keymap.vim
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ let g:which_key_map.q = {
\'q': ['cclose', 'Quit'],
\'l': ['cl', 'List'],
\'o': ['copen', 'Open'],
\'h': [':Chistory', 'History'],
\'H': [':Chistory', 'Location History'],
\'h': ['FzfQuiclfixHistory', 'History'],
\'H': ['FzfQuickfixLocalOpen', 'Location History'],
\}

let g:which_key_map.c = { 'name': 'Comment'}
Expand Down

0 comments on commit 15137c3

Please sign in to comment.