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

Merge branch 'dev'

This commit is contained in:
wsdjeg 2017-06-06 20:39:55 +08:00
commit afa34384cb
13 changed files with 257 additions and 41 deletions

View File

@ -325,7 +325,7 @@ let g:spacevim_enable_vimfiler_gitstatus = 0
" Enable/Disable filetypeicon colum in vimfiler buffer, default is 0.
let g:spacevim_enable_vimfiler_filetypeicon = 0
let g:spacevim_smartcloseignorewin = ['__Tagbar__' , 'vimfiler:default']
let g:spacevim_smartcloseignoreft = ['help']
let g:spacevim_smartcloseignoreft = ['help', 'tagbar', 'vimfiler']
let g:spacevim_altmoveignoreft = ['Tagbar' , 'vimfiler']
let g:spacevim_enable_javacomplete2_py = 0
let g:spacevim_src_root = 'E:\sources\'

View File

@ -10,18 +10,10 @@
" @section vim#message, api-vim-message
" @parentsection api
function! SpaceVim#api#vim#compatible#get() abort
return map({
\ 'echo' : '',
\ 'echomsg': '',
\ 'error': '',
\ 'warn': '',
\ },
\ "function('s:' . v:key)"
\ )
endfunction
function! s:echo(hl, msg) abort
let s:self = {}
function! s:self.echo(hl, msg) abort
execute 'echohl' a:hl
try
echo a:msg
@ -30,7 +22,7 @@ function! s:echo(hl, msg) abort
endtry
endfunction
function! s:echomsg(hl, msg) abort
function! s:self.echomsg(hl, msg) abort
execute 'echohl' a:hl
try
for m in split(a:msg, "\n")
@ -41,10 +33,27 @@ function! s:echomsg(hl, msg) abort
endtry
endfunction
function! s:error(msg) abort
call s:echomsg('ErrorMsg', a:msg)
function! s:self.error(msg) abort
call self.echomsg('ErrorMsg', a:msg)
endfunction
function! s:warn(msg) abort
call s:echomsg('WarningMsg', a:msg)
function! s:self.warn(msg) abort
call self.echomsg('WarningMsg', a:msg)
endfunction
function! s:self.confirm(msg) abort
echohl WarningMsg
echon a:msg . '? (y or n) '
echohl NONE
let rst = nr2char(getchar())
if rst =~? 'y' || rst == nr2char(13)
return 1
else
return 0
endif
endfunction
function! SpaceVim#api#vim#message#get() abort
return deepcopy(s:self)
endfunction

View File

@ -23,6 +23,10 @@ function! s:self.get_tree() abort
return self._tree
endfunction
function! s:self.realTabBuffers(id) abort
return filter(copy(tabpagebuflist(a:id)), 'buflisted(v:val) && getbufvar(v:val, "&buftype") == ""')
endfunction
function! SpaceVim#api#vim#tab#get() abort
return deepcopy(s:self)
endfunction

View File

@ -16,6 +16,8 @@ function! SpaceVim#autocmds#init() abort
\ bd|
\ q | endif
autocmd FileType jsp call JspFileTypeInit()
autocmd QuitPre * call SpaceVim#plugins#windowsmanager#UpdateRestoreWinInfo()
autocmd WinEnter * call SpaceVim#plugins#windowsmanager#MarkBaseWin()
autocmd FileType html,css,jsp EmmetInstall
autocmd BufRead,BufNewFile *.pp setfiletype puppet
if g:spacevim_enable_cursorline == 1

View File

@ -67,7 +67,7 @@ function! SpaceVim#layers#core#tabline#get() abort
elseif g:spacevim_buffer_index_type == 4
let id = i
else
let id = s:messletters.bubble_num(i, g:spacevim_buffer_index_type)
let id = s:messletters.circled_num(i, g:spacevim_buffer_index_type)
endif
if g:spacevim_enable_tabline_filetype_icon
let icon = s:file.fticon(name)
@ -112,7 +112,7 @@ function! SpaceVim#layers#core#tabline#get() abort
elseif g:spacevim_buffer_index_type == 4
let id = index(s:buffers, i) + 1
else
let id = s:messletters.bubble_num(index(s:buffers, i) + 1, g:spacevim_buffer_index_type)
let id = s:messletters.circled_num(index(s:buffers, i) + 1, g:spacevim_buffer_index_type)
endif
if g:spacevim_enable_tabline_filetype_icon
let icon = s:file.fticon(name)

View File

