--- /dev/null
+Same as vim's license
--- /dev/null
+# vim-password-store
+Vim niceties for password store ("pass" the standard Unix Password Manager)
+
+This is a fairly straight-forward fork of Tom Ryder's password-store plugin,
+included in the contrib folder for pass and at Tom's cgit store:
+https://git.zx2c4.com/password-store/
+
+I've added some niceties based around a fuller filetype implementation,
+in particular
+
+* unset spell
+* add simple syntax highlighting
+
+I've added some simple shoulder surfing protection via syntax highlighting.
+When loading a pass file for editing, the first line will be obscured. It is
+editable when the cursor is in place, but will be obscured while editing other
+fields.
+
+There are two commands to facilitate hiding and concealing
+
+*:Reveal*
+
+*:Conceal*
+
+These do what you might expect, reset the syntax highlighting of the password
+from obscured to cleared.
+
+There is also integration with ``pwgen`` the same utility called by
+password-store to generate passwords. By default this is mapped to vim's
+increment and decrement operators ``<C-X>`` and ``<C-A>`` but the mapping is
+available by a plug mapping ``<Plug>password_rotate``
--- /dev/null
+" 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')
+ let l:result = systemlist('pwgen -N1 ' . password_store#setting('pw_length') )
+ return l:result[0]
+ endif
+endfunction
+
+function! password_store#replace() abort
+ execute 's/\<.*\>/' . password_store#generate() . '/'
+endfunction
+
+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
+
+let &cpoptions = s:save_cpo
--- /dev/null
+*vim-password-store* Niceties for editing password-store files
+
+===============================================================================
+CONTENTS *password-store-contents*
+
+ 1. Intro ........................................... |password-store-intro|
+ 2. Requirements ............................. |password-store-requirements|
+ 3. Usage ........................................... |password-store-usage|
+ 4. Configuration .................................. |password-store-config|
+ 5. Licence ....................................... |password-store-licence|
+ 6. Credits ....................................... |password-store-credits|
+===============================================================================
+1. Intro *password-store-intro*
+
+Password store is a nice command line password manager, well suited to
+vim's style. Tom Ryder has written a plugin to unset the standard
+password security leakages, backup files, info files etc. This works
+well, but doesn't provide hooks for extending. I wanted to add a few
+simple enhancements, including unsetting spelling (no password should be
+spell checked :-) and some simple syntax highlighting.
+
+2. Requirements *password-store-requirements*
+
+A plugin manager (not required but the plugin is written to expect
+this) and password-store https://www.passwordstore.org/ .
+
+3. Usage *password-store-usage*
+
+The plugin automatically loads when it sees the appropriate file paths
+for password-store. This is Tom Ryders
+
+There are two functions:
+>
+ :Conceal
+ :Reveal
+<
+That apply syntax highlighting to obscure and un-obscure the password.
+By default the pass file loads in obscured mode, however when the cursor is on
+the word it should readable and editable. This offers minor "shoulder surfing"
+protection, facilitating editing of metadata, such as adding URLs etc.
+
+There's minor feedback for short passwords, with Error highlighting for
+passwords 6 or less characters long.
+
+Password store also adds password generation support via pwgen. Since
+password-store already leverages pwgen, this is a fairly safe assumption.
+There is a Plug mapping *<Plug>rotate_password*
+by default this is mapped to <C-X> and <C-A> but can be overridden via setting
+an alternate plug mapping
+>
+ nnoremap >M-a> <Plug>rotate_password
+<
+The mapped sequence will generate a random password. As neither decrement nor
+increment mean anything in this context, buth are mapped to the same plug.
+The default length of the password is 10 character, but
+modifiable by configuration This is also available via the function call(s)
+>
+ password_store#replace()
+<
+4. Configuration *password-store-config*
+
+Configuration is done through a global dictionary *g:password_store_settings*
+Initialize the dictionary and add settings as needed
+>
+ let g:password_store_settings = {}
+
+Syntax obfustaction is enabled by default. To disable it:
+>
+ let g:password_store_settings.enable_syntax = 'false"
+
+
+Auto "increment" password length is 12 characters. To change it
+>
+ let g:password_store_settings.pw_length = 20
+<
+4. Licence *password-store-licence*
+
+This plugin is licensed under the same terms as vim itself (see
+|license| )
+
+5. Credits *password-store-credits*
+
+Tom Ryder
+https://git.zx2c4.com/password-store/
+
+vim:ft=help
--- /dev/null
+" detect password-store files
+if exists('did_pass') || &compatible || version < 700
+ finish
+endif
+let g:did_pass = 'did_pass'
+let s:save_cpo = &cpoptions
+set compatible&vim
+
+" this is straight from Tom Ryders plugin
+
+autocmd VimEnter
+ \ /dev/shm/pass.?*/?*.txt
+ \,/dev/shm/gopass-edit*/secret
+ \,$TMPDIR/pass.?*/?*.txt
+ \,/tmp/pass.?*/?*.txt
+ \ setlocal filetype=pass |
+ \ if password_store#setting('enable_syntax') ==# 'true' | setlocal syntax=pass.obfuscated | endif
+
+" Cleanup at end
+let &cpoptions = s:save_cpo
--- /dev/null
+if exists('did_pass_ftplugin') || &compatible || v:version < 700
+ finish
+endif
+let g:did_pass = 'did_pass_ftplugin'
+let s:save_cpo = &cpoptions
+set compatible&vim
+
+nmap <buffer> <Plug>rotate_password :call password_store#replace()<Cr>
+if ! hasmapto( '\<Plug>rotate_password', 'n')
+ nmap <C-X> <Plug>rotate_password
+endif
+
+setlocal nospell
+
+
+" Check whether we should set redacting options or not
+function! s:CheckArgsRedact()
+
+ " Ensure there's one argument and it's the matched file
+ if argc() != 1 || fnamemodify(argv(0), ':p') !=# expand('<afile>:p')
+ return
+ endif
+
+ " Disable all the leaky options globally
+ set nobackup
+ set nowritebackup
+ set noswapfile
+ set viminfo=
+ if has('persistent_undo')
+ set noundofile
+ endif
+
+ " Tell the user what we're doing so they know this worked, via a message and
+ " a global variable they can check
+ echomsg 'Editing password file--disabled leaky options!'
+ let g:redact_pass_redacted = 1
+
+endfunction
+
+call s:CheckArgsRedact()
+
+function! s:reveal_pass() abort
+ highlight! link password_store_password Comment
+endfunction
+command! Reveal call <SID>reveal_pass()
+
+function! s:conceal_pass() abort
+ highlight! password_store_password guifg=DarkGray guibg=DarkGray ctermfg=8 ctermbg=8
+endfunction
+command! Conceal call <SID>conceal_pass()
+normal! GG
+
+augroup password_settings_late_load
+ autocmd!
+ autocmd FileReadPost if &filetype == 'pass' | echom 'autocmd triggered' | let b:load_pass_syntax = 1 | source 'syntax/pass.vim' | endif
+augroup end
+" Cleanup at end
+let &cpoptions = s:save_cpo
--- /dev/null
+if exists('b:current_syntax') | finish| endif
+
+setlocal cursorline
+
+" set redacted colors from colorscheme
+let s:error_highlight_str = execute( 'highlight Error' )
+let s:error_fg = matchstr(s:error_highlight_str, 'guifg=\zs\S*')
+
+let s:comment_highlight_str = execute( 'highlight Comment' )
+let s:comment_fg = matchstr(s:comment_highlight_str, 'guifg=\zs\S*')
+
+execute 'highlight password_store_password ' .
+ \ ' guibg=' . s:comment_fg .
+ \ ' guifg=' . s:comment_fg .
+ \ ' ctermfg=1 ctermbg=1'
+
+execute 'highlight password_store_password_short ' .
+ \ ' guibg=' . s:error_fg .
+ \ ' guifg=' . s:error_fg .
+ \ ' ctermfg=1 ctermbg=1'
+
--- /dev/null
+if exists('b:current_syntax') | finish| endif
+
+" first line (by convention always a single pasword)
+syntax match password_store_password /\%1l.*/
+highlight link password_store_password Comment
+
+" highlight short passwords
+syntax match password_store_password_short /\%1l.\{,6\}$/
+highlight link password_store_password_short Error
+
+" colon field value is the suggested path for additional information
+syntax match password_store_header '\v^[^:]+:'
+highlight link password_store_header PreProc
+
+
--- /dev/null
+Given pass (short password):
+ pass
+
+Execute (test short password syntax):
+ AssertEqual SyntaxAt(2), 'password_store_password_short'
+
+Given pass (longer password):
+ passwordlonger
+
+Execute (test longer password syntax):
+ AssertEqual SyntaxAt(2), 'password_store_password'
+
+Given pass (another password):
+ passwordlonger
+
+Before (disable syntax):
+ let g:password_store_settings = {}
+ let g:password_store_settings.enable_syntax = 'false'
+
+Execute (test disable syntax ):
+ AssertEqual &filetype, 'pass'
+
+Execute (test increment password length):
+ AssertEqual len( password_store#generate()), 12
+
+Execute (test new generates do not match):
+ AssertNotEqual password_store#generate(), password_store#generate()
+
+Given text (test ftdetect):
+ passwordtesting
+
+Before (mimic settings):
+ let g:password_store_settings = {}
+ let g:password_store_settings.enable_syntax = 'false'
+ let g:password_store_settings.pw_length = '16'
+
+Execute (test ftdetect trigger):
+ set filetype=pass
+ AssertEqual password_store#setting('enable_syntax'), 'false'
+ AssertEqual len( password_store#generate() ), 16
+
+