mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-13 15:39:09 +08:00
Fix conflict
This commit is contained in:
commit
626b4baed6
151
autoload/SpaceVim/api/transient_state.vim
Normal file
151
autoload/SpaceVim/api/transient_state.vim
Normal file
@ -0,0 +1,151 @@
|
||||
let s:self = {}
|
||||
|
||||
let s:self._keys = {}
|
||||
let s:self._on_syntax = ''
|
||||
let s:self._title = 'Transient State'
|
||||
let s:self._handle_inputs = {}
|
||||
|
||||
function! s:self.open() abort
|
||||
noautocmd botright split __transient_state__
|
||||
let self._bufid = bufnr('%')
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber
|
||||
set filetype=TransientState
|
||||
" let save_tve = &t_ve
|
||||
" setlocal t_ve=
|
||||
" setlocal nomodifiable
|
||||
" setf SpaceVimFlyGrep
|
||||
" let &t_ve = save_tve
|
||||
if !empty(self._on_syntax) && type(self._on_syntax) ==# 2
|
||||
call call(self._on_syntax, [])
|
||||
else
|
||||
hi def link SpaceVim_Transient_State_Exit Keyword
|
||||
hi def link SpaceVim_Transient_State_Notexit Number
|
||||
hi def link SpaceVim_Transient_State_Title Title
|
||||
endif
|
||||
call setline(1, self._title)
|
||||
let b:transient_state_title = self._title
|
||||
call append(line('$'), '')
|
||||
call self.highlight_title()
|
||||
call self._update_content()
|
||||
call append(line('$'), '')
|
||||
call append(line('$'), '[KEY] exits state [KEY] will not exit')
|
||||
call self.highlight_keys(1, line('$') - 1, 1, 4)
|
||||
call self.highlight_keys(0, line('$') - 1, 21, 24)
|
||||
if winheight(0) > line('$')
|
||||
exe 'resize ' . line('$')
|
||||
endif
|
||||
" move to prvious window
|
||||
wincmd p
|
||||
while 1
|
||||
redraw!
|
||||
let char = self._getchar()
|
||||
if char ==# "\<FocusLost>" || char ==# "\<FocusGained>" || char2nr(char) == 128
|
||||
continue
|
||||
endif
|
||||
if !has_key(self._handle_inputs, char)
|
||||
break
|
||||
else
|
||||
if type(self._handle_inputs[char]) == 2
|
||||
call call(self._handle_inputs[char], [])
|
||||
elseif type(self._handle_inputs[char]) == 1
|
||||
exe self._handle_inputs[char]
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
exe 'bd ' . self._bufid
|
||||
doautocmd WinEnter
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:self._getchar(...) abort
|
||||
let ret = call('getchar', a:000)
|
||||
return (type(ret) == type(0) ? nr2char(ret) : ret)
|
||||
endfunction
|
||||
|
||||
function! s:self.defind_keys(dict) abort
|
||||
let self._keys = a:dict
|
||||
endfunction
|
||||
|
||||
function! s:self.set_syntax(func) abort
|
||||
let self._on_syntax = a:func
|
||||
endfunction
|
||||
|
||||
function! s:self.set_title(title) abort
|
||||
let self._title = a:title
|
||||
endfunction
|
||||
|
||||
function! s:self.highlight_keys(exit, line, begin, end) abort
|
||||
if a:exit
|
||||
call nvim_buf_add_highlight(self._bufid, 0, 'SpaceVim_Transient_State_Exit', a:line, a:begin, a:end)
|
||||
else
|
||||
call nvim_buf_add_highlight(self._bufid, 0, 'SpaceVim_Transient_State_Notexit', a:line, a:begin, a:end)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:self.highlight_title() abort
|
||||
call nvim_buf_add_highlight(self._bufid, 0, 'SpaceVim_Transient_State_Title', 0, 0, len(self._title))
|
||||
endfunction
|
||||
|
||||
function! s:self._update_content() abort
|
||||
if get(self._keys, 'layout', '') == 'vertical split'
|
||||
let linenum = max([len(self._keys.right), len(self._keys.left)])
|
||||
for i in range(linenum)
|
||||
let left = get(self._keys.left, i)
|
||||
let right = get(self._keys.right, i)
|
||||
let line = ''
|
||||
if !empty(left)
|
||||
if type(left.key) == 1
|
||||
let line .= '[' . left.key . '] ' . left.desc
|
||||
call self.highlight_keys(left.exit, i + 2, 1, 1 + len(left.key))
|
||||
if !empty(left.cmd)
|
||||
call extend(self._handle_inputs, {left.key : left.cmd})
|
||||
elseif !empty(left.func)
|
||||
call extend(self._handle_inputs, {left.key : left.func})
|
||||
endif
|
||||
elseif type(left.key) == 3
|
||||
elseif type(left.key) == 4
|
||||
let line .= '[' . left.key.name . '] ' . left.desc
|
||||
for pos in left.key.pos
|
||||
call self.highlight_keys(left.exit, i + 2, pos[0], pos[1])
|
||||
endfor
|
||||
for handles in left.key.handles
|
||||
call extend(self._handle_inputs, {handles[0] : handles[1]})
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
let line .= repeat(' ', 40 - len(line))
|
||||
if !empty(right)
|
||||
if type(right.key) == 1
|
||||
let line .= '[' . right.key . '] ' . right.desc
|
||||
call self.highlight_keys(right.exit, i + 2, 41, 41 + len(right.key))
|
||||
if !empty(right.cmd)
|
||||
call extend(self._handle_inputs, {right.key : right.cmd})
|
||||
elseif !empty(right.func)
|
||||
call extend(self._handle_inputs, {right.key : right.func})
|
||||
endif
|
||||
elseif type(right.key) == 3
|
||||
let line .= '[' . join(right.key, '/') . '] ' . right.desc
|
||||
let begin = 41
|
||||
for key in right.key
|
||||
call self.highlight_keys(right.exit, i + 2, begin, begin + len(key))
|
||||
let begin = begin + len(key) + 1
|
||||
endfor
|
||||
if !empty(right.cmd)
|
||||
for key in right.key
|
||||
call extend(self._handle_inputs, {key : right.cmd})
|
||||
endfor
|
||||
elseif !empty(right.func)
|
||||
for key in right.key
|
||||
call extend(self._handle_inputs, {key : right.func})
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
call append(line('$'), line)
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#api#transient_state#get() abort
|
||||
return deepcopy(s:self)
|
||||
endfunction
|
@ -220,6 +220,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
||||
return '%#SpaceVim_statusline_a# FlyGrep %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
\ . '%#SpaceVim_statusline_b# %{getcwd()}%#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
|
||||
\ . '%#SpaceVim_statusline_c# %{SpaceVim#plugins#flygrep#lineNr()}'
|
||||
elseif &filetype ==# 'TransientState'
|
||||
return '%#SpaceVim_statusline_a# Transient State %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
|
||||
endif
|
||||
if a:0 > 0
|
||||
return s:active()
|
||||
|
@ -93,6 +93,9 @@ function! SpaceVim#layers#default#config() abort
|
||||
\ . string(s:_function('s:jump_to_url')) . ', [])',
|
||||
\ 'jump to url', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['<Tab>'], 'try | b# | catch | endtry', 'last buffer', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', '.'], 'call call('
|
||||
\ . string(s:_function('s:buffer_transient_state')) . ', [])',
|
||||
\ 'buffer transient state', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 'd'], 'call SpaceVim#mapping#close_current_buffer()', 'kill-this-buffer', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 'D'],
|
||||
\ 'call SpaceVim#mapping#kill_visible_buffer_choosewin()',
|
||||
@ -285,3 +288,132 @@ function! s:delete_current_buffer_file() abort
|
||||
redraw!
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:swap_buffer_with_nth_win(nr) abort
|
||||
if a:nr <= winnr('$') && a:nr != winnr()
|
||||
let cb = bufnr('%')
|
||||
let tb = winbufnr(a:nr)
|
||||
if cb != tb
|
||||
exe a:nr . 'wincmd w'
|
||||
exe 'b' . cb
|
||||
wincmd p
|
||||
exe 'b' . tb
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:move_buffer_to_nth_win(nr) abort
|
||||
if a:nr <= winnr('$') && a:nr != winnr()
|
||||
let cb = bufnr('%')
|
||||
bp
|
||||
exe a:nr . 'wincmd w'
|
||||
exe 'b' . cb
|
||||
wincmd p
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:buffer_transient_state() abort
|
||||
let state = SpaceVim#api#import('transient_state')
|
||||
call state.set_title('Buffer Selection Transient State')
|
||||
call state.defind_keys(
|
||||
\ {
|
||||
\ 'layout' : 'vertical split',
|
||||
\ 'left' : [
|
||||
\ {
|
||||
\ 'key' : {
|
||||
\ 'name' : 'C-1..C-9',
|
||||
\ 'pos' : [[1,4], [6,9]],
|
||||
\ 'handles' : [
|
||||
\ ["\<C-1>" , ''],
|
||||
\ ["\<C-2>" , ''],
|
||||
\ ["\<C-3>" , ''],
|
||||
\ ["\<C-4>" , ''],
|
||||
\ ["\<C-5>" , ''],
|
||||
\ ["\<C-6>" , ''],
|
||||
\ ["\<C-7>" , ''],
|
||||
\ ["\<C-8>" , ''],
|
||||
\ ["\<C-9>" , ''],
|
||||
\ ],
|
||||
\ },
|
||||
\ 'desc' : 'goto nth window',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : '',
|
||||
\ 'exit' : 0,
|
||||
\ },
|
||||
\ {
|
||||
\ 'key' : {
|
||||
\ 'name' : '1..9',
|
||||
\ 'pos' : [[1,2], [4,5]],
|
||||
\ 'handles' : [
|
||||
\ ['1' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [1])'],
|
||||
\ ['2' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [2])'],
|
||||
\ ['3' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [3])'],
|
||||
\ ['4' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [4])'],
|
||||
\ ['5' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [5])'],
|
||||
\ ['6' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [6])'],
|
||||
\ ['7' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [7])'],
|
||||
\ ['8' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [8])'],
|
||||
\ ['9' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [9])'],
|
||||
\ ],
|
||||
\ },
|
||||
\ 'desc' : 'move buffer to nth window',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : '',
|
||||
\ 'exit' : 0,
|
||||
\ },
|
||||
\ {
|
||||
\ 'key' : {
|
||||
\ 'name' : 'M-1..M-9',
|
||||
\ 'pos' : [[1,4], [6,9]],
|
||||
\ 'handles' : [
|
||||
\ ["\<M-1>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [1])'],
|
||||
\ ["\<M-2>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [2])'],
|
||||
\ ["\<M-3>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [3])'],
|
||||
\ ["\<M-4>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [4])'],
|
||||
\ ["\<M-5>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [5])'],
|
||||
\ ["\<M-6>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [6])'],
|
||||
\ ["\<M-7>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [7])'],
|
||||
\ ["\<M-8>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [8])'],
|
||||
\ ["\<M-9>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [9])'],
|
||||
\ ],
|
||||
\ },
|
||||
\ 'desc' : 'swap buffer with nth window',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : '',
|
||||
\ 'exit' : 0,
|
||||
\ },
|
||||
\ ],
|
||||
\ 'right' : [
|
||||
\ {
|
||||
\ 'key' : 'n',
|
||||
\ 'desc' : 'next buffer',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : 'bnext',
|
||||
\ 'exit' : 0,
|
||||
\ },
|
||||
\ {
|
||||
\ 'key' : ['N', 'p'],
|
||||
\ 'desc' : 'previous buffer',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : 'bp',
|
||||
\ 'exit' : 0,
|
||||
\ },
|
||||
\ {
|
||||
\ 'key' : 'd',
|
||||
\ 'desc' : 'kill buffer',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : 'call SpaceVim#mapping#close_current_buffer()',
|
||||
\ 'exit' : 0,
|
||||
\ },
|
||||
\ {
|
||||
\ 'key' : 'q',
|
||||
\ 'desc' : 'quit',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : '',
|
||||
\ 'exit' : 1,
|
||||
\ },
|
||||
\ ],
|
||||
\ }
|
||||
\ )
|
||||
call state.open()
|
||||
endfunction
|
||||
|
@ -1,8 +1,8 @@
|
||||
scriptencoding utf-8
|
||||
let s:PASSWORD = SpaceVim#api#import('password')
|
||||
let s:NUMBER = SpaceVim#api#import('data#number')
|
||||
let s:LIST = SpaceVim#api#import('data#list')
|
||||
|
||||
|
||||
function! SpaceVim#layers#edit#plugins() abort
|
||||
let plugins = [
|
||||
\ ['tpope/vim-surround'],
|
||||
@ -43,6 +43,53 @@ function! SpaceVim#layers#edit#config() abort
|
||||
"noremap <SPACE> <Plug>(wildfire-fuel)
|
||||
vnoremap <C-SPACE> <Plug>(wildfire-water)
|
||||
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'}
|
||||
nnoremap <silent> <Plug>CountSelectionRegion :call <SID>count_selection_region()<Cr>
|
||||
xnoremap <silent> <Plug>CountSelectionRegion :<C-u>call <SID>count_selection_region()<Cr>
|
||||
call SpaceVim#mapping#space#def('nmap', ['x', 'c'], '<Plug>CountSelectionRegion', 'cunt in the selection region', 0, 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', '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', '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)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', '_'], 'silent call call('
|
||||
\ . string(s:_function('s:under_score')) . ', [])',
|
||||
\ 'change symbol style to under_score', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'u'], 'silent call call('
|
||||
\ . string(s:_function('s:under_score')) . ', [])',
|
||||
\ 'change symbol style to under_score', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'U'], 'silent call call('
|
||||
\ . string(s:_function('s:up_case')) . ', [])',
|
||||
\ 'change symbol style to UP_CACE', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'k'], 'silent call call('
|
||||
\ . string(s:_function('s:kebab_case')) . ', [])',
|
||||
\ 'change symbol style to kebab-case', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', '-'], 'silent call call('
|
||||
\ . string(s:_function('s:kebab_case')) . ', [])',
|
||||
\ 'change symbol style to kebab-case', 1)
|
||||
|
||||
|
||||
let g:_spacevim_mappings_space.i = {'name' : '+Insertion'}
|
||||
let g:_spacevim_mappings_space.i.l = {'name' : '+Lorem-ipsum'}
|
||||
let g:_spacevim_mappings_space.i.p = {'name' : '+Passwords'}
|
||||
@ -75,6 +122,179 @@ function! SpaceVim#layers#edit#config() abort
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 's'], 'call call('
|
||||
\ . string(s:_function('s:insert_lorem_ipsum_sentence')) . ', [])',
|
||||
\ 'insert lorem-ipsum sentence', 1)
|
||||
let g:_spacevim_mappings_space.x.g = {'name' : '+translate'}
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'g', 't'], 'Ydc', 'translate current word', 1)
|
||||
|
||||
" move line
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'J'], 'call call('
|
||||
\ . string(s:_function('s:move_text_down_transient_state')) . ', [])',
|
||||
\ 'move text down(enter transient state)', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'K'], 'call call('
|
||||
\ . string(s:_function('s:move_text_up_transient_state')) . ', [])',
|
||||
\ 'move text up(enter transient state)', 1)
|
||||
endfunction
|
||||
|
||||
function! s:move_text_down_transient_state() abort
|
||||
normal! ddp
|
||||
call s:text_transient_state()
|
||||
endfunction
|
||||
|
||||
function! s:move_text_up_transient_state() abort
|
||||
normal! ddkP
|
||||
call s:text_transient_state()
|
||||
endfunction
|
||||
|
||||
function! s:text_transient_state() abort
|
||||
let state = SpaceVim#api#import('transient_state')
|
||||
call state.set_title('Move Text Transient State')
|
||||
call state.defind_keys(
|
||||
\ {
|
||||
\ 'layout' : 'vertical split',
|
||||
\ 'left' : [
|
||||
\ {
|
||||
\ 'key' : 'J',
|
||||
\ 'desc' : 'move text down',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : 'normal! "_ddp',
|
||||
\ 'exit' : 0,
|
||||
\ },
|
||||
\ ],
|
||||
\ 'right' : [
|
||||
\ {
|
||||
\ 'key' : 'K',
|
||||
\ 'desc' : 'move text up',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : 'normal! "_ddkP',
|
||||
\ 'exit' : 0,
|
||||
\ },
|
||||
\ ],
|
||||
\ }
|
||||
\ )
|
||||
call state.open()
|
||||
endfunction
|
||||
|
||||
function! s:lowerCamelCase() abort
|
||||
" fooFzz
|
||||
let cword = s:parse_symbol(expand('<cword>'))
|
||||
if !empty(cword)
|
||||
let rst = [cword[0]]
|
||||
if len(cword) > 1
|
||||
let rst += map(cword[1:], "substitute(v:val, '^.', '\\u&', 'g')")
|
||||
endif
|
||||
let save_register = @k
|
||||
let save_cursor = getcurpos()
|
||||
let @k = join(rst, '')
|
||||
normal! viw"kp
|
||||
call setpos('.', save_cursor)
|
||||
let @k = save_register
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:UpperCamelCase() abort
|
||||
" FooFzz
|
||||
let cword = s:parse_symbol(expand('<cword>'))
|
||||
if !empty(cword)
|
||||
let rst = map(cword, "substitute(v:val, '^.', '\\u&', 'g')")
|
||||
let save_register = @k
|
||||
let save_cursor = getcurpos()
|
||||
let @k = join(rst, '')
|
||||
normal! viw"kp
|
||||
call setpos('.', save_cursor)
|
||||
let @k = save_register
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:kebab_case() abort
|
||||
" foo-fzz
|
||||
let cword = s:parse_symbol(expand('<cword>'))
|
||||
if !empty(cword)
|
||||
let save_register = @k
|
||||
let save_cursor = getcurpos()
|
||||
let @k = join(cword, '-')
|
||||
normal! viw"kp
|
||||
call setpos('.', save_cursor)
|
||||
let @k = save_register
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:under_score() abort
|
||||
" foo_fzz
|
||||
let cword = s:parse_symbol(expand('<cword>'))
|
||||
if !empty(cword)
|
||||
let save_register = @k
|
||||
let save_cursor = getcurpos()
|
||||
let @k = join(cword, '_')
|
||||
normal! viw"kp
|
||||
call setpos('.', save_cursor)
|
||||
let @k = save_register
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:up_case() abort
|
||||
" FOO_FZZ
|
||||
let cword =map(s:parse_symbol(expand('<cword>')), 'toupper(v:val)')
|
||||
if !empty(cword)
|
||||
let save_register = @k
|
||||
let save_cursor = getcurpos()
|
||||
let @k = join(cword, '_')
|
||||
normal! viw"kp
|
||||
call setpos('.', save_cursor)
|
||||
let @k = save_register
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:STRING = SpaceVim#api#import('data#string')
|
||||
function! s:parse_symbol(symbol) abort
|
||||
if a:symbol =~ '^[a-z]\+\(-[a-zA-Z]\+\)*$'
|
||||
return split(a:symbol, '-')
|
||||
elseif a:symbol =~ '^[a-z]\+\(_[a-zA-Z]\+\)*$'
|
||||
return split(a:symbol, '_')
|
||||
elseif a:symbol =~ '^[a-z]\+\([A-Z][a-z]\+\)*$'
|
||||
let chars = s:STRING.string2chars(a:symbol)
|
||||
let rst = []
|
||||
let word = ''
|
||||
for char in chars
|
||||
if char =~# '[a-z]'
|
||||
let word .= char
|
||||
else
|
||||
call add(rst, tolower(word))
|
||||
let word = char
|
||||
endif
|
||||
endfor
|
||||
call add(rst, tolower(word))
|
||||
return rst
|
||||
elseif a:symbol =~ '^[A-Z][a-z]\+\([A-Z][a-z]\+\)*$'
|
||||
let chars = s:STRING.string2chars(a:symbol)
|
||||
let rst = []
|
||||
let word = ''
|
||||
for char in chars
|
||||
if char =~# '[a-z]'
|
||||
let word .= char
|
||||
else
|
||||
if !empty(word)
|
||||
call add(rst, tolower(word))
|
||||
endif
|
||||
let word = char
|
||||
endif
|
||||
endfor
|
||||
call add(rst, tolower(word))
|
||||
return rst
|
||||
else
|
||||
return [a:symbol]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:count_selection_region() abort
|
||||
call feedkeys("gvg\<c-g>\<Esc>", 'ti')
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:delete_extra_space() abort
|
||||
if !empty(getline('.'))
|
||||
if getline('.')[col('.')-1] ==# ' '
|
||||
exe "normal! viw\"_di\<Space>\<Esc>"
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
let s:local_lorem_ipsum = [
|
||||
\ 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.',
|
||||
|
@ -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)
|
||||
|
@ -25,6 +25,8 @@ title: "Documentation"
|
||||
* [Custom Configuration](#custom-configuration)
|
||||
* [Automatic Generation](#automatic-generation)
|
||||
* [Alternative directory](#alternative-directory)
|
||||
* [Concepts](#concepts)
|
||||
* [Transient-states](#transient-states)
|
||||
* [Awesome ui](#awesome-ui)
|
||||
* [Colorschemes](#colorschemes)
|
||||
* [Font](#font)
|
||||
@ -79,6 +81,9 @@ title: "Documentation"
|
||||
* [Searching on the fly](#searching-on-the-fly)
|
||||
* [Persistent highlighting](#persistent-highlighting)
|
||||
* [Editing](#editing)
|
||||
* [Paste text](#paste-text)
|
||||
* [Auto-indent pasted text](#auto-indent-pasted-text)
|
||||
* [Text manipulation commands](#text-manipulation-commands)
|
||||
* [Text insertion commands](#text-insertion-commands)
|
||||
* [Commenting](#commenting)
|
||||
* [Multi-Encodings](#multi-encodings)
|
||||
@ -291,6 +296,19 @@ let g:spacevim_guifont = 'DejaVu\ Sans\ Mono\ for\ Powerline\ 11'
|
||||
|
||||
Comprehensive documentation is available for each layer by <kbd>:h SpaceVim</kbd>.
|
||||
|
||||
## Concepts
|
||||
|
||||
### Transient-states
|
||||
|
||||
SpaceVim defines a wide variety of transient states (temporary overlay maps) where it makes sense. This prevents one from doing repetitive and tedious presses on the SPC key.
|
||||
|
||||
When a transient state is active, a documentation is displayed in the transient state buffer. Additional information may as well be displayed in it.
|
||||
|
||||
|
||||
Move Text Transient State:
|
||||
|
||||

|
||||
|
||||
## Awesome ui
|
||||
|
||||
SpaceVim has a minimalistic and distraction free UI:
|
||||
@ -756,6 +774,7 @@ Buffer manipulation commands (start with `b`):
|
||||
Key Binding | Description
|
||||
----------- | -----------
|
||||
`SPC TAB` | switch to alternate buffer in the current window (switch back and forth)
|
||||
`SPC b .` | buffer transient state
|
||||
`SPC b b` | switch to a buffer (via denite/unite)
|
||||
`SPC b d` | kill the current buffer (does not delete the visited file)
|
||||
`SPC u SPC b d` | kill the current buffer and window (does not delete the visited file) (TODO)
|
||||
@ -1154,6 +1173,70 @@ SpaceVim uses `g:spacevim_search_highlight_persist` to keep the searched express
|
||||
|
||||
### Editing
|
||||
|
||||
#### Paste text
|
||||
|
||||
##### Auto-indent pasted text
|
||||
|
||||
#### Text manipulation commands
|
||||
|
||||
Text related commands (start with `x`):
|
||||
|
||||
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 ]` | align region at ]
|
||||
`SPC x a {` | align region at {
|
||||
`SPC x a }` | align region at }
|
||||
`SPC x a ,` | align region at ,
|
||||
`SPC x a .` | align region at . (for numeric tables)
|
||||
`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 (TODO)
|
||||
`SPC x a c` | align current indentation region using default rules (TODO)
|
||||
`SPC x a l` | left-align with evil-lion (TODO)
|
||||
`SPC x a L` | right-align with evil-lion (TODO)
|
||||
`SPC x a r` | align region using user-specified regexp (TODO)
|
||||
`SPC x a m` | align region at arithmetic operators `` (+-*/) `` (TODO)
|
||||
`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
|
||||
`SPC x g l` | set lanuages used by translate commands (TODO)
|
||||
`SPC x g t` | translate current word using Google Translate
|
||||
`SPC x g T` | reverse source and target languages (TODO)
|
||||
`SPC x i c` | change symbol style to `lowerCamelCase`
|
||||
`SPC x i C` | change symbol style to `UpperCamelCase`
|
||||
`SPC x i i` | cycle symbol naming styles (i to keep cycling)
|
||||
`SPC x i -` | change symbol style to `kebab-case`
|
||||
`SPC x i k` | change symbol style to `kebab-case`
|
||||
`SPC x i _` | change symbol style to `under_score`
|
||||
`SPC x i u` | change symbol style to `under_score`
|
||||
`SPC x i U` | change symbol style to `UP_CASE`
|
||||
`SPC x j c` | set the justification to center (TODO)
|
||||
`SPC x j f` | set the justification to full (TODO)
|
||||
`SPC x j l` | set the justification to left (TODO)
|
||||
`SPC x j n` | set the justification to none (TODO)
|
||||
`SPC x j r` | set the justification to right (TODO)
|
||||
`SPC x J` | move down a line of text (enter transient state)
|
||||
`SPC x K` | move up a line of text (enter transient state)
|
||||
`SPC x l d` | duplicate line or region
|
||||
`SPC x l s` | sort lines
|
||||
`SPC x l u` | uniquify lines
|
||||
`SPC x o` | use avy to select a link in the frame and open it
|
||||
`SPC x O` | use avy to select multiple links in the frame and open them
|
||||
`SPC x t c` | swap (transpose) the current character with the previous one
|
||||
`SPC x t w` | swap (transpose) the current word with the previous one
|
||||
`SPC x t l` | swap (transpose) the current line with the previous one
|
||||
`SPC x u` | set the selected text to lower case
|
||||
`SPC x U` | set the selected text to upper case
|
||||
`SPC x w c` | count the number of occurrences per word in the select region
|
||||
`SPC x w d` | show dictionary entry of word from wordnik.com
|
||||
`SPC x TAB` | indent or dedent a region rigidly
|
||||
|
||||
#### Text insertion commands
|
||||
|
||||
Text insertion commands (start with `i`):
|
||||
@ -1191,6 +1274,7 @@ Key Binding | Description
|
||||
`SPC c Y` | invert comment and yank
|
||||
|
||||
**Tips:** To comment efficiently a block of line use the combo `SPC ; SPC j l`
|
||||
>>>>>>> dev
|
||||
|
||||
#### Multi-Encodings
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user