@ -72,9 +72,8 @@ function! SpaceVim#layers#default#config() abort
call SpaceVim#mapping#space#def('nmap', ['j', 'J'], '<Plug>(easymotion-s2)', 'jump to a suite of two characters', 0)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'k'], 'j==', 'go to next line and indent', 0)
call SpaceVim#mapping#space#def('nmap', ['j', 'l'], '<Plug>(easymotion-bd-jk)', 'jump to a line', 0)
call SpaceVim#mapping#space#def('nmap', ['j', 'u'], '<Plug>(easymotion-bd-jk)', 'jump to a line', 0)
call SpaceVim#mapping#space#def('nmap', ['j', 'v'], '<Plug>(easymotion-bd-jk)', 'jump to a line', 0)
call SpaceVim#mapping#space#def('nmap', ['j', 'w'], '<Plug>(easymotion-bd-jk)', 'jump to a line', 0)
call SpaceVim#mapping#space#def('nmap', ['j', 'w'], '<Plug>(easymotion-bd-w)', 'jump to a word', 0)
call SpaceVim#mapping#space#def('nmap', ['j', 'q'], '<Plug>(easymotion-bd-jk)', 'jump to a line', 0)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'n'], "i\<cr>\<esc>", 'sp-newline', 0)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'o'], "i\<cr>\<esc>k$", 'open-line', 0)
@ -90,9 +89,41 @@ function! SpaceVim#layers#default#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['w', 'R'], 'call call('
\ . string(s:_function('s:previous_window')) . ', [])',
\ 'rotate windows backward', 1)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'u'], 'call call('
\ . 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', '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()',
\ 'kill-this-buffer', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', '<C-d>'], 'call SpaceVim#mapping#clearBuffers()', 'kill-other-buffers', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'e'], 'call call('
\ . string(s:_function('s:safe_erase_buffer')) . ', [])',
\ 'safe-erase-buffer', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'h'], 'Startify', 'home', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'm'], 'call call('
\ . string(s:_function('s:open_message_buffer')) . ', [])',
\ 'open-message-buffer', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'P'], 'normal! ggdG"+P', 'copy-clipboard-to-whole-buffer', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'R'], 'call call('
\ . string(s:_function('s:safe_revert_buffer')) . ', [])',
\ 'safe-revert-buffer', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'Y'], 'normal! ggVG"+y``', 'copy-whole-buffer-to-clipboard', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'w'], 'setl readonly!', 'read-only-mode', 1)
let g:_spacevim_mappings_space.b.N = {'name' : '+New empty buffer'}
call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'h'], 'topleft vertical new', 'new-empty-buffer-left', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'j'], 'rightbelow new', 'new-empty-buffer-below', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'k'], 'new', 'new-empty-buffer-above', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'l'], 'rightbelow vertical new', 'new-empty-buffer-right', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'n'], 'enew', 'new-empty-buffer', 1)
" file mappings
call SpaceVim#mapping#space#def('nnoremap', ['f', 'b'], 'Unite vim_bookmarks', 'unite-filtered-bookmarks', 1)
endfunction
let s:file = SpaceVim#api#import('file')
let s:MESSAGE = SpaceVim#api#import('vim#message')
function! s:next_file() abort
let dir = expand('%:p:h')
@ -193,3 +224,33 @@ else
return function(substitute(a:fstr, 's:', s:_s, 'g'))
endfunction
endif
function! s:jump_to_url() abort
let g:EasyMotion_re_anywhere = 'http[s]*://'
call feedkeys("\<Plug>(easymotion-jumptoanywhere)")
endfunction
function! s:safe_erase_buffer() abort
if s:MESSAGE.confirm('Erase content of buffer ' . expand('%:t'))
normal! ggdG
endif
redraw!
endfunction
function! s:open_message_buffer() abort
vertical topleft edit __Message_Buffer__
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonumber norelativenumber
setf message
normal! ggdG
silent put =execute(':message')
normal! G
setlocal nomodifiable
nnoremap <silent> <buffer> q :silent bd<CR>
endfunction
function! s:safe_revert_buffer() abort
if s:MESSAGE.confirm('Revert buffer form ' . expand('%:p'))
edit!
endif
redraw!
endfunction

View File

@ -27,6 +27,7 @@ function! SpaceVim#layers#incsearch#plugins() abort
call add(plugins, ['haya14busa/incsearch.vim', {'merged' : 0}])
call add(plugins, ['haya14busa/incsearch-fuzzy.vim', {'merged' : 0}])
call add(plugins, ['haya14busa/vim-asterisk', {'merged' : 0}])
call add(plugins, ['osyo-manga/vim-over', {'merged' : 0}])
call add(plugins, ['haya14busa/incsearch-easymotion.vim', {'merged' : 0}])
return plugins
endfunction
@ -36,7 +37,7 @@ function! SpaceVim#layers#incsearch#config() abort
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
set hlsearch
let g:incsearch#auto_nohlsearch = 1
let g:incsearch#auto_nohlsearch = get(g:, 'incsearch#auto_nohlsearch', 1)
noremap <silent> n :call <SID>update_search_index('n')<cr>
noremap <silent> N :call <SID>update_search_index('N')<cr>
map * <Plug>(incsearch-nohl-*)

