Mercurial > dotfiles
annotate vim/autoload/ludo.vim @ 515:6d5e2a583502 default tip
Remove onsub extension
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 10 May 2022 09:54:59 -0700 |
parents | 232351531855 |
children |
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 |
495
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
48 " Returns whether a plugin file exists in the runtime path. |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
49 function! ludo#has_plugin(plugname, ...) abort |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
50 let l:dirname = 'plugin/' |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
51 if a:0 && a:1 |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
52 let l:dirname = 'autoload/' |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
53 endif |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
54 return globpath(&runtimepath, l:dirname.a:plugname.'.vim') !=# '' |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
55 endfunction |
424 | 56 |
57 " Loads `pathogenrc` files in each bundle directory and, if found, | |
58 " builds an exclude list based on the glob patterns found in them. | |
59 " | |
60 function! ludo#setup_pathogen(bundle_dirs) abort | |
61 for bundle_dir in a:bundle_dirs | |
426
67f14a8c2304
Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
424
diff
changeset
|
62 let l:rcfile = bundle_dir.'.pathogenrc' |
424 | 63 if !filereadable(l:rcfile) |
426
67f14a8c2304
Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
424
diff
changeset
|
64 call ludo#trace("No bundle configuration file: ".l:rcfile) |
424 | 65 continue |
66 endif | |
67 | |
68 let l:included = [] | |
69 let l:excluded = [] | |
426
67f14a8c2304
Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
424
diff
changeset
|
70 call ludo#trace("Reading bundle configuration file: ".l:rcfile) |
424 | 71 let l:rclines = readfile(l:rcfile) |
72 for line in l:rclines | |
73 if line[0] == '#' | |
74 continue | |
75 endif | |
495
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
76 |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
77 if strcharpart(line, 0, 4) == "gui:" |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
78 if !has('gui') |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
79 call ludo#trace("Ignoring gui-only line: ".line) |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
80 continue |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
81 else |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
82 let line = line[4:] |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
83 endif |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
84 endif |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
85 if strcharpart(line, 0, 6) == "nogui:" |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
86 if has('gui') |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
87 call ludo#trace("Ignoring terminal-only line: ".line) |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
88 continue |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
89 else |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
90 let line = line[6:] |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
91 endif |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
92 endif |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
93 |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
94 let l:add_to = l:included |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
95 let l:remove_from = l:excluded |
424 | 96 if line[0] == '-' |
495
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
97 let l:add_to = l:excluded |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
98 let l:remove_from = l:included |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
99 let line = line[1:] |
424 | 100 endif |
495
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
101 |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
102 let l:incls = glob(bundle_dir.'/'.line, 1, 1) |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
103 for incl in l:incls |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
104 let l:idx = index(l:remove_from, incl) |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
105 if l:idx >= 0 |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
106 call remove(l:remove_from, l:idx) |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
107 endif |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
108 call add(l:add_to, incl) |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
109 endfor |
424 | 110 endfor |
111 | |
112 for excl in l:excluded | |
113 if isdirectory(excl) | |
114 let l:excl_name = fnamemodify(excl, ':t') | |
115 call add(g:pathogen_disabled, l:excl_name) | |
116 endif | |
117 endfor | |
118 endfor | |
426
67f14a8c2304
Improve Vim configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
424
diff
changeset
|
119 call ludo#trace("Exclude list: ".join(g:pathogen_disabled, ', ')) |
424 | 120 endfunction |
121 | |
483
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
122 " Toggle quicklist window |
435
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
123 " |
483
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
124 function! ludo#toggle_quicklist() abort |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
125 let l:qlwin = -1 |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
126 let l:wincount = winnr('$') |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
127 for l:winidx in range(1, l:wincount) |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
128 let l:winbuftype = getwinvar(l:winidx, '&buftype', '') |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
129 if l:winbuftype == 'quickfix' |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
130 let l:qlwin = l:winidx |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
131 break |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
132 endif |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
133 endfor |
430
71a080d4d83c
Vim stuff: Goyo writing mode, Ack with Ag.
Ludovic Chabant <ludovic@chabant.com>
parents:
426
diff
changeset
|
134 |
483
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
135 if l:qlwin < 0 |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
136 copen |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
137 else |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
138 cclose |
1a54ffbc3b15
Remove goyo stuff, add quicklist toggle.
Ludovic Chabant <ludovic@chabant.com>
parents:
435
diff
changeset
|
139 endif |
430
71a080d4d83c
Vim stuff: Goyo writing mode, Ack with Ag.
Ludovic Chabant <ludovic@chabant.com>
parents:
426
diff
changeset
|
140 endfunction |
71a080d4d83c
Vim stuff: Goyo writing mode, Ack with Ag.
Ludovic Chabant <ludovic@chabant.com>
parents:
426
diff
changeset
|
141 |
435
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
142 " Better tags browser using FZF |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
143 " |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
144 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
|
145 let l:tag_files = tagfiles() |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
146 let l:tag_lister = |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
147 \'python '. |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
148 \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
|
149 \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
|
150 let options = { |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
151 \'source': l:tag_lister, |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
152 \'sink': function('s:tags_sink'), |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
153 \'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
|
154 \} |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
155 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
|
156 endfunction |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
157 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
158 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
|
159 let l:tokens = matchlist( |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
160 \a:line, |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
161 \'\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
|
162 if len(l:tokens) < 5 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
163 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
|
164 return |
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 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
167 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
|
168 \[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
|
169 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
|
170 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
|
171 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
172 if len(l:candidates) == 0 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
173 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
|
174 return |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
175 endif |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
176 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
177 if len(l:candidates) == 1 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
178 execute ':tjump '.l:tag |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
179 return |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
180 endif |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
181 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
182 let l:tagidx = 0 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
183 for cndd in l:candidates |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
184 let l:tagidx += 1 |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
185 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
|
186 continue |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
187 endif |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
188 if cndd['cmd'] != l:regex |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
189 continue |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
190 endif |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
191 break |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
192 endfor |
b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
Ludovic Chabant <ludovic@chabant.com>
parents:
430
diff
changeset
|
193 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
|
194 endfunction |
495
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
195 |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
196 function! ludo#build_vs_or_ue() abort |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
197 if !empty(get(g:, 'unreal_branch_dir', '')) |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
198 UnrealBuild |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
199 elseif !empty(get(g: 'vimcrosoft_current_sln', '')) |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
200 VimcrosoftBuildActiveProject |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
201 else |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
202 call ludo#warn("No VS or UE project active") |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
203 endif |
232351531855
Vim config improvements
Ludovic Chabant <ludovic@chabant.com>
parents:
483
diff
changeset
|
204 endfunction |