]> git.madduck.net Git - etc/vim.git/commitdiff

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 '.vim/bundle/password-store/' from commit 'dc759ab32b05afeba5c103e2756ec4a2509fdaf6'
authormartin f. krafft <madduck@madduck.net>
Sun, 24 Feb 2019 21:32:48 +0000 (22:32 +0100)
committermartin f. krafft <madduck@madduck.net>
Sun, 24 Feb 2019 21:32:48 +0000 (22:32 +0100)
git-subtree-dir: .vim/bundle/password-store
git-subtree-mainline: 16f202c3b8ea1bb2625d3319bf42d8fc57f33814
git-subtree-split: dc759ab32b05afeba5c103e2756ec4a2509fdaf6

.vim/bundle/password-store/LICENSE [new file with mode: 0644]
.vim/bundle/password-store/README.md [new file with mode: 0644]
.vim/bundle/password-store/autoload/password_store.vim [new file with mode: 0644]
.vim/bundle/password-store/doc/vim-password-store.txt [new file with mode: 0644]
.vim/bundle/password-store/ftdetect/pass.vim [new file with mode: 0644]
.vim/bundle/password-store/ftplugin/pass.vim [new file with mode: 0644]
.vim/bundle/password-store/syntax/obfuscated.vim [new file with mode: 0644]
.vim/bundle/password-store/syntax/pass.vim [new file with mode: 0644]
.vim/bundle/password-store/t/settings.vader [new file with mode: 0644]

diff --git a/.vim/bundle/password-store/LICENSE b/.vim/bundle/password-store/LICENSE
new file mode 100644 (file)
index 0000000..b6e9c7f
--- /dev/null
@@ -0,0 +1 @@
+Same as vim's license
diff --git a/.vim/bundle/password-store/README.md b/.vim/bundle/password-store/README.md
new file mode 100644 (file)
index 0000000..28bf33b
--- /dev/null
@@ -0,0 +1,31 @@
+# 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``
diff --git a/.vim/bundle/password-store/autoload/password_store.vim b/.vim/bundle/password-store/autoload/password_store.vim
new file mode 100644 (file)
index 0000000..fac5202
--- /dev/null
@@ -0,0 +1,36 @@
+" 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
diff --git a/.vim/bundle/password-store/doc/vim-password-store.txt b/.vim/bundle/password-store/doc/vim-password-store.txt
new file mode 100644 (file)
index 0000000..1ffcf36
--- /dev/null
@@ -0,0 +1,86 @@
+*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
diff --git a/.vim/bundle/password-store/ftdetect/pass.vim b/.vim/bundle/password-store/ftdetect/pass.vim
new file mode 100644 (file)
index 0000000..0ce0f48
--- /dev/null
@@ -0,0 +1,20 @@
+" 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
diff --git a/.vim/bundle/password-store/ftplugin/pass.vim b/.vim/bundle/password-store/ftplugin/pass.vim
new file mode 100644 (file)
index 0000000..c6a2680
--- /dev/null
@@ -0,0 +1,58 @@
+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
diff --git a/.vim/bundle/password-store/syntax/obfuscated.vim b/.vim/bundle/password-store/syntax/obfuscated.vim
new file mode 100644 (file)
index 0000000..0a53ea8
--- /dev/null
@@ -0,0 +1,21 @@
+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'
+
diff --git a/.vim/bundle/password-store/syntax/pass.vim b/.vim/bundle/password-store/syntax/pass.vim
new file mode 100644 (file)
index 0000000..1645720
--- /dev/null
@@ -0,0 +1,15 @@
+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
+
+
diff --git a/.vim/bundle/password-store/t/settings.vader b/.vim/bundle/password-store/t/settings.vader
new file mode 100644 (file)
index 0000000..aab7688
--- /dev/null
@@ -0,0 +1,42 @@
+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
+
+