mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-13 14:59:10 +08:00
Add mappings for changing symbol style
This commit is contained in:
parent
6934599450
commit
f53fc71e3f
@ -1,3 +1,4 @@
|
||||
scriptencoding utf-8
|
||||
function! SpaceVim#layers#edit#plugins() abort
|
||||
let plugins = [
|
||||
\ ['tpope/vim-surround'],
|
||||
@ -40,6 +41,8 @@ function! SpaceVim#layers#edit#config() abort
|
||||
let g:wildfire_objects = ["i'", 'i"', 'i)', 'i]', 'i}', 'ip', 'it']
|
||||
let g:_spacevim_mappings_space.x = {'name' : '+Text'}
|
||||
let g:_spacevim_mappings_space.x.a = {'name' : '+align'}
|
||||
let g:_spacevim_mappings_space.x.d = {'name' : '+delete'}
|
||||
let g:_spacevim_mappings_space.x.i = {'name' : '+change symbol style'}
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '&'], 'Tabularize /&', 'align region at &', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '('], 'Tabularize /(', 'align region at (', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ')'], 'Tabularize /)', 'align region at )', 1)
|
||||
@ -50,5 +53,59 @@ function! SpaceVim#layers#edit#config() abort
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ','], 'Tabularize /,', 'align region at ,', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '.'], 'Tabularize /.', 'align region at .', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ':'], 'Tabularize /:', 'align region at :', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ';'], 'Tabularize /;', 'align region at ;', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '='], 'Tabularize /=', 'align region at =', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '¦'], 'Tabularize /¦', 'align region at ¦', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', 'w'], 'StripWhitespace', 'delete trailing whitespaces', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', '[SPC]'], 'silent call call('
|
||||
\ . string(s:_function('s:delete_extra_space')) . ', [])',
|
||||
\ 'delete extra space arround cursor', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'c'], 'silent call call('
|
||||
\ . string(s:_function('s:lowerCamelCase')) . ', [])',
|
||||
\ 'change symbol style to lowerCamelCase', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'C'], 'silent call call('
|
||||
\ . string(s:_function('s:UpperCamelCase')) . ', [])',
|
||||
\ 'change symbol style to UpperCamelCase', 1)
|
||||
endfunction
|
||||
|
||||
function! s:lowerCamelCase() abort
|
||||
let cword = expand('<cword>')
|
||||
if !empty(cword) && cword[0:0] =~# '[A-Z]'
|
||||
let save_cursor = getcurpos()
|
||||
normal! b~
|
||||
call setpos('.', save_cursor)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:UpperCamelCase() abort
|
||||
let cword = expand('<cword>')
|
||||
if !empty(cword) && cword[0:0] =~# '[a-z]'
|
||||
let save_cursor = getcurpos()
|
||||
normal! b~
|
||||
call setpos('.', save_cursor)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:delete_extra_space() abort
|
||||
if !empty(getline('.'))
|
||||
if getline('.')[col('.')-1] ==# ' '
|
||||
exe "normal! viw\"_di\<Space>\<Esc>"
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" function() wrapper
|
||||
if v:version > 703 || v:version == 703 && has('patch1170')
|
||||
function! s:_function(fstr) abort
|
||||
return function(a:fstr)
|
||||
endfunction
|
||||
else
|
||||
function! s:_SID() abort
|
||||
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
|
||||
endfunction
|
||||
let s:_s = '<SNR>' . s:_SID() . '_'
|
||||
function! s:_function(fstr) abort
|
||||
return function(substitute(a:fstr, 's:', s:_s, 'g'))
|
||||
endfunction
|
||||
endif
|
||||
|
@ -47,6 +47,7 @@ function! SpaceVim#layers#tools#plugins() abort
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#tools#config() abort
|
||||
let g:better_whitespace_filetypes_blacklist = ['diff', 'gitcommit', 'unite', 'qf', 'help', 'markdown', 'leaderGuide']
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['a', 'c'], 'Calendar', 'vim calendar', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['e', 'a'], 'FencAutoDetect',
|
||||
\ 'Auto detect the file encoding', 1)
|
||||
|
@ -1129,13 +1129,13 @@ Key Binding | Description
|
||||
`SPC x a :` | align region at :
|
||||
`SPC x a ;` | align region at ;
|
||||
`SPC x a =` | align region at =
|
||||
`SPC x a ¦` | align region at ¦
|
||||
`SPC x a a` | align region (or guessed section) using default rules
|
||||
`SPC x a c` | align current indentation region using default rules
|
||||
`SPC x a l` | left-align with evil-lion
|
||||
`SPC x a L` | right-align with evil-lion
|
||||
`SPC x a r` | align region using user-specified regexp
|
||||
`SPC x a m` | align region at arithmetic operators `` (+-*/) ``
|
||||
`SPC x a ¦` | align region at ¦
|
||||
`SPC x c` | cunt the number of chars/words/lines in the selection region
|
||||
`SPC x d w` | delete trailing whitespaces
|
||||
`SPC x d SPC` | Delete all spaces and tabs around point, leaving one space
|
||||
|
Loading…
x
Reference in New Issue
Block a user