mirror of
https://github.com/vim-airline/vim-airline-themes.git
synced 2024-12-05 08:30:03 +08:00
Add crypt indicator
If editing an encrypted file, add an indicator, that the file is encrypted
This commit is contained in:
parent
67de5f2257
commit
9d90e2cbfe
|
@ -161,6 +161,10 @@ function! airline#check_mode(winnr)
|
|||
call add(l:mode, 'paste')
|
||||
endif
|
||||
|
||||
if g:airline_detect_crypt && !empty(&key)
|
||||
call add(l:mode, 'crypt')
|
||||
endif
|
||||
|
||||
if &readonly || ! &modifiable
|
||||
call add(l:mode, 'readonly')
|
||||
endif
|
||||
|
|
|
@ -15,13 +15,13 @@ function! airline#init#bootstrap()
|
|||
let s:loaded = 1
|
||||
|
||||
let g:airline#init#bootstrapping = 1
|
||||
|
||||
call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b0":">")
|
||||
call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b1":">")
|
||||
call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b2":"<")
|
||||
call s:check_defined('g:airline_right_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b3":"<")
|
||||
call s:check_defined('g:airline_detect_modified', 1)
|
||||
call s:check_defined('g:airline_detect_paste', 1)
|
||||
call s:check_defined('g:airline_detect_crypt', 1)
|
||||
call s:check_defined('g:airline_detect_iminsert', 0)
|
||||
call s:check_defined('g:airline_inactive_collapse', 1)
|
||||
call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus'])
|
||||
|
@ -55,6 +55,9 @@ function! airline#init#bootstrap()
|
|||
\ }, 'keep')
|
||||
|
||||
call s:check_defined('g:airline_symbols', {})
|
||||
let s:airline_crypt=''
|
||||
" generate crypt symbol, "\u" only accepts up to 4 chars
|
||||
exe 'sil norm!' ":\<C-V>U1F512\<c-\>eextend(s:, {'airline_crypt': getcmdline()}).airline_crypt\n"
|
||||
call extend(g:airline_symbols, {
|
||||
\ 'paste': get(g:, 'airline_paste_symbol', 'PASTE'),
|
||||
\ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a2" : 'RO'),
|
||||
|
@ -63,7 +66,9 @@ function! airline#init#bootstrap()
|
|||
\ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a0" : ''),
|
||||
\ 'modified': '+',
|
||||
\ 'space': ' ',
|
||||
\ 'crypt': get(g:, 'airline_crypt_symbol', s:airline_crypt),
|
||||
\ }, 'keep')
|
||||
unlet! s:airline_crypt
|
||||
|
||||
call airline#parts#define('mode', {
|
||||
\ 'function': 'airline#parts#mode',
|
||||
|
@ -71,6 +76,7 @@ function! airline#init#bootstrap()
|
|||
\ })
|
||||
call airline#parts#define_function('iminsert', 'airline#parts#iminsert')
|
||||
call airline#parts#define_function('paste', 'airline#parts#paste')
|
||||
call airline#parts#define_function('crypt', 'airline#parts#crypt')
|
||||
call airline#parts#define_function('filetype', 'airline#parts#filetype')
|
||||
call airline#parts#define('readonly', {
|
||||
\ 'function': 'airline#parts#readonly',
|
||||
|
@ -88,7 +94,7 @@ endfunction
|
|||
function! airline#init#sections()
|
||||
let spc = g:airline_symbols.space
|
||||
if !exists('g:airline_section_a')
|
||||
let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'capslock', 'iminsert'])
|
||||
let g:airline_section_a = airline#section#create_left(['mode', 'crypt', 'paste', 'capslock', 'iminsert'])
|
||||
endif
|
||||
if !exists('g:airline_section_b')
|
||||
let g:airline_section_b = airline#section#create(['hunks', 'branch'])
|
||||
|
|
|
@ -54,6 +54,10 @@ function! airline#parts#mode()
|
|||
return get(w:, 'airline_current_mode', '')
|
||||
endfunction
|
||||
|
||||
function! airline#parts#crypt()
|
||||
return g:airline_detect_crypt && !empty(&key) ? g:airline_symbols.crypt : ''
|
||||
endfunction
|
||||
|
||||
function! airline#parts#paste()
|
||||
return g:airline_detect_paste && &paste ? g:airline_symbols.paste : ''
|
||||
endfunction
|
||||
|
|
|
@ -70,6 +70,9 @@ values):
|
|||
* enable paste detection >
|
||||
let g:airline_detect_paste=1
|
||||
<
|
||||
* enable crypt detection >
|
||||
let g:airline_detect_crypt=1
|
||||
<
|
||||
* enable iminsert detection >
|
||||
let g:airline_detect_iminsert=0
|
||||
<
|
||||
|
@ -176,6 +179,7 @@ its contents. >
|
|||
let g:airline_left_sep = '▶'
|
||||
let g:airline_right_sep = '«'
|
||||
let g:airline_right_sep = '◀'
|
||||
let g:airline_symbols.crypt = '🔒'
|
||||
let g:airline_symbols.linenr = '␊'
|
||||
let g:airline_symbols.linenr = ''
|
||||
let g:airline_symbols.linenr = '¶'
|
||||
|
@ -214,7 +218,7 @@ section.
|
|||
>
|
||||
variable names default contents
|
||||
----------------------------------------------------------------------------
|
||||
let g:airline_section_a (mode, paste, iminsert)
|
||||
let g:airline_section_a (mode, crypt, paste, iminsert)
|
||||
let g:airline_section_b (hunks, branch)
|
||||
let g:airline_section_c (bufferline or filename)
|
||||
let g:airline_section_gutter (readonly, csv)
|
||||
|
@ -639,6 +643,7 @@ Before is a list of parts that are predefined by vim-airline.
|
|||
* `mode` displays the current mode
|
||||
* `iminsert` displays the current insert method
|
||||
* `paste` displays the paste indicator
|
||||
* crypt displays the crypted indicator
|
||||
* `filetype` displays the file type
|
||||
* `readonly` displays the read only indicator
|
||||
* `file` displays the filename and modified indicator
|
||||
|
|
Loading…
Reference in New Issue
Block a user