]> git.madduck.net Git - etc/vim.git/blob - ftplugin/pass.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:

66b91c7c5f43eb177195e27a9196cf03bee78e2a
[etc/vim.git] / ftplugin / pass.vim
1 if exists('did_pass_ftplugin') || &compatible  || v:version < 700
2     finish
3 endif
4 let g:did_pass = 'did_pass_ftplugin'
5 let s:save_cpo = &cpoptions
6 set compatible&vim
7
8
9 let s:default_settings = {
10             \    'pw_length' : '12',
11             \    'enable_syntax' : 'true',
12             \ }
13
14 if ! exists('g:password_store_settings')
15     let g:password_store_settings = {}
16 endif
17
18 for s:setting in keys(s:default_settings)
19     if ! has_key( g:password_store_settings, s:setting )
20         let g:password_store_settings[s:setting] = s:default_settings[s:setting]
21     endif
22 endfor
23
24 if ! exists('g:password_store_pw_length')
25     let g:password_store_pw_length = 12
26 endif
27
28 nmap <buffer> <Plug>rotate_password :call password_store#replace()<Cr>
29 if ! hasmapto( '\<Plug>rotate_password', 'n')
30     nmap <C-X> <Plug>rotate_password
31 endif
32
33 setlocal nospell
34
35
36 " Check whether we should set redacting options or not
37 function! s:CheckArgsRedact()
38
39   " Ensure there's one argument and it's the matched file
40   if argc() != 1 || fnamemodify(argv(0), ':p') !=# expand('<afile>:p')
41     return
42   endif
43
44   " Disable all the leaky options globally
45   set nobackup
46   set nowritebackup
47   set noswapfile
48   set viminfo=
49   if has('persistent_undo')
50     set noundofile
51   endif
52
53   " Tell the user what we're doing so they know this worked, via a message and
54   " a global variable they can check
55   echomsg 'Editing password file--disabled leaky options!'
56   let g:redact_pass_redacted = 1
57
58 endfunction
59
60 call s:CheckArgsRedact()
61
62 function! s:reveal_pass() abort
63     highlight! link password_store_password Comment
64 endfunction
65 command! Reveal call <SID>reveal_pass()
66
67 function! s:conceal_pass() abort
68     highlight! password_store_password guifg=DarkGray guibg=DarkGray ctermfg=8 ctermbg=8
69 endfunction
70 command! Conceal call <SID>conceal_pass()
71 normal! GG
72
73 " Cleanup at end
74 let &cpoptions = s:save_cpo