]> git.madduck.net Git - etc/vim.git/blob - autoload/password_store.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Add password testing
[etc/vim.git] / autoload / password_store.vim
1 " setup known state
2 if exists('did_password_store') 
3       "  || &compatible 
4       "  || version < 700}
5     finish
6 endif
7 let g:did_password_store = '1'
8 let s:save_cpo = &cpoptions
9 set compatible&vim
10 "echo 'main code'}}
11 " Return vim to users choice
12 function! password_store#generate() abort
13     if executable('pwgen')
14         let l:result =  systemlist('pwgen -N1 ' . password_store#setting('pw_length') )
15         return l:result[0]
16     endif
17 endfunction
18
19 function! password_store#replace() abort
20     execute 's/\<.*\>/' . password_store#generate() . '/'
21 endfunction
22
23 let s:default_settings = {
24             \    'pw_length' : '12',
25             \    'enable_syntax' : 'true',
26             \ }
27
28 function! password_store#setting(key)
29     if exists('g:password_store_settings') && has_key(g:password_store_settings, a:key)
30         echo 'found key'
31         return g:password_store_settings[a:key]
32     else
33         return s:default_settings[a:key]
34     endif
35 endfunction
36
37 let &cpoptions = s:save_cpo