1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 13:50:05 +08:00

Merge branch 'space-prefix' into dev

This commit is contained in:
wsdjeg 2017-04-19 00:19:53 +08:00
commit 2ee98baab2
19 changed files with 171 additions and 8 deletions

View File

@ -42,7 +42,7 @@ to select the layers they need. It got inspired by [spacemacs](https://github.co
please star it on github. It's a great way of getting feedback and gives me the kick to
put more time into development.
![2017-02-26_1365x739](https://cloud.githubusercontent.com/assets/13142418/23339920/590f2e9a-fc67-11e6-99ec-794f79ba0902.png)
![2017-04-19-00 17 33](https://cloud.githubusercontent.com/assets/13142418/25141441/220b3a54-2496-11e7-9462-fcfdccb7aad8.png)
If you are new to vim, you should learning about Vim in general, read [vim-galore](https://github.com/mhinz/vim-galore).

View File

@ -414,6 +414,7 @@ function! SpaceVim#end() abort
call SpaceVim#mapping#guide#register_prefix_descriptions('', 'g:leaderGuide_map')
endif
call SpaceVim#mapping#leader#defindglobalMappings()
call SpaceVim#mapping#space#init()
if g:spacevim_simple_mode
let g:spacevim_plugin_groups = ['core']
else

View File

@ -102,7 +102,14 @@ function! s:generate_doc() abort
endfunction
function! s:fix_gruvbox() abort
hi VertSplit guibg=#282828 guifg=#181A1F
if &background ==# 'dark'
hi VertSplit guibg=#282828 guifg=#181A1F
hi EndOfBuffer guibg=#282828 guifg=#282828
else
hi VertSplit guibg=#fbf1c7 guifg=#e7e9e1
hi EndOfBuffer guibg=#fbf1c7 guifg=#fbf1c7
endif
hi SpaceVimLeaderGuiderGroupName cterm=bold ctermfg=175 gui=bold guifg=#d3869b
endfunction
" vim:set et sw=2:

View File

@ -132,6 +132,7 @@ function! SpaceVim#default#SetPlugins() abort
call add(g:spacevim_plugin_groups, 'misc')
call add(g:spacevim_plugin_groups, 'core')
call add(g:spacevim_plugin_groups, 'default')
call add(g:spacevim_plugin_groups, 'unite')
call add(g:spacevim_plugin_groups, 'github')
if has('python3')

View File

@ -14,3 +14,11 @@ function! SpaceVim#layers#checkers#plugins() abort
return plugins
endfunction
function! SpaceVim#layers#checkers#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['e', '.'], 'lopen', 'error-transient-state', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', 'n'], 'lnext', 'next-error', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', 'p'], 'lprevious', 'previous-error', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', 'N'], 'lNext', 'previous-error', 1)
endfunction

View File

@ -173,3 +173,33 @@ function! SpaceVim#layers#colorscheme#plugins() abort
\ ['jacoborus/tender'],
\ ]
endfunction
let s:cs = ['gruvbox', 'molokai', 'onedark', 'jellybeans']
let s:Number = SpaceVim#api#import('data#number')
function! SpaceVim#layers#colorscheme#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['T', 'n'],
\ 'call call(' . string(s:_function('s:cycle_spacevim_theme'))
\ . ', [])', 'cycle-spacevim-theme', 1)
call SpaceVim#mapping#space#def('nnoremap', ['T', 's'], 'Unite colorscheme', 'unite-colorschemes', 1)
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
function! s:cycle_spacevim_theme() abort
let id = s:Number.random(0, len(s:cs))
exe 'colorscheme ' . s:cs[id]
endfunction

View File

@ -9,5 +9,6 @@ function! SpaceVim#layers#default#plugins() abort
endfunction
function! SpaceVim#layers#default#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['f', 's'], 'write', 'save buffer', 1)
call SpaceVim#mapping#space#def('nnoremap', ['f', 'S'], 'wall', 'save all buffer', 1)
endfunction

View File

@ -23,7 +23,7 @@ function! SpaceVim#layers#git#config() abort
nnoremap <silent> <Leader>gp :Gina push<CR>
nnoremap <silent> <Leader>ga :Gina add %<CR>
nnoremap <silent> <Leader>gA :Gina add .<CR>
let g:_spacevim_mappings.g = {'name' : 'git function',
let g:_spacevim_mappings.g = {'name' : '+git function',
\ 'd' : ['Gina diff', 'git diff'],
\ 's' : ['Gina status', 'git status'],
\ 'c' : ['Gina commit', 'git commit'],

View File

@ -66,4 +66,5 @@ function! SpaceVim#layers#incsearch#config() abort
endfunction
noremap <silent><expr> <Space>/ incsearch#go(<SID>config_easyfuzzymotion())
call SpaceVim#mapping#space#def('nnoremap', ['/',], 'call feedkeys("\<Space>/", "m")', 'incsearch-fuzzy', 1)
endfunction

View File

@ -46,6 +46,7 @@ function! SpaceVim#layers#tools#plugins() abort
endfunction
function! SpaceVim#layers#tools#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['a', 'c'], 'Calendar', 'vim calendar', 1)
nmap mm <Plug>BookmarkToggle
nmap mi <Plug>BookmarkAnnotate
nmap ma <Plug>BookmarkShowAll

View File

@ -22,4 +22,24 @@ function! SpaceVim#layers#ui#config() abort
let g:signify_disable_by_default = 0
let g:signify_line_highlight = 0
noremap <silent> <F2> :TagbarToggle<CR>
" Ui toggles
call SpaceVim#mapping#space#def('nnoremap', ['T', 'F'], '<F11>', 'fullscreen-frame', 0)
call SpaceVim#mapping#space#def('nnoremap', ['T', 'm'], 'call call(' . string(s:_function('s:toggle_menu_bar')) . ', [])', 'menu-bar', 1)
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
function! s:toggle_menu_bar() abort
echom 1
endfunction

View File

@ -78,4 +78,5 @@ function! SpaceVim#layers#unite#plugins() abort
endfunction
function! SpaceVim#layers#unite#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['!'], 'Unite output/shellcmd -start-insert', 'shell cmd', 1)
endfunction

View File

@ -207,7 +207,16 @@ function! SpaceVim#mapping#close_term_buffer(...) abort
endif
endif
endif
endfunction
function! SpaceVim#mapping#menu(desc, key, cmd) abort
let description = '➤ '
\. a:desc
\. repeat(' ', 80 - len(a:desc) - len(a:key))
\. a:key
call add(g:unite_source_menu_menus.CustomKeyMaps.command_candidates,
\ [description ,
\ a:cmd])
endfunction
" vim:set et sw=2 cc=80:

View File

@ -394,7 +394,7 @@ function! s:updateStatusline() abort
hi! LeaderGuiderName cterm=bold gui=bold guifg=#282828 guibg=#fe8019
hi! LeaderGuiderSep2 cterm=bold gui=bold guifg=#fe8019 guibg=#3c3836
hi! LeaderGuiderFill guifg=#7c6f64 guibg=#3c3836
exe 'setlocal statusline=%#LeaderGuiderPrompt#\ Leader\ Guide:\ ' .
exe 'setlocal statusline=%#LeaderGuiderPrompt#\ Mapping\ Guide:\ ' .
\ '%#LeaderGuiderSep1#' .
\ '%#LeaderGuiderName#' .
\ SpaceVim#mapping#leader#getName(s:prefix_key)
@ -512,8 +512,15 @@ if !exists("g:leaderGuide_displayfunc")
let g:leaderGuide_displayfunc = [function("s:leaderGuide_display")]
endif
call SpaceVim#mapping#guide#register_prefix_descriptions('\',
\ 'g:_spacevim_mappings')
if get(g:, 'mapleader', '\') == ' '
call SpaceVim#mapping#guide#register_prefix_descriptions(' ',
\ 'g:_spacevim_mappings')
else
call SpaceVim#mapping#guide#register_prefix_descriptions('\',
\ 'g:_spacevim_mappings')
call SpaceVim#mapping#guide#register_prefix_descriptions(' ',
\ 'g:_spacevim_mappings_space')
endif
call SpaceVim#mapping#guide#register_prefix_descriptions(
\ g:spacevim_unite_leader,
\ 'g:_spacevim_mappings_unite')

