Permalink
Browse files

Allow to pick mlocate.db from current directory

  • Loading branch information...
1 parent f2f686e commit 4af26847f9a80253deefab891fe8c0639fc114a9 @avsej committed May 15, 2012
Showing with 18 additions and 10 deletions.
  1. +18 −10 gpicker.vim
View
@@ -17,8 +17,8 @@
" Maintainers: Sergey Avseyev <sergey.avseyev@gmail.com>
" Contributors:
"
-" Release Date: May 12, 2012
-" Version: 0.4
+" Release Date: May 15, 2012
+" Version: 0.5
" Keywords: autocompletion
"
" Install: Copy file into ~/.vim/plugin directory or put in .vimrc
@@ -44,28 +44,36 @@
" ":GPickBuffer"
" ":GPickLocate"
"
+" To generate "mlocate.db" file in current directory you can
+" use ":GGenLocateDB" command.
+"
" Exit quickly when already loaded.
if exists("g:loaded_gpicker") || executable("gpicker") == 0
finish
endif
-if exists("g:gpicker_mlocate_db") == 0
- let g:gpicker_mlocate_db = "/var/lib/mlocate/mlocate.db"
-endif
-
-command GPickFile :call <SID>GPickFile("edit", resolve("."), "guess")
-command GPickFileDefault :call <SID>GPickFile("edit", resolve("."), "default")
+command GPickFile :call <SID>GPickFile("edit", "", "guess")
+command GPickFileDefault :call <SID>GPickFile("edit", "", "default")
command GPickFileFromHere :call <SID>GPickFile("edit", expand("%:h"), "default")
-command GPickLocate :call <SID>GPickFile("edit", g:gpicker_mlocate_db, "mlocate")
+command GPickLocate :call <SID>GPickFile("edit", "", "mlocate")
+command GGenLocateDB :call system("updatedb -U " . getcwd() . " -o mlocate.db")
function! s:GPickFile(cmd, path, type)
if empty(a:path)
- let l:path = "."
+ let l:path = getcwd()
else
let l:path = a:path
endif
" select file via gpicker
if a:type == "mlocate"
+ let l:path = getcwd() . '/mlocate.db'
+ if filereadable(l:path) == 0
+ if exists("g:gpicker_mlocate_db")
+ let l:path = g:gpicker_mlocate_db
+ else
+ let l:path = "/var/lib/mlocate/mlocate.db"
+ endif
+ endif
let l:filename = system('gpicker --eat-prefix="" -t mlocate ' . shellescape(l:path))
else
let l:filename = l:path . "/" . system('gpicker -t ' . a:type . " " . shellescape(l:path))

2 comments on commit 4af2684

alk commented on 4af2684 Jan 19, 2014

I think it's time for gicker 2.3. Do you want to me include this commit ?

Owner

Yes, it would be nice to have it there

Please sign in to comment.