1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 02:20:05 +08:00

Add toggle whitespace mappings SPC t w

This commit is contained in:
wsdjeg 2017-05-23 22:56:31 +08:00
parent 529b482b40
commit 0a914e2b92
4 changed files with 28 additions and 4 deletions

View File

@ -5,7 +5,7 @@ function! s:self.build(left_sections, right_sections, lsep, rsep, hi_a, hi_b, hi
let l = '%#' . a:hi_a . '#' . a:left_sections[0]
let l .= '%#' . a:hi_a . '_' . a:hi_b . '#' . a:lsep
let flag = 1
for sec in a:left_sections[1:]
for sec in filter(a:left_sections[1:], '!empty(v:val)')
if flag == 1
let l .= '%#' . a:hi_b . '#' . sec
let l .= '%#' . a:hi_b . '_' . a:hi_c . '#' . a:lsep
@ -30,7 +30,7 @@ function! s:self.build(left_sections, right_sections, lsep, rsep, hi_a, hi_b, hi
endif
let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:rsep
let flag = 1
for sec in a:right_sections
for sec in filter(a:right_sections, '!empty(v:val)')
if flag == 1
let l .= '%#' . a:hi_b . '#' . sec
let l .= '%#' . a:hi_c . '_' . a:hi_b . '#' . a:rsep

View File

@ -47,6 +47,10 @@ let s:modes = {
\ 'icon' : s:MESSLETTERS.circled_letter('S'),
\ 'desc' : 'spell-checking mode',
\ },
\ 'whitespace' :{
\ 'icon' : s:MESSLETTERS.circled_letter('w'),
\ 'desc' : 'whitespace mode',
\ },
\ }
let s:loaded_sections = ['syntax checking', 'major mode', 'minor mode lighters', 'version control info']
@ -109,13 +113,22 @@ function! s:git_branch() abort
return ''
endfunction
function! s:whitespace() abort
let ln = search('\s\+$', 'n')
if ln != 0
return ' trailing[' . ln . '] '
else
return ''
endif
endfunction
function! s:modes() abort
let m = ' ❖ '
for mode in s:loaded_modes
let m .= s:modes[mode].icon . ' '
endfor
return m
return m . ' '
endfunction
function! s:filesize() abort
@ -179,6 +192,9 @@ function! s:active() abort
call add(rsec, s:time())
endif
if index(s:loaded_sections, 'whitespace') != -1
call add(rsec, s:whitespace())
endif
return s:STATUSLINE.build(lsec, rsec, s:lsep, s:rsep,
\ 'SpaceVim_statusline_a', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z')
endfunction

View File

@ -70,6 +70,9 @@ function! SpaceVim#layers#ui#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['t', 'S'], 'call call('
\ . string(s:_function('s:toggle_spell_check')) . ', [])',
\ 'toggle syntax checker', 1)
call SpaceVim#mapping#space#def('nnoremap', ['t', 'w'], 'call call('
\ . string(s:_function('s:toggle_whitespace')) . ', [])',
\ 'toggle the whitespace', 1)
endfunction
" function() wrapper
if v:version > 703 || v:version == 703 && has('patch1170')
@ -201,3 +204,8 @@ function! s:toggle_spell_check() abort
endif
call SpaceVim#layers#core#statusline#toggle_mode('spell-checking')
endfunction
function! s:toggle_whitespace() abort
call SpaceVim#layers#core#statusline#toggle_section('whitespace')
call SpaceVim#layers#core#statusline#toggle_mode('whitespace')
endfunction

View File

@ -480,7 +480,7 @@ Prefix name | custom option and default value | description
`[unite]` | `g:spacevim_unite_leader` / `f` | unite mapping prefix of SpaceVim
`<leader>` | `mapleader` / ``\`` | default leader prefix of vim/neovim
By default the guide buffer will be displayed 1000ms after the key has been pressed. You can change the delay by setting `'timeoutlen'` option to your liking (the value is in milliseconds).
By default the guide buffer will be displayed 1000ms after the key has been pressed. You can change the delay by setting `'timeoutlen'` option to your liking (the value is in milliseconds).
for example, after pressing `<Space>` in normal mode, you will see :