X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/d6c1a4935fbd3f1f1a37f442693b84b78bdc8575..3e3c8f18c7e13b80a0657d48c3c4fa8f55d9eb68:/autoload/password_store.vim?ds=sidebyside diff --git a/autoload/password_store.vim b/autoload/password_store.vim index 9e3c5b6c..5ac486ed 100644 --- a/autoload/password_store.vim +++ b/autoload/password_store.vim @@ -1,17 +1,7 @@ -" setup known state -if exists('did_password_store') - " || &compatible - " || version < 700} - finish -endif -let g:did_password_store = '1' -let s:save_cpo = &cpoptions -set compatible&vim -"echo 'main code'}} -" Return vim to users choice function! password_store#generate() abort if executable('pwgen') - return systemlist('pwgen -N1 ' . g:password_store_settings.pw_length )[0] + let l:result = systemlist('pwgen -N1 ' . password_store#setting('pw_length') ) + return l:result[0] endif endfunction @@ -19,4 +9,21 @@ function! password_store#replace() abort execute 's/\<.*\>/' . password_store#generate() . '/' endfunction -let &cpoptions = s:save_cpo +let s:default_settings = { + \ 'pw_length' : '12', + \ 'enable_syntax' : 'true', + \ } + +function! password_store#setting(key) + if exists('g:password_store_settings') && has_key(g:password_store_settings, a:key) + return g:password_store_settings[a:key] + else + return s:default_settings[a:key] + endif +endfunction + +function! password_store#get_highight(group, key) abort + let l:hl_line = execute( 'highlight ' . a:group) + let l:key = matchstr(l:hl_line, a:key . '=\zs\S*') + return l:key +endfunction