Skip to content

Instantly share code, notes, and snippets.

@chemzqm
Created December 19, 2015 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemzqm/3e5aae0915107734069f to your computer and use it in GitHub Desktop.
Save chemzqm/3e5aae0915107734069f to your computer and use it in GitHub Desktop.
Unite quickfix
scriptencoding utf-8
function! unite#sources#quickfix#define()
return s:source
endfunction
let s:source = {
\ "name" : "quickfix",
\ "description" : "output quickfix",
\ "syntax" : "uniteSource__Quickfix",
\ "hooks" : {},
\}
" "converters" : "converter_quickfix_default"
function! s:qflist_to_unite(val)
let bufnr = a:val.bufnr
let fname = bufnr == 0 ? "" : bufname(bufnr)
let line = bufnr == 0 ? 0 : a:val.lnum
let col = bufnr == 0 ? 0 : a:val.col
let word = fname . '|' . line . ' col ' . col . '| ' . a:val.text
return {
\ "word": word,
\ "kind": a:val.valid ? ["common", "jump_list"] : ["common"],
\ "action__line" : line,
\ "action__col" : col,
\ "action__path" : fname,
\ }
endfunction
function! s:source.gather_candidates(args, context)
let qfolder = empty(a:args) ? 0 : a:args[0]
if qfolder == 0
return map(getqflist(), "s:qflist_to_unite(v:val)")
else
try
execute "colder" qfolder
return map(getqflist(), "s:qflist_to_unite(v:val)")
finally
execute "cnewer" qfolder
endtry
endif
endfunction
function! s:source.hooks.on_syntax(args, context)
syntax case ignore
syntax match uniteSource__QuickfixHeader /^.*$/
\ containedin=uniteSource__Quickfix
syntax match uniteSource__QuickfixName /\v^[^|]+/ contained
\ containedin=uniteSource__QuickfixHeader
syntax match uniteSource__QuickfixPosition /\v\|\zs.*\ze\|/ contained
\ containedin=uniteSource__QuickfixHeader
highlight default link uniteSource__QuickfixName Identifier
highlight default link uniteSource__QuickfixPosition LineNr
endfunction
function! s:source.hooks.on_close(args, context)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment