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

Merge cmdlinemenu api, fix conflict

This commit is contained in:
wsdjeg 2017-03-12 16:38:01 +08:00
commit 7f4850c632
5 changed files with 222 additions and 67 deletions

View File

@ -10,7 +10,7 @@
" @section Introduction, intro
" @stylized spacevim
" @library
" @order intro version dicts functions exceptions layers faq
" @order intro version dicts functions exceptions layers api faq
" SpaceVim is a bundle of custom settings and plugins with a modular
" configuration for Vim. It was inspired by Spacemacs.
"
@ -256,7 +256,7 @@ let g:spacevim_hosts_url
let g:spacevim_wildignore
\ = '*/tmp/*,*.so,*.swp,*.zip,*.class,tags,*.jpg,
\*.ttf,*.TTF,*.png,*/target/*,
\.git,.svn,.hg,.DS_Store'
\.git,.svn,.hg,.DS_Store,*.svg'
function! SpaceVim#loadCustomConfig() abort
let custom_confs_old = SpaceVim#util#globpath(getcwd(), '.local.vim')

View File

@ -1,3 +1,14 @@
""
" @section API, api
" SpaceVim contains a variety of public apis. here is a list of all the apis.
" @subsection usage
" This is just an example, and it works well in old version vim.
" >
" let s:json = SpaceVim#api#import('data#json')
" let rst = s:json.json_encode(onject)
" let rst = s:json.json_decode(string)
" <
function! SpaceVim#api#import(name) abort
let p = {}
try

View File

@ -0,0 +1,106 @@
let s:api = {}
function! s:parseInput(char) abort
if a:char == 27
return ''
else
return a:char
endif
endfunction
function! s:nextItem(list, item) abort
let id = index(a:list, a:item)
if id == len(a:list) - 1
return a:list[0]
else
return a:list[id + 1]
endif
endfunction
function! s:previousItem(list, item) abort
let id = index(a:list, a:item)
if id == 0
return a:list[len(a:list) - 1]
else
return a:list[id - 1]
endif
endfunction
function! s:parseItems(items) abort
let items = {}
for item in a:items
let id = index(a:items, item) + 1
let items[id] = ['(' . id . ')' . item[0], item[1]]
endfor
return items
endfunction
" items should be a list of [name, funcrc or string]
""
" @section cmdlinemenu, api-cmdlinemenu
" @parentsection api
" menu({items})
"
" Create a cmdline selection menu from a list of {items}, each item should be a
" list of two value in it, first one is the description, and the next one
" should be a funcrc.
function! s:menu(items) abort
let saved_more = &more
set nomore
let items = s:parseItems(a:items)
let selected = '1'
let exit = 0
let indent = repeat(' ', 7)
while !exit
let menu = "Cmdline menu: Use j/k/enter and the shortcuts indicated\n"
for id in keys(items)
let m = items[id]
if type(m) == type([])
let m = m[0]
endif
if id == selected
let menu .= indent . '>' . items[id][0] . "\n"
else
let menu .= indent . ' ' . items[id][0] . "\n"
endif
endfor
echo menu[:-2]
let nr = getchar()
if s:parseInput(nr) ==# '' || nr == 3
let exit = 1
redraw
elseif index(keys(items), nr2char(nr)) != -1 || nr == 13
if nr != 13
let selected = nr2char(nr)
endif
let Value = items[selected][1]
redraw
if type(Value) == 2
call call(Value, [])
elseif type(Value) == type('') && !empty(Value)
execute Value
endif
let exit = 1
elseif nr2char(nr) ==# 'j'
let selected = s:nextItem(keys(items), selected)
redraw
elseif nr2char(nr) ==# 'k'
let selected = s:previousItem(keys(items), selected)
redraw
endif
endwhile
let &more = saved_more
endfunction
let s:api['menu'] = function('s:menu')
function! SpaceVim#api#cmdlinemenu#get() abort
return deepcopy(s:api)
endfunction
" vim:set et sw=2 cc=80:

View File

@ -1,69 +1,84 @@
function! SpaceVim#layers#tools#plugins() abort
return [
\ ['tpope/vim-scriptease'],
\ ['wsdjeg/vim-cheat', { 'on_cmd' : 'Cheat'}],
\ ['wsdjeg/SourceCounter.vim', { 'on_cmd' : 'SourceCounter'}],
\ ['junegunn/goyo.vim', { 'on_cmd' : 'Goyo', 'loadconf' : 1}],
\ ['junegunn/limelight.vim', { 'on_cmd' : 'Limelight'}],
\ ['Yggdroot/LeaderF', {'merged' : 0, 'on_cmd' : 'LeaderF'}],
\ ['MattesGroeger/vim-bookmarks', { 'on_map' : '<Plug>Bookmark', 'loadconf_before' : 1}],
\ ['simnalamburt/vim-mundo', { 'on_cmd' : 'MundoToggle'}],
\ ['mhinz/vim-grepper' , { 'on_cmd' : 'Grepper', 'loadconf' : 1} ],
\ ['tpope/vim-projectionist',{'on_cmd':['A','AS','AV','AT','AD','Cd','Lcd','ProjectDo']}],
\ ['ntpeters/vim-better-whitespace',{'on_cmd' : 'StripWhitespace'}],
\ ['junegunn/rainbow_parentheses.vim',{'on_cmd' : 'RainbowParentheses'}],
\ ['tyru/open-browser.vim', {
\'on_cmd' : ['OpenBrowserSmartSearch','OpenBrowser','OpenBrowserSearch'],
\'on_map' : '<Plug>(openbrowser-',
\ 'loadconf' : 1,
\}],
\ ['godlygeek/tabular', { 'on_cmd': 'Tabularize'}],
\ ['airblade/vim-gitgutter',{'on_cmd' : 'GitGutterEnable'}],
\ ['itchyny/calendar.vim', { 'on_cmd' : 'Calendar'}],
\ ['wsdjeg/Mysql.vim', { 'on_cmd' : 'SQLGetConnection'}],
\ ['wsdjeg/job.vim', { 'merged' : 0}],
\ ['junegunn/fzf', { 'on_cmd' : 'FZF'}],
\ ['ianva/vim-youdao-translater', { 'on_cmd' : ['Ydv','Ydc','Yde']}],
\ ['TaskList.vim', { 'on_cmd' : 'TaskList'}],
\ ['MarcWeber/vim-addon-mw-utils'],
\ ['taglist.vim',{'on_cmd' : 'TlistToggle', 'loadconf' : 1}],
\ ['scrooloose/nerdtree',{'on_cmd' : 'NERDTreeToggle', 'loadconf' : 1}],
\ ['Xuyuanp/nerdtree-git-plugin'],
\ ]
return [
\ ['tpope/vim-scriptease'],
\ ['wsdjeg/vim-cheat', { 'on_cmd' : 'Cheat'}],
\ ['wsdjeg/SourceCounter.vim', { 'on_cmd' : 'SourceCounter'}],
\ ['junegunn/goyo.vim', { 'on_cmd' : 'Goyo',
\ 'loadconf' : 1}],
\ ['junegunn/limelight.vim', { 'on_cmd' : 'Limelight'}],
\ ['Yggdroot/LeaderF', { 'on_cmd' : 'LeaderF',
\ 'merged' : 0}],
\ ['MattesGroeger/vim-bookmarks', { 'on_map' : '<Plug>Bookmark',
\ 'loadconf_before' : 1}],
\ ['simnalamburt/vim-mundo', { 'on_cmd' : 'MundoToggle'}],
\ ['mhinz/vim-grepper' , { 'on_cmd' : 'Grepper',
\ 'loadconf' : 1} ],
\ ['tpope/vim-projectionist', { 'on_cmd' : ['A', 'AS', 'AV',
\ 'AT', 'AD', 'Cd', 'Lcd', 'ProjectDo']}],
\ ['ntpeters/vim-better-whitespace', { 'on_cmd' : 'StripWhitespace'}],
\ ['junegunn/rainbow_parentheses.vim',
\ { 'on_cmd' : 'RainbowParentheses'}],
\ ['tyru/open-browser.vim', {
\'on_cmd' : ['OpenBrowserSmartSearch', 'OpenBrowser',
\ 'OpenBrowserSearch'],
\'on_map' : '<Plug>(openbrowser-',
\ 'loadconf' : 1,
\}],
\ ['godlygeek/tabular', { 'on_cmd' : 'Tabularize'}],
\ ['airblade/vim-gitgutter', { 'on_cmd' : 'GitGutterEnable'}],
\ ['itchyny/calendar.vim', { 'on_cmd' : 'Calendar'}],
\ ['wsdjeg/Mysql.vim', { 'on_cmd' : 'SQLGetConnection'}],
\ ['wsdjeg/job.vim', { 'merged' : 0}],
\ ['junegunn/fzf', { 'on_cmd' : 'FZF'}],
\ ['ianva/vim-youdao-translater', { 'on_cmd' : ['Ydv','Ydc','Yde']}],
\ ['TaskList.vim', { 'on_cmd' : 'TaskList'}],
\ ['MarcWeber/vim-addon-mw-utils'],
\ ['taglist.vim', { 'on_cmd' : 'TlistToggle', 'loadconf' : 1}],
\ ['scrooloose/nerdtree', { 'on_cmd' : 'NERDTreeToggle',
\ 'loadconf' : 1}],
\ ['Xuyuanp/nerdtree-git-plugin'],
\ ]
endfunction
function! SpaceVim#layers#tools#config() abort
nmap mm <Plug>BookmarkToggle
nmap mi <Plug>BookmarkAnnotate
nmap ma <Plug>BookmarkShowAll
nmap mn <Plug>BookmarkNext
nmap mp <Plug>BookmarkPrev
nnoremap <silent> <F7> :MundoToggle<CR>
augroup rainbow_lisp
autocmd!
autocmd FileType lisp,clojure,scheme,java RainbowParentheses
augroup END
let g:rainbow#max_level = 16
let g:rainbow#pairs = [['(', ')'], ['[', ']'],['{','}']]
" List of colors that you do not want. ANSI code or #RRGGBB
let g:rainbow#blacklist = [233, 234]
nnoremap <Leader>fz :FZF<CR>
vnoremap <silent> <C-l> <Esc>:Ydv<CR>
nnoremap <silent> <C-l> <Esc>:Ydc<CR>
map <unique> <Leader>td <Plug>TaskList
noremap <silent> <F8> :TlistToggle<CR>
function! OpenOrCloseNERDTree() abort
exec 'normal! A'
endfunction
if g:spacevim_filemanager ==# 'nerdtree'
noremap <silent> <F3> :NERDTreeToggle<CR>
endif
let g:NERDTreeWinPos= get(g:, 'NERDTreeWinPos', 'right')
let g:NERDTreeWinSize=get(g:, 'NERDTreeWinSize', 31)
let g:NERDTreeChDirMode=get(g:, 'NERDTreeChDirMode', 1)
autocmd bufenter * if (winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree()) | q | endif
augroup nerdtree_zvim
autocmd!
autocmd FileType nerdtree nnoremap <silent><buffer><Space> :call OpenOrCloseNERDTree()<cr>
augroup END
nmap mm <Plug>BookmarkToggle
nmap mi <Plug>BookmarkAnnotate
nmap ma <Plug>BookmarkShowAll
nmap mn <Plug>BookmarkNext
nmap mp <Plug>BookmarkPrev
nnoremap <silent> <F7> :MundoToggle<CR>
augroup rainbow_lisp
autocmd!
autocmd FileType lisp,clojure,scheme,java RainbowParentheses
augroup END
let g:rainbow#max_level = 16
let g:rainbow#pairs = [['(', ')'], ['[', ']'],['{','}']]
" List of colors that you do not want. ANSI code or #RRGGBB
let g:rainbow#blacklist = [233, 234]
nnoremap <Leader>fz :FZF<CR>
vnoremap <silent> <C-l> <Esc>:Ydv<CR>
nnoremap <silent> <C-l> <Esc>:Ydc<CR>
map <unique> <Leader>td <Plug>TaskList
noremap <silent> <F8> :TlistToggle<CR>
function! OpenOrCloseNERDTree() abort
exec 'normal! A'
endfunction
if g:spacevim_filemanager ==# 'nerdtree'
noremap <silent> <F3> :NERDTreeToggle<CR>
endif
let g:NERDTreeWinPos='right'
let g:NERDTreeWinSize=31
let g:NERDTreeChDirMode=1
augroup nerdtree_zvim
autocmd!
autocmd bufenter *
\ if (winnr('$') == 1 && exists('b:NERDTree')
\ && b:NERDTree.isTabTree())
\| q
\| endif
autocmd FileType nerdtree nnoremap <silent><buffer><Space>
\ :call OpenOrCloseNERDTree()<cr>
augroup END
endfunction
" vim:set et sw=2 cc=80:

View File

@ -42,7 +42,9 @@ CONTENTS *SpaceVim-contents*
19. operator...................................|SpaceVim-layer-operator|
20. shell.........................................|SpaceVim-layer-shell|
21. tmux...........................................|SpaceVim-layer-tmux|
6. FAQ........................................................|SpaceVim-faq|
6. API........................................................|SpaceVim-api|
1. cmdlinemenu................................|SpaceVim-api-cmdlinemenu|
7. FAQ........................................................|SpaceVim-faq|
==============================================================================
INTRODUCTION *SpaceVim-intro*
@ -782,6 +784,27 @@ MAPPINGS
<C-l> normal Switch to vim/tmux pane in right direction
<
==============================================================================
API *SpaceVim-api*
SpaceVim contains a variety of public apis. here is a list of all the apis.
USAGE
This is just an example, and it works well in old version vim.
>
let s:json = SpaceVim#api#import('data#json')
let rst = s:json.json_encode(onject)
let rst = s:json.json_decode(string)
<
==============================================================================
CMDLINEMENU *SpaceVim-api-cmdlinemenu*
menu({items})
Create a cmdline selection menu from a list of {items}, each item should be a
list of two value in it, first one is the description, and the next one should
be a funcrc.
==============================================================================
FAQ *SpaceVim-faq*