]> 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:

Squashed '.vim/bundle/password-store/' changes from dc759ab3..474a7dfc
authormartin f. krafft <madduck@madduck.net>
Tue, 8 Apr 2025 14:55:27 +0000 (16:55 +0200)
committermartin f. krafft <madduck@madduck.net>
Tue, 8 Apr 2025 14:55:27 +0000 (16:55 +0200)
474a7dfc cleanup: Remove unneeded autoload guard
e7bb4ab5 fix: fat-fingered cpoptions
33e96717 perf: remove uneeeded ftdetect guard
2aa305fa Adding a default CursorLone
fb41a021 Add a projectionist config
5e34e7aa Shuffling test files
6ed6635c Cleanup gunk in obfuscation
3ed78b66 Add empty test
b0df1566 Better support for cterm obfustaction
73599919 Remove stale, non-working syntax late loading
69938267 Fix Conceal & Reveal

git-subtree-dir: .vim/bundle/password-store
git-subtree-split: 474a7dfc1c49986ed92fa78925963080b673926a

.projections.json [new file with mode: 0644]
autoload/password_store.vim
ftdetect/pass.vim
ftplugin/pass.vim
syntax/obfuscated.vim
syntax/pass.vim
t/pass.vader [moved from t/settings.vader with 85% similarity]