View File

@ -129,15 +129,17 @@ function! SpaceVim#mapping#gd() abort
endfunction
function! SpaceVim#mapping#clearBuffers() abort
let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val)')
for i in blisted
if i != bufnr('%')
try
exe 'bw ' . i
catch
endtry
endif
endfor
if confirm('Kill all other buffers?', "&Yes\n&No\n&Cancel") == 1
let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val)')
for i in blisted
if i != bufnr('%')
try
exe 'bw ' . i
catch
endtry
endif
endfor
endif
endfunction
function! SpaceVim#mapping#split_previous_buffer() abort
@ -209,6 +211,18 @@ function! SpaceVim#mapping#close_term_buffer(...) abort
endif
endfunction
function! SpaceVim#mapping#kill_visible_buffer_choosewin() abort
ChooseWin
let nr = bufnr('%')
for i in range(1, winnr('$'))
if winbufnr(i) == nr
exe i . 'wincmd w'
enew
endif
endfor
exe 'bwipeout ' . nr
endfunction
function! SpaceVim#mapping#menu(desc, key, cmd) abort
let description = '➤ '
\. a:desc

View File

@ -337,7 +337,6 @@ function! s:handle_input(input) " {{{
call s:start_buffer()
else
let s:prefix_key_inp = ''
doautocmd WinEnter
call feedkeys(s:vis.s:reg.s:count, 'ti')
redraw!
try
@ -428,7 +427,7 @@ endfunction
function! s:winclose() " {{{
noautocmd execute s:gwin.'wincmd w'
if s:gwin == winnr()
close
noautocmd close
redraw!
exe s:winres
let s:gwin = -1

View File

@ -55,15 +55,14 @@ function! SpaceVim#mapping#space#init() abort
call SpaceVim#mapping#space#def('nnoremap', ['w', '='], 'wincmd =', 'balance-windows', 1)
call SpaceVim#mapping#space#def('nnoremap', ['w', 'w'], 'wincmd w', 'cycle and focus between windows', 1)
call SpaceVim#mapping#space#def('nnoremap', ['w', 'W'], 'ChooseWin', 'select window', 1)
call SpaceVim#mapping#space#def('nnoremap', ['w', 'u'], 'call SpaceVim#plugins#windowsmanager#UndoQuitWin()', 'undo quieted window', 1)
call SpaceVim#mapping#space#def('nnoremap', ['w', 'U'], 'call SpaceVim#plugins#windowsmanager#RedoQuitWin()', 'redo quieted window', 1)
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/Encoding'}
let g:_spacevim_mappings_space.B = {'name' : '+Global-buffers'}
nnoremap <silent> [SPC]tn :<C-u>setlocal nonumber! norelativenumber!<CR>

View File

@ -0,0 +1,83 @@
let s:TAB = SpaceVim#api#import('vim#tab')
let s:restore_windows_stack = []
let s:redo_stack = []
let s:unmarked = 0
function! s:get_window_restore_data() abort
let win_data = {
\ 'bufname': fnamemodify(bufname('%'), ':p'),
\ 'tabpagenr': tabpagenr(),
\ 'view': winsaveview(),
\ 'newtab':0,
\ 'oldwinid' : -1,
\ 'same_w' : 0,
\ }
return win_data
endfunction
function! SpaceVim#plugins#windowsmanager#UpdateRestoreWinInfo() abort
if !&buflisted
return
endif
let s:unmarked = 1
let win_data = s:get_window_restore_data()
if len(tabpagebuflist()) == 1
let win_data.newtab = 1
let win_data.open_command = (tabpagenr() - 1).'tabnew'
else
if winwidth(winnr()) == &columns
let win_data.same_w = 1
endif
let win_data.oldwinid = winnr()
endif
call add(s:restore_windows_stack, win_data)
let s:redo_stack = []
endfunction
function! SpaceVim#plugins#windowsmanager#UndoQuitWin()
if empty(s:restore_windows_stack)
return
endif
let win_data = remove(s:restore_windows_stack, -1)
if win_data.newtab
exe win_data.open_command . ' ' . win_data.bufname
else
exe win_data.open_command
endif
call add(s:redo_stack, [tabpagenr(), winnr()])
endfunction
function! SpaceVim#plugins#windowsmanager#RedoQuitWin()
if !empty(s:redo_stack)
let [tabpage, winnr] = remove(s:redo_stack, -1)
exe 'tabnext' . tabpage
exe winnr . 'wincmd w'
quit
endif
endfunction
function! SpaceVim#plugins#windowsmanager#MarkBaseWin()
if s:unmarked
let win_data = s:restore_windows_stack[-1]
if win_data.same_w
" split
if win_data.oldwinid == winnr()
let win_data.open_command = 'topleft split ' . win_data.bufname
else
let win_data.open_command = 'rightbelow split ' . win_data.bufname
endif
else
" vsplit
if win_data.oldwinid == winnr()
let win_data.open_command = 'topleft vsplit ' . win_data.bufname
else
let win_data.open_command = 'rightbelow vsplit ' . win_data.bufname
endif
endif
let s:unmarked = 0
endif
endfunction