View File

@ -287,6 +287,8 @@ function! SpaceVim#mapping#leader#getName(key) abort
return '[unite]'
elseif a:key == g:spacevim_denite_leader
return '[denite]'
elseif a:key == ' '
return '[SPC]'
else
return '<leader>'
endif

View File

@ -0,0 +1,57 @@
function! SpaceVim#mapping#space#init() abort
if s:has_map_to_spc()
return
endif
nnoremap <silent><nowait> [SPC] :<c-u>LeaderGuide " "<CR>
nmap <Space> [SPC]
let g:_spacevim_mappings_space = {}
let g:_spacevim_mappings_space['?'] = ['Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings']
let g:_spacevim_mappings_space.t = {'name' : '+Toggles'}
let g:_spacevim_mappings_space.T = {'name' : '+UI toggles/themes'}
let g:_spacevim_mappings_space.a = {'name' : '+Applications'}
let g:_spacevim_mappings_space.b = {'name' : '+Buffers'}
let g:_spacevim_mappings_space.f = {'name' : '+Files'}
nnoremap <silent> [SPC]bn :bnext<CR>
let g:_spacevim_mappings_space.b.n = ['bnext', 'next buffer']
call SpaceVim#mapping#menu('Open next buffer', '[SPC]bn', 'bp')
nnoremap <silent> [SPC]bp :bp<CR>
nnoremap <silent> [SPC]bN :bN<CR>
let g:_spacevim_mappings_space.b.p = ['bp', 'previous buffer']
call SpaceVim#mapping#menu('Open previous buffer', '[SPC]bp', 'bp')
let g:_spacevim_mappings_space.b.N = ['bN', 'previous buffer']
call SpaceVim#mapping#menu('Open previous buffer', '[SPC]bN', 'bp')
let g:_spacevim_mappings_space.e = {'name' : '+Errors'}
let g:_spacevim_mappings_space.B = {'name' : '+Global-uffers'}
nnoremap <silent> [SPC]tn :<C-u>set nu!<CR>
let g:_spacevim_mappings_space.t.n = ['set nu!', 'toggle line number']
call SpaceVim#mapping#menu('toggle line number', '[SPC]tn', 'set nu!')
endfunction
function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort
if s:has_map_to_spc()
return
endif
if a:is_cmd
let cmd = ':<C-u>' . a:cmd . '<CR>'
let lcmd = a:cmd
else
let cmd = a:cmd
let feedkey_m = a:m =~# 'nore' ? 'n' : 'm'
if a:cmd =~? '^<plug>'
let lcmd = 'call feedkeys("\' . a:cmd . '", "' . feedkey_m . '")'
else
let lcmd = 'call feedkeys("' . a:cmd . '", "' . feedkey_m . '")'
endif
endif
exe a:m . ' <silent> [SPC]' . join(a:keys, '') . ' ' . cmd
if len(a:keys) == 2
let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]] = [lcmd, a:desc]
elseif len(a:keys) == 1
let g:_spacevim_mappings_space[a:keys[0]] = [lcmd, a:desc]
endif
call SpaceVim#mapping#menu(a:desc, '[SPC]' . join(a:keys, ''), lcmd)
endfunction
function! s:has_map_to_spc() abort
return get(g:, 'mapleader', '\') == ' '
endfunction

View File

@ -49,6 +49,17 @@ call SpaceVim#mapping#def('nmap', '<leader>8', '<Plug>AirlineSelectTab8', 'Switc
call SpaceVim#mapping#def('nmap', '<leader>9', '<Plug>AirlineSelectTab9', 'Switch to airline tab 9', '', 'window 9')
call SpaceVim#mapping#def('nmap', '<leader>-', '<Plug>AirlineSelectPrevTab', 'Switch to previous airline tag', '', 'window previous')
call SpaceVim#mapping#def('nmap', '<leader>+', '<Plug>AirlineSelectNextTab', 'Switch to next airline tag', '', 'window next')
call SpaceVim#mapping#space#def('nmap', [1], '<Plug>AirlineSelectTab1', 'window 1', 0)
call SpaceVim#mapping#space#def('nmap', [2], '<Plug>AirlineSelectTab2', 'window 2', 0)
call SpaceVim#mapping#space#def('nmap', [3], '<Plug>AirlineSelectTab3', 'window 3', 0)
call SpaceVim#mapping#space#def('nmap', [4], '<Plug>AirlineSelectTab4', 'window 4', 0)
call SpaceVim#mapping#space#def('nmap', [5], '<Plug>AirlineSelectTab5', 'window 5', 0)
call SpaceVim#mapping#space#def('nmap', [6], '<Plug>AirlineSelectTab6', 'window 6', 0)
call SpaceVim#mapping#space#def('nmap', [7], '<Plug>AirlineSelectTab7', 'window 7', 0)
call SpaceVim#mapping#space#def('nmap', [8], '<Plug>AirlineSelectTab8', 'window 8', 0)
call SpaceVim#mapping#space#def('nmap', [9], '<Plug>AirlineSelectTab9', 'window 9', 0)
call SpaceVim#mapping#space#def('nmap', ['-'], '<Plug>AirlineSelectPrevTab', 'window previous', 0)
call SpaceVim#mapping#space#def('nmap', ['+'], '<Plug>AirlineSelectNextTab', 'window next', 0)
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif

View File

@ -58,4 +58,6 @@ augroup startify_map
autocmd FileType startify set scrolloff=0
augroup END
call SpaceVim#mapping#space#def('nnoremap', ['a','s'], 'Startify', 'fancy start screen',1)
" vim:set et sw=2:

View File

@ -7,9 +7,13 @@ syn region LeaderGuideKeys start="\["hs=e+1 end="\]\s"he=s-1
\ contained
syn region LeaderGuideBrackets start="\(^\|\s\+\)\[" end="\]\s\+"
\ contains=LeaderGuideKeys keepend
syn match LeaderGuideGroupName /+[^\[^\]]\+/ contained
syn region LeaderGuideDesc start="^" end="$"
\ contains=LeaderGuideBrackets
\ contains=LeaderGuideBrackets,LeaderGuideGroupName
hi def link LeaderGuideDesc Identifier
hi def link LeaderGuideKeys Type
hi def link LeaderGuideBrackets Delimiter
hi def link LeaderGuideGroupName SpaceVimLeaderGuiderGroupName