Add mapping <Plug>SecretToggle

This commit is contained in:
Ernst Widerberg 2021-01-30 12:09:05 +01:00
parent 33ef0ba3b6
commit a911e7e891
5 changed files with 29 additions and 2 deletions

View file

@ -17,6 +17,10 @@
<td><code>:Secret!</code></td>
<td>Disable secret view.</td>
</tr>
<tr>
<td><code>&lt;Plug&gt;SecretToggle</code></td>
<td>Toggle secret view.</td>
</tr>
</table>
An area around the cursor is unhidden to enable you to see what you are typing. This can be the entire line, the current word, the current character, or it can be disabled completely.

View file

@ -164,3 +164,11 @@ function! secret#secret(enable, ...)
call s:disable()
endif
endfunction
function! secret#toggle()
if !exists('w:secret_state') || !has_key(w:secret_state, bufnr())
call secret#secret(1)
else
call secret#secret(0)
endif
endfunction

View file

@ -64,12 +64,20 @@ g:secret_timeout_insert Hide entire buffer after 'updatetime' milliseconds
==============================================================================
MAPPINGS *secret-mappings*
Secret view mappings~
*g:secret_quickhide*
g:secret_quickhide Hide entire buffer until the cursor is moved. Set this
to a key sequence string: >
g:secret_quickhide Hide entire buffer until the cursor is moved.
Set this to a key sequence string: >
let g:secret_quickhide = '<Leader>q'
Global mappings~
*<Plug>SecretToggle*
<Plug>SecretToggle Toggle secret view.
<Plug> mappings are used like this: >
nmap <Leader>s <Plug>SecretToggle
==============================================================================
HIGHLIGHTING *secret-highlight* *SecretVisible*

View file

@ -1,4 +1,5 @@
command! -bang -nargs=* Secret call secret#secret(<bang>1, <f-args>)
nmap <silent> <Plug>SecretToggle :call secret#toggle()<CR>
if !exists('g:secret_cchar')
let g:secret_cchar = '•'

View file

@ -249,3 +249,9 @@ Execute (quickhide mapping, moving around):
AssertSyntax '••••• •••••', '••••• ••• ••••'
Secret!
AssertEqual maparg('q'), ''
Execute (toggle mapping):
nmap s <Plug>SecretToggle
AssertSyntax ' ', ' '
normal s
AssertSyntax '----- •••••', '••••• ••• ••••'