View File

@ -46,7 +46,7 @@ fu! zvim#util#SmartClose() abort
endfor
if num == 1
else
close
quit
endif
endf

View File

@ -57,6 +57,9 @@ title: "Documentation"
* [Window manipulation key bindings](#window-manipulation-key-bindings)
* [Buffers and Files](#buffers-and-files)
* [Buffers manipulation key bindings](#buffers-manipulation-key-bindings)
* [Create a new empty buffer](#create-a-new-empty-buffer)
* [Special Buffers](#special-buffers)
* [Files manipulations key bindings](#files-manipulations-key-bindings)
* [Auto-saving](#auto-saving)
* [Searching](#searching)
* [Editing](#editing)
@ -650,9 +653,9 @@ Key Binding | Description
`SPC j k` | jump to next line and indent it using auto-indent rules
`SPC j l` | jump to a line with avy (easymotion)
`SPC j q` | show the dumb-jump quick look tooltip (TODO)
`SPC j u` | jump to a URL in the current buffer (TODO)
`SPC j u` | jump to a URL in the current window
`SPC j v` | jump to the definition/declaration of an Emacs Lisp variable (TODO)
`SPC j w` | jump to a word in the current buffer (easymotion)(TODO)
`SPC j w` | jump to a word in the current buffer (easymotion)
##### Joining and splitting
@ -729,6 +732,47 @@ Key Binding | Description
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 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)
`SPC b D` | kill a visible buffer using vim-choosewin
`SPC u SPC b D` | kill a visible buffer and its window using ace-window(TODO)
`SPC b C-d` | kill other buffers
`SPC b C-D` | kill buffers using a regular expression(TODO)
`SPC b e` | erase the content of the buffer (ask for confirmation)
`SPC b h` | open *SpaceVim* home buffer
`SPC b n` | switch to next buffer avoiding special buffers
`SPC b m` | open *Messages* buffer
`SPC u SPC b m` | kill all buffers and windows except the current one(TODO)
`SPC b p` | switch to previous buffer avoiding special buffers
`SPC b P` | copy clipboard and replace buffer (useful when pasting from a browser)
`SPC b R` | revert the current buffer (reload from disk)
`SPC b s` | switch to the *scratch* buffer (create it if needed)
`SPC b w` | toggle read-only (writable state)
`SPC b Y` | copy whole buffer to clipboard (useful when copying to a browser)
`z f` | Make current function or comments visible in buffer as much as possible (TODO)
##### Create a new empty buffer
Key Binding | Description
----------- | -----------
`SPC b N h` | create new empty buffer in a new window on the left
`SPC b N j` | create new empty buffer in a new window at the bottom
`SPC b N k` | create new empty buffer in a new window above
`SPC b N l` | create new empty buffer in a new window below
`SPC b N n` | create new empty buffer in current window
##### Special Buffers
In SpaceVim, there are many special buffers, these buffers are created by plugins or SpaceVim isself. and all of this buffers are not listed.
##### Files manipulations key bindings
Files manipulation commands (start with f):
### Auto-saving
### Searching
@ -810,9 +854,9 @@ Key | Description
### c/c++ support
1. code completion: autocompletion and fuzzy match.
![2017-02-01_1359x720](https://cloud.githubusercontent.com/assets/13142418/22505960/df9068de-e8b8-11e6-943e-d79ceca095f1.png)
![completion-fuzzy-match](https://cloud.githubusercontent.com/assets/13142418/22505960/df9068de-e8b8-11e6-943e-d79ceca095f1.png)
2. syntax check: Asynchronous linting and make framework.
![2017-02-01_1359x722](https://cloud.githubusercontent.com/assets/13142418/22506340/e28b4782-e8ba-11e6-974b-ca29574dcc1f.png)
![syntax-check](https://cloud.githubusercontent.com/assets/13142418/22506340/e28b4782-e8ba-11e6-974b-ca29574dcc1f.png)
### go support