annotate vim/autoload/ludo.vim @ 483:1a54ffbc3b15

Remove goyo stuff, add quicklist toggle.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 24 Sep 2020 23:07:10 -0700
parents b7682004288d
children 232351531855
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
426
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
1 let g:ludo_trace = 0
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
2
435
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
3 " Get the platform we're running on.
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
4 if has("win32") || has("win64") || has("dos32")
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
5 let s:vim_platform = "windows"
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
6 let s:path_sep = "\\"
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
7 elseif has("mac")
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
8 let s:vim_platform = "mac"
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
9 let s:path_sep = '/'
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
10 else
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
11 let s:vim_platform = "unix"
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
12 let s:path_sep = '/'
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
13 endif
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
14 function! ludo#platform() abort
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
15 return s:vim_platform
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
16 endfunction
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
17
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
18 " Get our vim directory.
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
19 let s:vim_home = expand("<sfile>:h:h")
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
20
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
21 " Get local path.
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
22 function! ludo#localpath(...) abort
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
23 return s:vim_home.s:path_sep.join(a:000, s:path_sep)
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
24 endfunction
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
25
426
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
26 " Debug logging.
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
27 function! ludo#trace(msg) abort
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
28 if g:ludo_trace
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
29 echom a:msg
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
30 endif
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
31 endfunction
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
32
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
33 " Warning message.
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
34 function! ludo#warn(msg) abort
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
35 echohl WarningMsg
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
36 echomsg "ludo: Warning: ".a:msg
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
37 echohl None
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
38 endfunction
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
39
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
40 " Error message.
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
41 function! ludo#error(msg) abort
430
71a080d4d83c Vim stuff: Goyo writing mode, Ack with Ag.
Ludovic Chabant <ludovic@chabant.com>
parents: 426
diff changeset
42 let v:errmsg = "ludo: Error: ".a:msg
426
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
43 echohl ErrorMsg
430
71a080d4d83c Vim stuff: Goyo writing mode, Ack with Ag.
Ludovic Chabant <ludovic@chabant.com>
parents: 426
diff changeset
44 echom v:errmsg
426
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
45 echohl None
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
46 endfunction
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
47
424
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
48
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
49 " Loads `pathogenrc` files in each bundle directory and, if found,
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
50 " builds an exclude list based on the glob patterns found in them.
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
51 "
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
52 function! ludo#setup_pathogen(bundle_dirs) abort
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
53 for bundle_dir in a:bundle_dirs
426
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
54 let l:rcfile = bundle_dir.'.pathogenrc'
424
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
55 if !filereadable(l:rcfile)
426
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
56 call ludo#trace("No bundle configuration file: ".l:rcfile)
424
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
57 continue
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
58 endif
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
59
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
60 let l:included = []
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
61 let l:excluded = []
426
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
62 call ludo#trace("Reading bundle configuration file: ".l:rcfile)
424
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
63 let l:rclines = readfile(l:rcfile)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
64 for line in l:rclines
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
65 if line[0] == '#'
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
66 continue
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
67 endif
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
68
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
69 if line[0] == '-'
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
70 let l:excls = glob(bundle_dir.'/'.line[1:], 1, 1)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
71 for excl in l:excls
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
72 let l:idx = index(l:included, excl)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
73 if l:idx >= 0
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
74 call remove(l:included, l:idx)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
75 endif
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
76 call add(l:excluded, excl)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
77 endfor
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
78 else
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
79 let l:incls = glob(bundle_dir.'/'.line, 1, 1)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
80 for incl in l:incls
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
81 let l:idx = index(l:excluded, incl)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
82 if l:idx >= 0
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
83 call remove(l:excluded, l:idx)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
84 endif
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
85 call add(l:included, incl)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
86 endfor
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
87 endif
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
88 endfor
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
89
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
90 for excl in l:excluded
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
91 if isdirectory(excl)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
92 let l:excl_name = fnamemodify(excl, ':t')
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
93 call add(g:pathogen_disabled, l:excl_name)
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
94 endif
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
95 endfor
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
96 endfor
426
67f14a8c2304 Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents: 424
diff changeset
97 call ludo#trace("Exclude list: ".join(g:pathogen_disabled, ', '))
424
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
98 endfunction
d8086f81b9c8 Pathogen config files.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
99
483
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
100 " Toggle quicklist window
435
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
101 "
483
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
102 function! ludo#toggle_quicklist() abort
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
103 let l:qlwin = -1
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
104 let l:wincount = winnr('$')
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
105 for l:winidx in range(1, l:wincount)
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
106 let l:winbuftype = getwinvar(l:winidx, '&buftype', '')
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
107 if l:winbuftype == 'quickfix'
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
108 let l:qlwin = l:winidx
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
109 break
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
110 endif
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
111 endfor
430
71a080d4d83c Vim stuff: Goyo writing mode, Ack with Ag.
Ludovic Chabant <ludovic@chabant.com>
parents: 426
diff changeset
112
483
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
113 if l:qlwin < 0
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
114 copen
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
115 else
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
116 cclose
1a54ffbc3b15 Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents: 435
diff changeset
117 endif
430
71a080d4d83c Vim stuff: Goyo writing mode, Ack with Ag.
Ludovic Chabant <ludovic@chabant.com>
parents: 426
diff changeset
118 endfunction
71a080d4d83c Vim stuff: Goyo writing mode, Ack with Ag.
Ludovic Chabant <ludovic@chabant.com>
parents: 426
diff changeset
119
435
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
120 " Better tags browser using FZF
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
121 "
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
122 function! ludo#run_fzf_tags(args, bang) abort
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
123 let l:tag_files = tagfiles()
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
124 let l:tag_lister =
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
125 \'python '.
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
126 \ludo#localpath('scripts', 'list_tags.py').' -a 24 '.
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
127 \join(map(l:tag_files, "shellescape(v:val)"))
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
128 let options = {
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
129 \'source': l:tag_lister,
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
130 \'sink': function('s:tags_sink'),
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
131 \'options': '--algo=v1 --tiebreak=begin --prompt "Tags> "'
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
132 \}
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
133 return fzf#run(fzf#wrap('tags', options, a:bang))
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
134 endfunction
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
135
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
136 function! s:tags_sink(line) abort
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
137 let l:tokens = matchlist(
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
138 \a:line,
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
139 \'\v^(\S+)\s+([^\t]+)\t([^\t]{-1,})(;")?\t[a-z]+\tline\:([0-9]+)')
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
140 if len(l:tokens) < 5
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
141 call fb#warn("Couldn't parse line '".a:line."', got '".string(l:tokens)."'")
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
142 return
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
143 endif
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
144
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
145 let [l:tag, l:source_path, l:regex, l:line] =
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
146 \[l:tokens[1], tolower(l:tokens[2]), l:tokens[3], l:tokens[4]]
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
147 let l:cur_path = fnamemodify(bufname('%'), ':p')
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
148 let l:candidates = taglist(l:tag, l:cur_path)
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
149
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
150 if len(l:candidates) == 0
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
151 call fb#warn("No candidates found for '".l:tag."'")
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
152 return
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
153 endif
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
154
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
155 if len(l:candidates) == 1
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
156 execute ':tjump '.l:tag
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
157 return
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
158 endif
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
159
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
160 let l:tagidx = 0
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
161 for cndd in l:candidates
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
162 let l:tagidx += 1
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
163 if tolower(cndd['filename']) != l:source_path
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
164 continue
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
165 endif
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
166 if cndd['cmd'] != l:regex
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
167 continue
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
168 endif
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
169 break
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
170 endfor
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
171 execute ':'.string(l:tagidx).'tag '.l:tag
b7682004288d Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents: 430
diff changeset
172 endfunction