Skip to content

Loading…

[gpicker.vim] Allow to pick "mlocate.db" file from current working directory #9

Closed
wants to merge 1 commit into from

2 participants

@avsej
Collaborator

Hi

This patch does SUBJ and also allows to generated aforementioned file

Thanks

@alk alk closed this
@alk
Owner

I've added you to list of "collaborators" on alk/github. So hopefully you'll be able to commit this things yourself.

@avsej
Collaborator

Thanks

@alk
Owner

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

Collaborator

Yes, it would be nice to have it there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 15, 2012
  1. @avsej
Showing with 18 additions and 10 deletions.
  1. +18 −10 gpicker.vim
View
28 gpicker.vim
@@ -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))
Something went wrong with that request. Please try again.