comparison vendor/vim-packs/ctrlp.vim/autoload/ctrlp/quickfix.vim @ 707:4576f1471f53

[update-vendor, vim] add ctrlp
author nanaya <me@nanaya.net>
date Sun, 18 Dec 2022 22:27:56 +0900
parents
children
comparison
equal deleted inserted replaced
706:4b30df382167 707:4576f1471f53
1 " =============================================================================
2 " File: autoload/ctrlp/quickfix.vim
3 " Description: Quickfix extension
4 " Author: Kien Nguyen <github.com/kien>
5 " =============================================================================
6
7 " Init {{{1
8 if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
9 fini
10 en
11 let g:loaded_ctrlp_quickfix = 1
12
13 cal add(g:ctrlp_ext_vars, {
14 \ 'init': 'ctrlp#quickfix#init()',
15 \ 'accept': 'ctrlp#quickfix#accept',
16 \ 'lname': 'quickfix',
17 \ 'sname': 'qfx',
18 \ 'type': 'line',
19 \ 'sort': 0,
20 \ 'nolim': 1,
21 \ })
22
23 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
24
25 fu! s:lineout(dict)
26 retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
27 \ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
28 endf
29 " Utilities {{{1
30 fu! s:syntax()
31 if !ctrlp#nosy()
32 cal ctrlp#hicheck('CtrlPqfLineCol', 'Search')
33 sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
34 en
35 endf
36 " Public {{{1
37 fu! ctrlp#quickfix#init()
38 cal s:syntax()
39 retu map(getqflist(), 's:lineout(v:val)')
40 endf
41
42 fu! ctrlp#quickfix#accept(mode, str)
43 let vals = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
44 if vals == [] || vals[1] == '' | retu | en
45 cal ctrlp#acceptfile(a:mode, vals[1])
46 let cur_pos = getpos('.')[1:2]
47 if cur_pos != [1, 1] && cur_pos != map(vals[2:3], 'str2nr(v:val)')
48 mark '
49 en
50 cal cursor(vals[2], vals[3])
51 sil! norm! zvzz
52 endf
53
54 fu! ctrlp#quickfix#id()
55 retu s:id
56 endf
57 "}}}
58
59 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2