" these mappings. That means we can simply 'invoke' the preferred
" completion method and then C-n and C-p will behave as they should while
" the menu is present
ino <C-n> <C-X><C-U>
ino <C-p> <C-X><C-U>
fun! LBDBCompleteFn(findstart, base)
if a:findstart
" locate the start of the word
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] =~ '[^:,]'
let start -= 1
endwhile
while start < col('.') && line[start] =~ '[:, ]'
let start += 1
endwhile
return start
else
let res = []
let query = substitute(a:base, '"', '', 'g')
let query = substitute(query, '\s*<.*>\s*', '', 'g')
for m in LbdbQuery(query)
call add(res, printf('"%s" <%s>', escape(m[0], '"'), m[1]))
endfor
return res
endif
endfun
set completefunc=LBDBCompleteFnOn Thu, March 22, 2012 10:42, Jostein Gogstad wrote:
> I'm using Vim as my default text editor for writing e-mail. I have an
> external
> perl script that does LDAP-lookup and outputs a list of names matching the
> search query. Is it possible to present this list in Vim? Preferably in a
> dropdown like the one you get on keyword completion (default Ctrl+N).
>
> Ideal scenario:
> 1. Start writing Paul
> 2. Hit ^T (or something)
> 3. Vim executes perl script with the word under the cursor and displays
> the
> result in a keywordcompletion-style dropdown.
I use something similar. Basically, for looking up e-mail contacts,
I use The little Brother's Database lbdb¹ together with mutt and Vim.
Additionally Vim Script 1757² plus a custom complete script that I
found online somewhere, but don't find it anymore (so I attach it
here)
The lbdb comes with a little script lbdbq that can query different
sources, e.g. mutt alias file, abook file, OS X adressbook, ldap
server, etc. to query for contacts so in theory it should be able to
query your own ldap server, but if that does not work
for you, it should at least give you an starter how to write your own
script.
¹)http://www.spinnaker.de/lbdb/
²)http://www.vim.org/scripts/script.php?script_id=1757
regards,
Christian
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment