Will be its own plugin
bd37a61ce5ee106d3db68c7c2f755277195ee0a3
1 parent
e5ee92a4
.vimrc
+0 -31
| 157 | 157 | ||
| 158 | 158 | if has("nvim") |
|
| 159 | 159 | tnoremap <Esc> <C-\><C-n> |
|
| 160 | 160 | endif |
|
| 161 | 161 | ||
| 162 | - | command! FuzzyOpen call s:fuzzy() |
|
| 163 | - | function! s:fuzzy() abort |
|
| 164 | - | let lines = 12 |
|
| 165 | - | let tmp = tempname() |
|
| 166 | - | let command = "ag -g '' | fzy -l " . lines . " > " . tmp |
|
| 167 | - | let opts = { 'tmp': tmp } |
|
| 168 | - | ||
| 169 | - | function! opts.on_exit(id, code) abort |
|
| 170 | - | bdelete! |
|
| 171 | - | if a:code == 0 |
|
| 172 | - | if filereadable(self.tmp) |
|
| 173 | - | let result = readfile(self.tmp) |
|
| 174 | - | if !empty(result) |
|
| 175 | - | execute 'edit' fnameescape(join(result)) |
|
| 176 | - | endif |
|
| 177 | - | endif |
|
| 178 | - | endif |
|
| 179 | - | endfunction |
|
| 180 | - | ||
| 181 | - | below new |
|
| 182 | - | execute 'resize' lines + 1 |
|
| 183 | - | ||
| 184 | - | if bufnr('FuzzyOpen') > 0 |
|
| 185 | - | execute 'buffer' bufnr('FuzzyOpen') |
|
| 186 | - | else |
|
| 187 | - | call termopen(command, opts) |
|
| 188 | - | file FuzzyOpen |
|
| 189 | - | endif |
|
| 190 | - | startinsert |
|
| 191 | - | endfunction |
|
| 192 | - | ||
| 193 | 162 | if executable('ag') |
|
| 194 | 163 | let g:ackprg = 'ag --vimgrep' |
|
| 195 | 164 | endif |
|
| 196 | 165 | ||
| 197 | 166 | " Syntax coloring |