diff --git a/.projections.json b/.projections.json
new file mode 100644 (file)
index 0000000..89596b8
--- /dev/null
@@ -0,0 +1,18 @@
+{
+    "t/*.vader" : {
+        "type"      : "test",
+        "alternate" : [ "autoload/{}.vim", "ftplugin/{}.vim" ]
+    },
+    "autoload/*.vim" : {
+        "type"      : "autoload",
+        "alternate" : "t/pass.vader"
+    },
+    "ftplugin/*.vim" : {
+        "type"      : "plugin",
+        "alternate" : "t/{}.vader"
+    },
+    ".scratch/*.vim" : {
+        "type"      : "scratch",
+        "alternate" : "{}"
+    }
+}
index fac5202e1fb657fc661fa3c9fa8fbdb5cfc28a9e..5ac486ede111d647de0bec9086edd353fbeca1a0 100644 (file)
@@ -1,14 +1,3 @@
-" 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') )
 function! password_store#generate() abort
     if executable('pwgen')
         let l:result =  systemlist('pwgen -N1 ' . password_store#setting('pw_length') )
@@ -33,4 +22,8 @@ function! password_store#setting(key)
     endif
 endfunction
 
     endif
 endfunction
 
-let &cpoptions = s:save_cpo
+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
index 0ce0f48a911255e4d41ab94e64a7c5fc2508f620..408c174e5751692884eee6b28da78cd4d02f059b 100644 (file)
@@ -1,13 +1,5 @@
-" 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
-
+" this is mostly from Tom Ryders plugin
+" with deleyed obfuscation syntax
 autocmd VimEnter
             \ /dev/shm/pass.?*/?*.txt
             \,/dev/shm/gopass-edit*/secret
 autocmd VimEnter
             \ /dev/shm/pass.?*/?*.txt
             \,/dev/shm/gopass-edit*/secret
@@ -15,6 +7,3 @@ autocmd VimEnter
             \,/tmp/pass.?*/?*.txt
             \ setlocal filetype=pass |
             \ if password_store#setting('enable_syntax') ==# 'true' | setlocal syntax=pass.obfuscated | endif
             \,/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
index c6a2680a8bdb36ae3bc40d0da9d6e8ef535d2a0b..5c8b41e38db7dfb8a10db532f6824612a8461449 100644 (file)
@@ -3,7 +3,7 @@ if exists('did_pass_ftplugin') || &compatible  || v:version < 700
 endif
 let g:did_pass = 'did_pass_ftplugin'
 let s:save_cpo = &cpoptions
 endif
 let g:did_pass = 'did_pass_ftplugin'
 let s:save_cpo = &cpoptions
-set compatible&vim
+set cpoptions&vim
 
 nmap <buffer> <Plug>rotate_password :call password_store#replace()<Cr>
 if ! hasmapto( '\<Plug>rotate_password', 'n')
 
 nmap <buffer> <Plug>rotate_password :call password_store#replace()<Cr>
 if ! hasmapto( '\<Plug>rotate_password', 'n')
@@ -40,19 +40,15 @@ endfunction
 call s:CheckArgsRedact()
 
 function! s:reveal_pass() abort
 call s:CheckArgsRedact()
 
 function! s:reveal_pass() abort
-    highlight! link password_store_password Comment
+    setlocal syntax=pass
 endfunction
 command! Reveal call <SID>reveal_pass()
 
 function! s:conceal_pass() abort
 endfunction
 command! Reveal call <SID>reveal_pass()
 
 function! s:conceal_pass() abort
-    highlight! password_store_password guifg=DarkGray guibg=DarkGray ctermfg=8 ctermbg=8
+    setlocal syntax=pass.obfuscated
 endfunction
 command! Conceal call <SID>conceal_pass()
 normal! GG
 
 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
 " Cleanup at end
 let &cpoptions = s:save_cpo
index 0a53ea8574d90934a0635b540aa6ecb9db22b48c..8eff972a97844de7d43b36b812e5631000548da4 100644 (file)
@@ -1,21 +1,31 @@
 if exists('b:current_syntax') | finish|  endif
 
 if exists('b:current_syntax') | finish|  endif
 
+if execute('highlight CursorLine') =~# 'xxx term=underline cterm=underline guibg=Grey40'
+    echohl WarningMsg
+    echo 'cursorline expected for obfuscation, manually setting'
+    echohl None
+    highlight CursorLine term=underline ctermbg=gray guibg=Grey40
+endif
+
 setlocal cursorline
 
 " set redacted colors from colorscheme
 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*')
+" regular passwords are Comment
+let s:comment_guifg = password_store#get_highight('Comment', 'guifg')
+let s:comment_ctermfg = password_store#get_highight('Comment', 'ctermfg')
 
 
-let s:comment_highlight_str = execute( 'highlight Comment' )
-let s:comment_fg = matchstr(s:comment_highlight_str, 'guifg=\zs\S*')
+" short passwords are Error
+let s:error_guifg = password_store#get_highight('Error', 'guifg')
+let s:error_ctermfg = password_store#get_highight('Error', 'ctermfg')
 
 execute 'highlight password_store_password ' .
 
 execute 'highlight password_store_password ' .
-            \ ' guibg=' . s:comment_fg .
-            \ ' guifg=' . s:comment_fg .
-            \ ' ctermfg=1 ctermbg=1'
+            \ ' guibg=' . s:comment_guifg .
+            \ ' guifg=' . s:comment_guifg .
+            \ ' ctermfg=' . s:comment_ctermfg
+            \  'ctermbg=' . s:comment_ctermfg
 
 execute 'highlight password_store_password_short ' .
 
 execute 'highlight password_store_password_short ' .
-            \ ' guibg=' . s:error_fg .
-            \ ' guifg=' . s:error_fg .
-            \ ' ctermfg=1 ctermbg=1'
-
+            \ ' guibg=' . s:error_guifg .
+            \ ' guifg=' . s:error_guifg .
+            \ ' ctermfg=' . s:error_ctermfg
+            \  'ctermbg=' . s:error_ctermfg
index 1645720091d257fd36eb87c28be6184d558a0f67..4ab26e41e0f78be5fb085bb7ff550bcea0eb4d19 100644 (file)
@@ -2,11 +2,11 @@ if exists('b:current_syntax') | finish|  endif
 
 " first line (by convention always a single pasword)
 syntax match password_store_password /\%1l.*/
 
 " first line (by convention always a single pasword)
 syntax match password_store_password /\%1l.*/
-highlight link password_store_password Comment
+highlight! link password_store_password Comment
 
 " highlight short passwords
 syntax match password_store_password_short /\%1l.\{,6\}$/
 
 " highlight short passwords
 syntax match password_store_password_short /\%1l.\{,6\}$/
-highlight link password_store_password_short Error
+highlight! link password_store_password_short Error
 
 " colon field value is the suggested path for additional information
 syntax match password_store_header '\v^[^:]+:'
 
 " colon field value is the suggested path for additional information
 syntax match password_store_header '\v^[^:]+:'
similarity index 85%
rename from t/settings.vader
rename to t/pass.vader
index aab7688c212121b64d18a13797845e0cca14a99e..e1c5db0bff2506e35de45023bc2a287d0e931b41 100644 (file)
@@ -39,4 +39,7 @@ Execute (test ftdetect trigger):
   AssertEqual password_store#setting('enable_syntax'), 'false'
   AssertEqual len( password_store#generate() ), 16
 
   AssertEqual password_store#setting('enable_syntax'), 'false'
   AssertEqual len( password_store#generate() ), 16
 
+Execute (test highlight group parsing):
+  Assert password_store#get_highight('Comment', 'guifg') =~# '\v#[0-9a-f]{6}'
+  Assert password_store#get_highight('Comment', 'not_a_real_group') =~# ''