mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 20:20:05 +08:00
Merge branch 'dev' into spacevim_zh_cn
This commit is contained in:
commit
f3f6ec4ef3
@ -10,7 +10,7 @@
|
||||
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
|
||||
[![Doc](https://img.shields.io/badge/doc-%3Ah%20SpaceVim-orange.svg?style=flat-square)](doc/SpaceVim.txt)
|
||||
|
||||
SpaceVim is a community-driven vim distribution that seeks to provide layer featur, escpecially for neovim. It offers a variety of layers to choose from. to create a suitable vim development environment, you just need to select the required layers.
|
||||
SpaceVim is a community-driven vim distribution that seeks to provide layer feature, escpecially for neovim. It offers a variety of layers to choose from. to create a suitable vim development environment, you just need to select the required layers.
|
||||
|
||||
See the [documentation](https://spacevim.org/documentation) or [the list of layers](http://spacevim.org/layers/) for more information.
|
||||
|
||||
@ -147,10 +147,11 @@ curl -sLf https://spacevim.org/install.sh | bash
|
||||
```
|
||||
before use SpaceVim, you should install the plugin by `call dein#install()`
|
||||
|
||||
Installation of neovim/vim with python support:
|
||||
> [neovim installation](https://github.com/neovim/neovim/wiki/Installing-Neovim)
|
||||
SpaceVim required Vim7.4 above or neovim, here is the installation of neovim/vim with python support:
|
||||
|
||||
> [Building Vim from source](https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source)
|
||||
- [neovim installation](https://github.com/neovim/neovim/wiki/Installing-Neovim)
|
||||
|
||||
- [Building Vim from source](https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source)
|
||||
|
||||
for more info about the install script, please check:
|
||||
|
||||
|
@ -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,73 @@ 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'
|
||||
" privite options
|
||||
let g:_spacevim_mappings = {}
|
||||
" TODO merge leader guide
|
||||
|
||||
if !exists('g:leaderGuide_vertical')
|
||||
let g:leaderGuide_vertical = 0
|
||||
endif
|
||||
|
||||
let g:spacevim_leader_guide_vertical = 0
|
||||
|
||||
if !exists('g:leaderGuide_sort_horizontal')
|
||||
let g:leaderGuide_sort_horizontal = 0
|
||||
endif
|
||||
|
||||
let g:spacevim_leader_guide_sort_horizontal = 0
|
||||
|
||||
if !exists('g:leaderGuide_position')
|
||||
let g:leaderGuide_position = 'botright'
|
||||
endif
|
||||
|
||||
let g:spacevim_leader_guide_position = 'botright'
|
||||
|
||||
if !exists('g:leaderGuide_run_map_on_popup')
|
||||
let g:leaderGuide_run_map_on_popup = 1
|
||||
endif
|
||||
|
||||
let g:spacevim_leader_guide_run_map_on_popup = 1
|
||||
|
||||
if !exists("g:leaderGuide_hspace")
|
||||
let g:leaderGuide_hspace = 5
|
||||
endif
|
||||
|
||||
let g:spacevim_leader_guide_hspace = 5
|
||||
|
||||
if !exists("g:leaderGuide_flatten")
|
||||
let g:leaderGuide_flatten = 1
|
||||
endif
|
||||
|
||||
let g:spacevim_leader_guide_flatten = 1
|
||||
|
||||
if !exists("g:leaderGuide_default_group_name")
|
||||
let g:leaderGuide_default_group_name = ""
|
||||
endif
|
||||
|
||||
let g:spacevim_leader_guide_default_group_name = ""
|
||||
|
||||
if !exists("g:leaderGuide_max_size")
|
||||
let g:leaderGuide_max_size = 0
|
||||
endif
|
||||
|
||||
let g:spacevim_leader_guide_max_size = 0
|
||||
|
||||
if !exists("g:leaderGuide_submode_mappings")
|
||||
let g:leaderGuide_submode_mappings = {'<C-C>': "win_close"}
|
||||
endif
|
||||
|
||||
let g:spacevim_leader_guide_submode_mappings = {'<C-C>': "win_close"}
|
||||
|
||||
if !SpaceVim#mapping#guide#has_configuration()
|
||||
let g:leaderGuide_map = {}
|
||||
call SpaceVim#mapping#guide#register_prefix_descriptions('', 'g:leaderGuide_map')
|
||||
endif
|
||||
|
||||
|
||||
command -nargs=1 LeaderGuide call SpaceVim#mapping#guide#start_by_prefix('0', <args>)
|
||||
"====
|
||||
|
||||
function! SpaceVim#loadCustomConfig() abort
|
||||
let custom_confs_old = SpaceVim#util#globpath(getcwd(), '.local.vim')
|
||||
@ -340,6 +406,16 @@ function! SpaceVim#end() abort
|
||||
silent exec 'lan ' . g:spacevim_language
|
||||
endif
|
||||
|
||||
if g:spacevim_realtime_leader_guide
|
||||
nnoremap <silent><nowait> <leader> :<c-u>LeaderGuide get(g:, 'mapleader', '\')<CR>
|
||||
vnoremap <silent> <leader> :<c-u>LeaderGuideVisual get(g:, 'mapleader', '\')<CR>
|
||||
endif
|
||||
let g:leaderGuide_max_size = 15
|
||||
let g:leaderGuide_submode_mappings =
|
||||
\ { '<C-C>': 'win_close', '<PageDown>': 'page_down', '<PageUp>': 'page_up'}
|
||||
let g:_spacevim_mappings.g = {'name' : 'git function',
|
||||
\ 'd' : ['Gita diff', 'git diff'],
|
||||
\ }
|
||||
call SpaceVim#plugins#load()
|
||||
endfunction
|
||||
|
||||
|
@ -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
|
||||
|
106
autoload/SpaceVim/api/cmdlinemenu.vim
Normal file
106
autoload/SpaceVim/api/cmdlinemenu.vim
Normal 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:
|
99
autoload/SpaceVim/api/data/dict.vim
Normal file
99
autoload/SpaceVim/api/data/dict.vim
Normal file
@ -0,0 +1,99 @@
|
||||
function! SpaceVim#api#data#dict#get() abort
|
||||
return map({'make' : '',
|
||||
\ },
|
||||
\ "function('s:' . v:key)"
|
||||
\ )
|
||||
endfunction
|
||||
|
||||
function! s:make(keys, values, ...) abort
|
||||
let dict = {}
|
||||
let fill = a:0 ? a:1 : 0
|
||||
for i in range(len(a:keys))
|
||||
let key = type(a:keys[i]) == type('') ? a:keys[i] : string(a:keys[i])
|
||||
if key ==# ''
|
||||
throw "SpaceVim API: data#dict: Can't use an empty string for key."
|
||||
endif
|
||||
let dict[key] = get(a:values, i, fill)
|
||||
endfor
|
||||
return dict
|
||||
endfunction
|
||||
|
||||
" Swaps keys and values
|
||||
function! s:swap(dict) abort
|
||||
return s:make(values(a:dict), keys(a:dict))
|
||||
endfunction
|
||||
|
||||
" Makes a index dict from a list
|
||||
function! s:make_index(list, ...) abort
|
||||
let value = a:0 ? a:1 : 1
|
||||
return s:make(a:list, [], value)
|
||||
endfunction
|
||||
|
||||
function! s:pick(dict, keys) abort
|
||||
let new_dict = {}
|
||||
for key in a:keys
|
||||
if has_key(a:dict, key)
|
||||
let new_dict[key] = a:dict[key]
|
||||
endif
|
||||
endfor
|
||||
return new_dict
|
||||
endfunction
|
||||
|
||||
function! s:omit(dict, keys) abort
|
||||
let new_dict = copy(a:dict)
|
||||
for key in a:keys
|
||||
if has_key(a:dict, key)
|
||||
call remove(new_dict, key)
|
||||
endif
|
||||
endfor
|
||||
return new_dict
|
||||
endfunction
|
||||
|
||||
function! s:clear(dict) abort
|
||||
for key in keys(a:dict)
|
||||
call remove(a:dict, key)
|
||||
endfor
|
||||
return a:dict
|
||||
endfunction
|
||||
|
||||
function! s:_max_by(dict, expr) abort
|
||||
let dict = s:swap(map(copy(a:dict), a:expr))
|
||||
let key = dict[max(keys(dict))]
|
||||
return [key, a:dict[key]]
|
||||
endfunction
|
||||
|
||||
function! s:max_by(dict, expr) abort
|
||||
if empty(a:dict)
|
||||
throw 'SpaceVim API: data#dict: Empty dictionary'
|
||||
endif
|
||||
return s:_max_by(a:dict, a:expr)
|
||||
endfunction
|
||||
|
||||
function! s:min_by(dict, expr) abort
|
||||
if empty(a:dict)
|
||||
throw 'SpaceVim API: data#dict: Empty dictionary'
|
||||
endif
|
||||
return s:_max_by(a:dict, '-(' . a:expr . ')')
|
||||
endfunction
|
||||
|
||||
function! s:_foldl(f, init, xs) abort
|
||||
let memo = a:init
|
||||
for [k, v] in a:xs
|
||||
let expr = substitute(a:f, 'v:key', string(k), 'g')
|
||||
let expr = substitute(expr, 'v:val', string(v), 'g')
|
||||
let expr = substitute(expr, 'v:memo', string(memo), 'g')
|
||||
unlet memo
|
||||
let memo = eval(expr)
|
||||
endfor
|
||||
return memo
|
||||
endfunction
|
||||
|
||||
function! s:foldl(f, init, dict) abort
|
||||
return s:_foldl(a:f, a:init, items(a:dict))
|
||||
endfunction
|
||||
|
||||
function! s:foldr(f, init, dict) abort
|
||||
return s:_foldl(a:f, a:init, reverse(items(a:dict)))
|
||||
endfunction
|
||||
|
||||
" vim:set et sw=2 cc=80:
|
75
autoload/SpaceVim/api/data/list.vim
Normal file
75
autoload/SpaceVim/api/data/list.vim
Normal file
@ -0,0 +1,75 @@
|
||||
function! SpaceVim#api#data#list#get() abort
|
||||
return map({'pop' : '',
|
||||
\ 'push' : '',
|
||||
\ 'shift' : '',
|
||||
\ 'unshift' : '',
|
||||
\ 'uniq' : '',
|
||||
\ 'uniq_by' : '',
|
||||
\ 'char_range' : '',
|
||||
\ 'has' : '',
|
||||
\ 'has_index' : '',
|
||||
\ },
|
||||
\ "function('s:' . v:key)"
|
||||
\ )
|
||||
endfunction
|
||||
|
||||
function! s:pop(list) abort
|
||||
return remove(a:list, -1)
|
||||
endfunction
|
||||
|
||||
function! s:push(list, val) abort
|
||||
call add(a:list, a:val)
|
||||
return a:list
|
||||
endfunction
|
||||
|
||||
function! s:shift(list) abort
|
||||
return remove(a:list, 0)
|
||||
endfunction
|
||||
|
||||
function! s:unshift(list, val) abort
|
||||
return insert(a:list, a:val)
|
||||
endfunction
|
||||
|
||||
function! s:uniq(list) abort
|
||||
return s:uniq_by(a:list, 'v:val')
|
||||
endfunction
|
||||
|
||||
function! s:uniq_by(list, f) abort
|
||||
let list = map(copy(a:list), printf('[v:val, %s]', a:f))
|
||||
let i = 0
|
||||
let seen = {}
|
||||
while i < len(list)
|
||||
let key = string(list[i][1])
|
||||
if has_key(seen, key)
|
||||
call remove(list, i)
|
||||
else
|
||||
let seen[key] = 1
|
||||
let i += 1
|
||||
endif
|
||||
endwhile
|
||||
return map(list, 'v:val[0]')
|
||||
endfunction
|
||||
|
||||
function! s:clear(list) abort
|
||||
if !empty(a:list)
|
||||
unlet! a:list[0 : len(a:list) - 1]
|
||||
endif
|
||||
return a:list
|
||||
endfunction
|
||||
|
||||
function! s:char_range(from, to) abort
|
||||
return map(
|
||||
\ range(char2nr(a:from), char2nr(a:to)),
|
||||
\ 'nr2char(v:val)'
|
||||
\)
|
||||
endfunction
|
||||
|
||||
function! s:has(list, val) abort
|
||||
return index(a:list, a:val) != -1
|
||||
endfunction
|
||||
|
||||
function! s:has_index(list, index) abort
|
||||
return 0 <= a:index && a:index < len(a:list)
|
||||
endfunction
|
||||
|
||||
" vim:set et sw=2 cc=80:
|
@ -159,13 +159,14 @@ function! SpaceVim#default#SetMappings() abort
|
||||
|
||||
"mapping
|
||||
imap <silent><expr><TAB> SpaceVim#mapping#tab()
|
||||
imap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
||||
imap <silent><expr><S-TAB> SpaceVim#mapping#shift_tab()
|
||||
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
|
||||
inoremap <silent><expr><CR> SpaceVim#mapping#enter()
|
||||
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
|
||||
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
|
||||
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
|
||||
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
|
||||
imap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
||||
smap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
||||
" Save a file with sudo
|
||||
" http://forrst.com/posts/Use_w_to_sudo_write_a_file_with_Vim-uAN
|
||||
|
@ -21,42 +21,46 @@
|
||||
|
||||
|
||||
function! SpaceVim#layers#autocomplete#plugins() abort
|
||||
let plugins = [
|
||||
\ ['honza/vim-snippets', {'on_i' : 1, 'loadconf_before' : 1}],
|
||||
\ ['Shougo/neco-syntax', { 'on_i' : 1}],
|
||||
\ ['ujihisa/neco-look', { 'on_i' : 1}],
|
||||
\ ['Shougo/context_filetype.vim', { 'on_i' : 1}],
|
||||
\ ['Shougo/neoinclude.vim', { 'on_i' : 1}],
|
||||
\ ['Shougo/neosnippet-snippets', { 'merged' : 0}],
|
||||
\ ['Shougo/neopairs.vim', { 'on_i' : 1}],
|
||||
\ ]
|
||||
if g:spacevim_autocomplete_method ==# 'ycm'
|
||||
call add(plugins, ['SirVer/ultisnips', {'loadconf_before' : 1, 'merged' : 0}])
|
||||
call add(plugins, ['ervandew/supertab', {'loadconf_before' : 1, 'merged' : 0}])
|
||||
call add(plugins, ['Valloric/YouCompleteMe', {'loadconf_before' : 1, 'merged' : 0}])
|
||||
elseif g:spacevim_autocomplete_method ==# 'neocomplete' "{{{
|
||||
call add(plugins, ['Shougo/neocomplete', {
|
||||
\ 'on_i' : 1,
|
||||
\ 'loadconf' : 1,
|
||||
\ }])
|
||||
elseif g:spacevim_autocomplete_method ==# 'neocomplcache' "{{{
|
||||
call add(plugins, ['Shougo/neocomplcache.vim', {
|
||||
\ 'on_i' : 1,
|
||||
\ 'loadconf' : 1,
|
||||
\ }])
|
||||
elseif g:spacevim_autocomplete_method ==# 'deoplete'
|
||||
call add(plugins, ['Shougo/deoplete.nvim', {
|
||||
\ 'on_i' : 1,
|
||||
\ 'loadconf' : 1,
|
||||
\ }])
|
||||
endif
|
||||
return plugins
|
||||
let plugins = [
|
||||
\ ['honza/vim-snippets', { 'on_i' : 1, 'loadconf_before' : 1}],
|
||||
\ ['Shougo/neco-syntax', { 'on_i' : 1}],
|
||||
\ ['ujihisa/neco-look', { 'on_i' : 1}],
|
||||
\ ['Shougo/context_filetype.vim', { 'on_i' : 1}],
|
||||
\ ['Shougo/neoinclude.vim', { 'on_i' : 1}],
|
||||
\ ['Shougo/neosnippet-snippets', { 'merged' : 0}],
|
||||
\ ['Shougo/neopairs.vim', { 'on_i' : 1}],
|
||||
\ ['Raimondi/delimitMate', { 'merged' : 0}],
|
||||
\ ]
|
||||
if g:spacevim_autocomplete_method ==# 'ycm'
|
||||
call add(plugins, ['SirVer/ultisnips', { 'loadconf_before' : 1, 'merged' : 0}])
|
||||
call add(plugins, ['ervandew/supertab', { 'loadconf_before' : 1, 'merged' : 0}])
|
||||
call add(plugins, ['Valloric/YouCompleteMe', { 'loadconf_before' : 1, 'merged' : 0}])
|
||||
elseif g:spacevim_autocomplete_method ==# 'neocomplete'
|
||||
call add(plugins, ['Shougo/neocomplete', {
|
||||
\ 'on_i' : 1,
|
||||
\ 'loadconf' : 1,
|
||||
\ }])
|
||||
elseif g:spacevim_autocomplete_method ==# 'neocomplcache' "{{{
|
||||
call add(plugins, ['Shougo/neocomplcache.vim', {
|
||||
\ 'on_i' : 1,
|
||||
\ 'loadconf' : 1,
|
||||
\ }])
|
||||
elseif g:spacevim_autocomplete_method ==# 'deoplete'
|
||||
call add(plugins, ['Shougo/deoplete.nvim', {
|
||||
\ 'on_i' : 1,
|
||||
\ 'loadconf' : 1,
|
||||
\ }])
|
||||
endif
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
|
||||
function SpaceVim#layers#autocomplete#config()
|
||||
if g:spacevim_autocomplete_method ==# 'ycm'
|
||||
iunmap <S-TAB>
|
||||
sunmap <S-TAB>
|
||||
endif
|
||||
function! SpaceVim#layers#autocomplete#config() abort
|
||||
if g:spacevim_autocomplete_method ==# 'ycm'
|
||||
sunmap <S-TAB>
|
||||
iunmap <S-TAB>
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" vim:set et sw=2 cc=80:
|
||||
|
@ -1,7 +1,6 @@
|
||||
function! SpaceVim#layers#core#plugins() abort
|
||||
return [
|
||||
\ ['Shougo/vimproc.vim', {'build' : 'make'}],
|
||||
\ ['hecal3/vim-leader-guide', {'loadconf': 1, 'loadconf_before' : 1, 'merged' : 0}],
|
||||
\ ['benizi/vim-automkdir'],
|
||||
\ ['airblade/vim-rooter'],
|
||||
\ ]
|
||||
|
@ -12,9 +12,6 @@ function! SpaceVim#layers#lang#plugins() abort
|
||||
\ ['leafgarland/typescript-vim', { 'on_ft' : ['typescript']}],
|
||||
\ ['kchmck/vim-coffee-script', { 'on_ft' : ['coffee']}],
|
||||
\ ['leshill/vim-json', { 'on_ft' : ['javascript','json']}],
|
||||
\ ['syngan/vim-vimlint', { 'on_ft' : 'vim'}],
|
||||
\ ['ynkdir/vim-vimlparser', { 'on_ft' : 'vim'}],
|
||||
\ ['todesking/vint-syntastic', { 'on_ft' : 'vim'}],
|
||||
\ ['elixir-lang/vim-elixir', { 'on_ft' : 'elixir'}],
|
||||
\ ['PotatoesMaster/i3-vim-syntax', { 'on_ft' : 'i3'}],
|
||||
\ ['isundil/vim-irssi-syntax', { 'on_ft' : 'irssi'}],
|
||||
|
@ -7,7 +7,9 @@ function! SpaceVim#layers#lang#markdown#plugins() abort
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#markdown#config() abort
|
||||
let g:vim_markdown_fenced_languages = [ 'c++=cpp' , 'viml=vim', 'bash=sh', 'ini=dosini']
|
||||
let g:vim_markdown_conceal = 0
|
||||
let g:vim_markdown_folding_disabled = 1
|
||||
let g:markdown_fenced_languages = ['vim', 'java', 'bash=sh', 'sh', 'html', 'python']
|
||||
let g:vim_markdown_frontmatter = 1
|
||||
let g:vim_markdown_toml_frontmatter = 1
|
||||
endfunction
|
||||
|
@ -1,5 +1,9 @@
|
||||
function! SpaceVim#layers#lang#vim#plugins() abort
|
||||
let plugins = []
|
||||
let plugins = [
|
||||
\ ['syngan/vim-vimlint', { 'on_ft' : 'vim'}],
|
||||
\ ['ynkdir/vim-vimlparser', { 'on_ft' : 'vim'}],
|
||||
\ ['todesking/vint-syntastic', { 'on_ft' : 'vim'}],
|
||||
\ ]
|
||||
call add(plugins,['tweekmonster/exception.vim'])
|
||||
call add(plugins,['mhinz/vim-lookup'])
|
||||
call add(plugins,['Shougo/neco-vim', { 'on_i' : 1, 'loadconf_before' : 1}])
|
||||
|
@ -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='right'
|
||||
let g:NERDTreeWinSize=31
|
||||
let 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=get(g:,'NERDTreeWinPos','right')
|
||||
let g:NERDTreeWinSize=get(g:,'NERDTreeWinSize',31)
|
||||
let g:NERDTreeChDirMode=get(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:
|
||||
|
@ -6,7 +6,7 @@ let g:unite_source_menu_menus.CustomKeyMaps = {'description':
|
||||
let g:unite_source_menu_menus.CustomKeyMaps.command_candidates =
|
||||
\ get(g:unite_source_menu_menus.CustomKeyMaps,'command_candidates', [])
|
||||
|
||||
function! SpaceVim#mapping#def(type,key,value,desc,...) abort
|
||||
function! SpaceVim#mapping#_def(type,key,value,desc,...) abort
|
||||
exec a:type . ' ' . a:key . ' ' . a:value
|
||||
let description = '➤ '
|
||||
\. a:desc
|
||||
@ -16,6 +16,64 @@ function! SpaceVim#mapping#def(type,key,value,desc,...) abort
|
||||
call add(g:unite_source_menu_menus.CustomKeyMaps.command_candidates, [description,cmd])
|
||||
endfunction
|
||||
|
||||
" a:1 unite desc
|
||||
" a:2 unite cmd
|
||||
" a:3 guide desc
|
||||
" example call SpaceVim#mapping#def('nnoremap <silent>', 'gf', ':call zvim#gf()<CR>', 'Jump to a file under cursor', '')
|
||||
function! SpaceVim#mapping#def(type, key, value, ...) abort
|
||||
let feedkeys_mode = 'm'
|
||||
let map = split(a:type)[0]
|
||||
if map =~# 'nore'
|
||||
let feedkeys_mode = 'n'
|
||||
endif
|
||||
let lhs = a:key
|
||||
let rhs = a:value
|
||||
let gexe = a:value
|
||||
if a:value =~? '^<plug>'
|
||||
let gexe = '\' . a:value
|
||||
elseif a:value =~? ':.\+<cr>$'
|
||||
let gexe = substitute(gexe, '<cr>', "\<cr>", 'g')
|
||||
let gexe = substitute(gexe, '<CR>', "\<CR>", 'g')
|
||||
let gexe = substitute(gexe, '<Esc>', "\<Esc>", 'g')
|
||||
else
|
||||
endif
|
||||
exec a:type . ' ' . a:key . ' ' . a:value
|
||||
if a:0 > 0
|
||||
let desc = a:1
|
||||
let description = '➤ '
|
||||
\ . desc
|
||||
\ . repeat(' ', 80 - len(desc) - len(a:key))
|
||||
\ . a:key
|
||||
let cmd = a:0 == 2 ? a:2 : a:value
|
||||
call add(g:unite_source_menu_menus.CustomKeyMaps.command_candidates, [description,cmd])
|
||||
if a:0 == 3
|
||||
" enable guide
|
||||
if a:key =~? '^<leader>'
|
||||
if len(a:key) > 9
|
||||
let group = a:key[8:8]
|
||||
if !has_key(g:_spacevim_mappings, group)
|
||||
let g:_spacevim_mappings[group] = {'name': 'new group'}
|
||||
endif
|
||||
call extend(g:_spacevim_mappings[group], {
|
||||
\ a:key[9:] : ['call feedkeys("' . gexe . '", "'
|
||||
\ . feedkeys_mode . '")', a:3]
|
||||
\ })
|
||||
elseif len(a:key) == 9
|
||||
call extend(g:_spacevim_mappings, {
|
||||
\ a:key[8:] : ['call feedkeys("' . gexe . '", "'
|
||||
\ . feedkeys_mode . '")', a:3]
|
||||
\ })
|
||||
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#mapping#shift_tab() abort
|
||||
return pumvisible() ? "\<C-p>" : "\<Plug>delimitMateS-Tab"
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#mapping#tab() abort
|
||||
if getline('.')[col('.')-2] ==# '{'&& pumvisible()
|
||||
return "\<C-n>"
|
||||
|
505
autoload/SpaceVim/mapping/guide.vim
Normal file
505
autoload/SpaceVim/mapping/guide.vim
Normal file
@ -0,0 +1,505 @@
|
||||
"=============================================================================
|
||||
" guide.vim --- mappings guide helper for SpaceVim
|
||||
" Copyright (c) 2016-2017 Shidong Wang & Contributors
|
||||
" Author: Shidong Wang < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: MIT license
|
||||
"=============================================================================
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SpaceVim#mapping#guide#has_configuration() "{{{
|
||||
return exists('s:desc_lookup')
|
||||
endfunction "}}}
|
||||
|
||||
function! SpaceVim#mapping#guide#register_prefix_descriptions(key, dictname) " {{{
|
||||
let key = a:key ==? '<Space>' ? ' ' : a:key
|
||||
if !exists('s:desc_lookup')
|
||||
call s:create_cache()
|
||||
endif
|
||||
if strlen(key) == 0
|
||||
let s:desc_lookup['top'] = a:dictname
|
||||
return
|
||||
endif
|
||||
if !has_key(s:desc_lookup, key)
|
||||
let s:desc_lookup[key] = a:dictname
|
||||
endif
|
||||
endfunction "}}}
|
||||
function! s:create_cache() " {{{
|
||||
let s:desc_lookup = {}
|
||||
let s:cached_dicts = {}
|
||||
endfunction " }}}
|
||||
function! s:create_target_dict(key) " {{{
|
||||
if has_key(s:desc_lookup, 'top')
|
||||
let toplevel = deepcopy({s:desc_lookup['top']})
|
||||
let tardict = s:toplevel ? toplevel : get(toplevel, a:key, {})
|
||||
let mapdict = s:cached_dicts[a:key]
|
||||
call s:merge(tardict, mapdict)
|
||||
elseif has_key(s:desc_lookup, a:key)
|
||||
let tardict = deepcopy({s:desc_lookup[a:key]})
|
||||
let mapdict = s:cached_dicts[a:key]
|
||||
call s:merge(tardict, mapdict)
|
||||
else
|
||||
let tardict = s:cached_dicts[a:key]
|
||||
endif
|
||||
return tardict
|
||||
endfunction " }}}
|
||||
function! s:merge(dict_t, dict_o) " {{{
|
||||
let target = a:dict_t
|
||||
let other = a:dict_o
|
||||
for k in keys(target)
|
||||
if type(target[k]) == type({}) && has_key(other, k)
|
||||
if type(other[k]) == type({})
|
||||
if has_key(target[k], 'name')
|
||||
let other[k].name = target[k].name
|
||||
endif
|
||||
call s:merge(target[k], other[k])
|
||||
elseif type(other[k]) == type([])
|
||||
if g:leaderGuide_flatten == 0 || type(target[k]) == type({})
|
||||
let target[k.'m'] = target[k]
|
||||
endif
|
||||
let target[k] = other[k]
|
||||
if has_key(other, k."m") && type(other[k."m"]) == type({})
|
||||
call s:merge(target[k."m"], other[k."m"])
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call extend(target, other, "keep")
|
||||
endfunction " }}}
|
||||
|
||||
" @vimlint(EVL103, 1, a:dictname)
|
||||
function! SpaceVim#mapping#guide#populate_dictionary(key, dictname) " {{{
|
||||
call s:start_parser(a:key, s:cached_dicts[a:key])
|
||||
endfunction " }}}
|
||||
" @vimlint(EVL103, 0, a:dictname)
|
||||
|
||||
function! SpaceVim#mapping#guide#parse_mappings() " {{{
|
||||
for [k, v] in items(s:cached_dicts)
|
||||
call s:start_parser(k, v)
|
||||
endfor
|
||||
endfunction " }}}
|
||||
|
||||
|
||||
function! s:start_parser(key, dict) " {{{
|
||||
let key = a:key ==? ' ' ? "<Space>" : a:key
|
||||
let readmap = ""
|
||||
redir => readmap
|
||||
silent execute 'map '.key
|
||||
redir END
|
||||
let lines = split(readmap, "\n")
|
||||
let visual = s:vis == "gv" ? 1 : 0
|
||||
|
||||
for line in lines
|
||||
let mapd = maparg(split(line[3:])[0], line[0], 0, 1)
|
||||
if mapd.lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'
|
||||
continue
|
||||
endif
|
||||
let mapd.display = s:format_displaystring(mapd.rhs)
|
||||
let mapd.lhs = substitute(mapd.lhs, key, "", "")
|
||||
let mapd.lhs = substitute(mapd.lhs, "<Space>", " ", "g")
|
||||
let mapd.lhs = substitute(mapd.lhs, "<Tab>", "<C-I>", "g")
|
||||
let mapd.rhs = substitute(mapd.rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")
|
||||
if mapd.lhs != '' && mapd.display !~# 'LeaderGuide.*'
|
||||
if (visual && match(mapd.mode, "[vx ]") >= 0) ||
|
||||
\ (!visual && match(mapd.mode, "[vx]") == -1)
|
||||
let mapd.lhs = s:string_to_keys(mapd.lhs)
|
||||
call s:add_map_to_dict(mapd, 0, a:dict)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfunction " }}}
|
||||
|
||||
function! s:add_map_to_dict(map, level, dict) " {{{
|
||||
if len(a:map.lhs) > a:level+1
|
||||
let curkey = a:map.lhs[a:level]
|
||||
let nlevel = a:level+1
|
||||
if !has_key(a:dict, curkey)
|
||||
let a:dict[curkey] = { 'name' : g:leaderGuide_default_group_name }
|
||||
" mapping defined already, flatten this map
|
||||
elseif type(a:dict[curkey]) == type([]) && g:leaderGuide_flatten
|
||||
let cmd = s:escape_mappings(a:map)
|
||||
let curkey = join(a:map.lhs[a:level+0:], '')
|
||||
let nlevel = a:level
|
||||
if !has_key(a:dict, curkey)
|
||||
let a:dict[curkey] = [cmd, a:map.display]
|
||||
endif
|
||||
elseif type(a:dict[curkey]) == type([]) && g:leaderGuide_flatten == 0
|
||||
let cmd = s:escape_mappings(a:map)
|
||||
let curkey = curkey."m"
|
||||
if !has_key(a:dict, curkey)
|
||||
let a:dict[curkey] = { 'name' : g:leaderGuide_default_group_name }
|
||||
endif
|
||||
endif
|
||||
" next level
|
||||
if type(a:dict[curkey]) == type({})
|
||||
call s:add_map_to_dict(a:map, nlevel, a:dict[curkey])
|
||||
endif
|
||||
else
|
||||
let cmd = s:escape_mappings(a:map)
|
||||
if !has_key(a:dict, a:map.lhs[a:level])
|
||||
let a:dict[a:map.lhs[a:level]] = [cmd, a:map.display]
|
||||
" spot is taken already, flatten existing submaps
|
||||
elseif type(a:dict[a:map.lhs[a:level]]) == type({}) && g:leaderGuide_flatten
|
||||
let childmap = s:flattenmap(a:dict[a:map.lhs[a:level]], a:map.lhs[a:level])
|
||||
for it in keys(childmap)
|
||||
let a:dict[it] = childmap[it]
|
||||
endfor
|
||||
let a:dict[a:map.lhs[a:level]] = [cmd, a:map.display]
|
||||
endif
|
||||
endif
|
||||
endfunction " }}}
|
||||
" @vimlint(EVL111, 1, Fun)
|
||||
function! s:format_displaystring(map) " {{{
|
||||
let g:leaderGuide#displayname = a:map
|
||||
for Fun in g:leaderGuide_displayfunc
|
||||
call Fun()
|
||||
endfor
|
||||
let display = g:leaderGuide#displayname
|
||||
unlet g:leaderGuide#displayname
|
||||
return display
|
||||
endfunction " }}}
|
||||
" @vimlint(EVL111, 0, Fun)
|
||||
function! s:flattenmap(dict, str) " {{{
|
||||
let ret = {}
|
||||
for kv in keys(a:dict)
|
||||
if type(a:dict[kv]) == type([])
|
||||
let toret = {}
|
||||
let toret[a:str.kv] = a:dict[kv]
|
||||
return toret
|
||||
elseif type(a:dict[kv]) == type({})
|
||||
call extend(ret, s:flattenmap(a:dict[kv], a:str.kv))
|
||||
endif
|
||||
endfor
|
||||
return ret
|
||||
endfunction " }}}
|
||||
|
||||
|
||||
function! s:escape_mappings(mapping) " {{{
|
||||
let feedkeyargs = a:mapping.noremap ? "nt" : "mt"
|
||||
let rstring = substitute(a:mapping.rhs, '\', '\\\\', 'g')
|
||||
let rstring = substitute(rstring, '<\([^<>]*\)>', '\\<\1>', 'g')
|
||||
let rstring = substitute(rstring, '"', '\\"', 'g')
|
||||
let rstring = 'call feedkeys("'.rstring.'", "'.feedkeyargs.'")'
|
||||
return rstring
|
||||
endfunction " }}}
|
||||
function! s:string_to_keys(input) " {{{
|
||||
" Avoid special case: <>
|
||||
if match(a:input, '<.\+>') != -1
|
||||
let retlist = []
|
||||
let si = 0
|
||||
let go = 1
|
||||
while si < len(a:input)
|
||||
if go
|
||||
call add(retlist, a:input[si])
|
||||
else
|
||||
let retlist[-1] .= a:input[si]
|
||||
endif
|
||||
if a:input[si] ==? '<'
|
||||
let go = 0
|
||||
elseif a:input[si] ==? '>'
|
||||
let go = 1
|
||||
end
|
||||
let si += 1
|
||||
endw
|
||||
return retlist
|
||||
else
|
||||
return split(a:input, '\zs')
|
||||
endif
|
||||
endfunction " }}}
|
||||
function! s:escape_keys(inp) " {{{
|
||||
let ret = substitute(a:inp, "<", "<lt>", "")
|
||||
return substitute(ret, "|", "<Bar>", "")
|
||||
endfunction " }}}
|
||||
function! s:show_displayname(inp) " {{{
|
||||
if has_key(s:displaynames, toupper(a:inp))
|
||||
return s:displaynames[toupper(a:inp)]
|
||||
else
|
||||
return a:inp
|
||||
end
|
||||
endfunction " }}}
|
||||
" displaynames {{{1 "
|
||||
let s:displaynames = {'<C-I>': '<Tab>',
|
||||
\ '<C-H>': '<BS>'}
|
||||
" 1}}} "
|
||||
|
||||
|
||||
function! s:calc_layout() " {{{
|
||||
let ret = {}
|
||||
let smap = filter(copy(s:lmap), 'v:key !=# "name"')
|
||||
let ret.n_items = len(smap)
|
||||
let length = values(map(smap,
|
||||
\ 'strdisplaywidth("[".v:key."]".'.
|
||||
\ '(type(v:val) == type({}) ? v:val["name"] : v:val[1]))'))
|
||||
let maxlength = max(length) + g:leaderGuide_hspace
|
||||
if g:leaderGuide_vertical
|
||||
let ret.n_rows = winheight(0) - 2
|
||||
let ret.n_cols = ret.n_items / ret.n_rows + (ret.n_items != ret.n_rows)
|
||||
let ret.col_width = maxlength
|
||||
let ret.win_dim = ret.n_cols * ret.col_width
|
||||
else
|
||||
let ret.n_cols = winwidth(0) / maxlength
|
||||
let ret.col_width = winwidth(0) / ret.n_cols
|
||||
let ret.n_rows = ret.n_items / ret.n_cols + (fmod(ret.n_items,ret.n_cols) > 0 ? 1 : 0)
|
||||
let ret.win_dim = ret.n_rows
|
||||
"echom string(ret)
|
||||
endif
|
||||
return ret
|
||||
endfunction " }}}
|
||||
function! s:create_string(layout) " {{{
|
||||
let l = a:layout
|
||||
let l.capacity = l.n_rows * l.n_cols
|
||||
let overcap = l.capacity - l.n_items
|
||||
let overh = l.n_cols - overcap
|
||||
let n_rows = l.n_rows - 1
|
||||
|
||||
let rows = []
|
||||
let row = 0
|
||||
let col = 0
|
||||
let smap = sort(filter(keys(s:lmap), 'v:val !=# "name"'),'1')
|
||||
for k in smap
|
||||
let desc = type(s:lmap[k]) == type({}) ? s:lmap[k].name : s:lmap[k][1]
|
||||
let displaystring = "[".s:show_displayname(k)."] ".desc
|
||||
let crow = get(rows, row, [])
|
||||
if empty(crow)
|
||||
call add(rows, crow)
|
||||
endif
|
||||
call add(crow, displaystring)
|
||||
call add(crow, repeat(' ', l.col_width - strdisplaywidth(displaystring)))
|
||||
|
||||
if !g:leaderGuide_sort_horizontal
|
||||
if row >= n_rows - 1
|
||||
if overh > 0 && row < n_rows
|
||||
let overh -= 1
|
||||
let row += 1
|
||||
else
|
||||
let row = 0
|
||||
let col += 1
|
||||
endif
|
||||
else
|
||||
let row += 1
|
||||
endif
|
||||
else
|
||||
if col == l.n_cols - 1
|
||||
let row +=1
|
||||
let col = 0
|
||||
else
|
||||
let col += 1
|
||||
endif
|
||||
endif
|
||||
silent execute "cnoremap <nowait> <buffer> ".substitute(k, "|", "<Bar>", ""). " " . s:escape_keys(k) ."<CR>"
|
||||
endfor
|
||||
let r = []
|
||||
let mlen = 0
|
||||
for ro in rows
|
||||
let line = join(ro, '')
|
||||
call add(r, line)
|
||||
if strdisplaywidth(line) > mlen
|
||||
let mlen = strdisplaywidth(line)
|
||||
endif
|
||||
endfor
|
||||
call insert(r, '')
|
||||
let output = join(r, "\n ")
|
||||
cnoremap <nowait> <buffer> <Space> <Space><CR>
|
||||
cnoremap <nowait> <buffer> <silent> <c-c> <LGCMD>submode<CR>
|
||||
return output
|
||||
endfunction " }}}
|
||||
|
||||
|
||||
" @vimlint(EVL102, 1, l:string)
|
||||
function! s:start_buffer() " {{{
|
||||
let s:winv = winsaveview()
|
||||
let s:winnr = winnr()
|
||||
let s:winres = winrestcmd()
|
||||
call s:winopen()
|
||||
let layout = s:calc_layout()
|
||||
let string = s:create_string(layout)
|
||||
|
||||
if g:leaderGuide_max_size
|
||||
let layout.win_dim = min([g:leaderGuide_max_size, layout.win_dim])
|
||||
endif
|
||||
|
||||
setlocal modifiable
|
||||
if g:leaderGuide_vertical
|
||||
noautocmd execute 'vert res '.layout.win_dim
|
||||
else
|
||||
noautocmd execute 'res '.layout.win_dim
|
||||
endif
|
||||
silent 1put!=string
|
||||
normal! gg"_dd
|
||||
setlocal nomodifiable
|
||||
call s:wait_for_input()
|
||||
endfunction " }}}
|
||||
" @vimlint(EVL102, 0, l:string)
|
||||
|
||||
function! s:handle_input(input) " {{{
|
||||
call s:winclose()
|
||||
if type(a:input) ==? type({})
|
||||
let s:lmap = a:input
|
||||
call s:start_buffer()
|
||||
else
|
||||
call feedkeys(s:vis.s:reg.s:count, 'ti')
|
||||
redraw!
|
||||
try
|
||||
unsilent execute a:input[0]
|
||||
catch
|
||||
unsilent echom v:exception
|
||||
endtry
|
||||
endif
|
||||
endfunction " }}}
|
||||
function! s:wait_for_input() " {{{
|
||||
redraw!
|
||||
let inp = input("")
|
||||
if inp ==? ''
|
||||
call s:winclose()
|
||||
elseif match(inp, "^<LGCMD>submode") == 0
|
||||
call s:submode_mappings()
|
||||
else
|
||||
let fsel = get(s:lmap, inp)
|
||||
call s:handle_input(fsel)
|
||||
endif
|
||||
endfunction " }}}
|
||||
function! s:winopen() " {{{
|
||||
if !exists('s:bufnr')
|
||||
let s:bufnr = -1
|
||||
endif
|
||||
let pos = g:leaderGuide_position ==? 'topleft' ? 'topleft' : 'botright'
|
||||
if bufexists(s:bufnr)
|
||||
let qfbuf = &buftype ==# 'quickfix'
|
||||
let splitcmd = g:leaderGuide_vertical ? ' 1vs' : ' 1sp'
|
||||
noautocmd execute pos . splitcmd
|
||||
let bnum = bufnr('%')
|
||||
noautocmd execute 'buffer '.s:bufnr
|
||||
cmapclear <buffer>
|
||||
if qfbuf
|
||||
noautocmd execute bnum.'bwipeout!'
|
||||
endif
|
||||
else
|
||||
let splitcmd = g:leaderGuide_vertical ? ' 1vnew' : ' 1new'
|
||||
noautocmd execute pos.splitcmd
|
||||
let s:bufnr = bufnr('%')
|
||||
autocmd WinLeave <buffer> call s:winclose()
|
||||
endif
|
||||
let s:gwin = winnr()
|
||||
setlocal filetype=leaderGuide
|
||||
setlocal nonumber norelativenumber nolist nomodeline nowrap
|
||||
setlocal nobuflisted buftype=nofile bufhidden=unload noswapfile
|
||||
setlocal nocursorline nocursorcolumn colorcolumn=
|
||||
setlocal winfixwidth winfixheight
|
||||
setlocal statusline=\ Leader\ Guide
|
||||
endfunction " }}}
|
||||
function! s:winclose() " {{{
|
||||
noautocmd execute s:gwin.'wincmd w'
|
||||
if s:gwin == winnr()
|
||||
close
|
||||
redraw!
|
||||
exe s:winres
|
||||
let s:gwin = -1
|
||||
noautocmd execute s:winnr.'wincmd w'
|
||||
call winrestview(s:winv)
|
||||
endif
|
||||
endfunction " }}}
|
||||
function! s:page_down() " {{{
|
||||
call feedkeys("\<c-c>", "n")
|
||||
call feedkeys("\<c-f>", "x")
|
||||
redraw!
|
||||
call s:wait_for_input()
|
||||
endfunction " }}}
|
||||
function! s:page_up() " {{{
|
||||
call feedkeys("\<c-c>", "n")
|
||||
call feedkeys("\<c-b>", "x")
|
||||
redraw!
|
||||
call s:wait_for_input()
|
||||
endfunction " }}}
|
||||
|
||||
function! s:handle_submode_mapping(cmd) " {{{
|
||||
if a:cmd ==? '<LGCMD>page_down'
|
||||
call s:page_down()
|
||||
elseif a:cmd ==? '<LGCMD>page_up'
|
||||
call s:page_up()
|
||||
elseif a:cmd ==? '<LGCMD>win_close'
|
||||
call s:winclose()
|
||||
endif
|
||||
endfunction " }}}
|
||||
function! s:submode_mappings() " {{{
|
||||
let submodestring = ""
|
||||
let maplist = []
|
||||
for key in items(g:leaderGuide_submode_mappings)
|
||||
let map = maparg(key[0], "c", 0, 1)
|
||||
if !empty(map)
|
||||
call add(maplist, map)
|
||||
endif
|
||||
execute 'cnoremap <nowait> <silent> <buffer> '.key[0].' <LGCMD>'.key[1].'<CR>'
|
||||
let submodestring = submodestring.' '.key[0].': '.key[1].','
|
||||
endfor
|
||||
let inp = input(strpart(submodestring, 0, strlen(submodestring)-1))
|
||||
for map in maplist
|
||||
call s:mapmaparg(map)
|
||||
endfor
|
||||
silent call s:handle_submode_mapping(inp)
|
||||
endfunction " }}}
|
||||
function! s:mapmaparg(maparg) " {{{
|
||||
let noremap = a:maparg.noremap ? 'noremap' : 'map'
|
||||
let buffer = a:maparg.buffer ? '<buffer> ' : ''
|
||||
let silent = a:maparg.silent ? '<silent> ' : ''
|
||||
let nowait = a:maparg.nowait ? '<nowait> ' : ''
|
||||
let st = a:maparg.mode . '' . noremap . ' ' . nowait . silent . buffer
|
||||
\ . '' .a:maparg.lhs . ' ' . a:maparg.rhs
|
||||
execute st
|
||||
endfunction " }}}
|
||||
|
||||
function! s:get_register() "{{{
|
||||
if match(&clipboard, 'unnamedplus') >= 0
|
||||
let clip = '+'
|
||||
elseif match(&clipboard, 'unnamed') >= 0
|
||||
let clip = '*'
|
||||
else
|
||||
let clip = '"'
|
||||
endif
|
||||
return clip
|
||||
endfunction "}}}
|
||||
function! SpaceVim#mapping#guide#start_by_prefix(vis, key) " {{{
|
||||
let s:vis = a:vis ? 'gv' : ''
|
||||
let s:count = v:count != 0 ? v:count : ''
|
||||
let s:toplevel = a:key ==? ' '
|
||||
|
||||
if has('nvim') && !exists('s:reg')
|
||||
let s:reg = ''
|
||||
else
|
||||
let s:reg = v:register != s:get_register() ? '"'.v:register : ''
|
||||
endif
|
||||
|
||||
if !has_key(s:cached_dicts, a:key) || g:leaderGuide_run_map_on_popup
|
||||
"first run
|
||||
let s:cached_dicts[a:key] = {}
|
||||
call s:start_parser(a:key, s:cached_dicts[a:key])
|
||||
endif
|
||||
|
||||
if has_key(s:desc_lookup, a:key) || has_key(s:desc_lookup , 'top')
|
||||
let rundict = s:create_target_dict(a:key)
|
||||
else
|
||||
let rundict = s:cached_dicts[a:key]
|
||||
endif
|
||||
let s:lmap = rundict
|
||||
|
||||
call s:start_buffer()
|
||||
endfunction " }}}
|
||||
function! SpaceVim#mapping#guide#start(vis, dict) " {{{
|
||||
let s:vis = a:vis ? 'gv' : 0
|
||||
let s:lmap = a:dict
|
||||
call s:start_buffer()
|
||||
endfunction " }}}
|
||||
|
||||
if !exists("g:leaderGuide_displayfunc")
|
||||
function! s:leaderGuide_display()
|
||||
let g:leaderGuide#displayname = substitute(g:leaderGuide#displayname, '\c<cr>$', '', '')
|
||||
endfunction
|
||||
let g:leaderGuide_displayfunc = [function("s:leaderGuide_display")]
|
||||
endif
|
||||
|
||||
call SpaceVim#mapping#guide#register_prefix_descriptions('\', 'g:_spacevim_mappings')
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:set et sw=2 cc=80:
|
@ -1,142 +1,173 @@
|
||||
function! SpaceVim#mapping#leader#defindglobalMappings() abort
|
||||
inoremap <silent> <Leader><Tab> <C-r>=MyLeaderTabfunc()<CR>
|
||||
nnoremap <silent><leader><space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
|
||||
inoremap <silent> <Leader><Tab> <C-r>=MyLeaderTabfunc()<CR>
|
||||
|
||||
"for buftabs
|
||||
noremap <silent><Leader>bp :bprev<CR>
|
||||
noremap <silent><Leader>bn :bnext<CR>
|
||||
"for buftabs
|
||||
noremap <silent><Leader>bp :bprev<CR>
|
||||
noremap <silent><Leader>bn :bnext<CR>
|
||||
|
||||
"background
|
||||
noremap <silent><leader>bg :call ToggleBG()<CR>
|
||||
"numbers
|
||||
noremap <silent><leader>nu :call ToggleNumber()<CR>
|
||||
|
||||
" yark and paste
|
||||
vmap <Leader>y "+y
|
||||
vmap <Leader>d "+d
|
||||
nmap <Leader>p "+p
|
||||
nmap <Leader>P "+P
|
||||
vmap <Leader>p "+p
|
||||
vmap <Leader>P "+P
|
||||
"background
|
||||
noremap <silent><leader>bg :call ToggleBG()<CR>
|
||||
"numbers
|
||||
noremap <silent><leader>nu :call ToggleNumber()<CR>
|
||||
|
||||
cnoremap <Leader><C-F> <C-F>
|
||||
"When pressing <leader>cd switch to the directory of the open buffer
|
||||
map <Leader>cd :cd %:p:h<CR>:pwd<CR>
|
||||
" Fast saving
|
||||
nnoremap <Leader>w :w<CR>
|
||||
vnoremap <Leader>w <Esc>:w<CR>
|
||||
" yark and paste
|
||||
vmap <Leader>y "+y
|
||||
vmap <Leader>d "+d
|
||||
nmap <Leader>p "+p
|
||||
nmap <Leader>P "+P
|
||||
vmap <Leader>p "+p
|
||||
vmap <Leader>P "+P
|
||||
|
||||
" Toggle editor visuals
|
||||
nmap <Leader>ts :setlocal spell!<cr>
|
||||
nmap <Leader>tn :setlocal nonumber! norelativenumber!<CR>
|
||||
nmap <Leader>tl :setlocal nolist!<CR>
|
||||
nmap <Leader>th :nohlsearch<CR>
|
||||
nmap <Leader>tw :setlocal wrap! breakindent!<CR>
|
||||
cnoremap <Leader><C-F> <C-F>
|
||||
"When pressing <leader>cd switch to the directory of the open buffer
|
||||
map <Leader>cd :cd %:p:h<CR>:pwd<CR>
|
||||
|
||||
" Location list movement
|
||||
nmap <silent><Leader>lj :lnext<CR>
|
||||
nmap <silent><Leader>lk :lprev<CR>
|
||||
nmap <silent><Leader>lq :lclose<CR>
|
||||
" Fast saving
|
||||
call SpaceVim#mapping#def('nnoremap', '<Leader>w', ':w<CR>',
|
||||
\ 'Save current file',
|
||||
\ 'w',
|
||||
\ 'Save current file')
|
||||
call SpaceVim#mapping#def('vnoremap', '<Leader>w', '<Esc>:w<CR>',
|
||||
\ 'Save current file',
|
||||
\ 'w',
|
||||
\ 'Save current file')
|
||||
|
||||
" quickfix list movement
|
||||
nmap <silent><Leader>qj :cnext<CR>
|
||||
nmap <silent><Leader>qk :cprev<CR>
|
||||
nmap <silent><Leader>qq :cclose<CR>
|
||||
let g:_spacevim_mappings.t = {'name' : 'Toggle editor visuals'}
|
||||
nmap <Leader>ts :setlocal spell!<cr>
|
||||
nmap <Leader>tn :setlocal nonumber! norelativenumber!<CR>
|
||||
nmap <Leader>tl :setlocal nolist!<CR>
|
||||
nmap <Leader>th :nohlsearch<CR>
|
||||
nmap <Leader>tw :setlocal wrap! breakindent!<CR>
|
||||
|
||||
" Duplicate lines
|
||||
nnoremap <Leader>d m`YP``
|
||||
vnoremap <Leader>d YPgv
|
||||
" Location list movement
|
||||
let g:_spacevim_mappings.l = {'name' : 'Location list movement'}
|
||||
call SpaceVim#mapping#def('nnoremap', '<Leader>lj', ':lnext<CR>',
|
||||
\ 'Jump to next location list position',
|
||||
\ 'lnext',
|
||||
\ 'Next location list')
|
||||
call SpaceVim#mapping#def('nnoremap', '<Leader>lk', ':lprev<CR>',
|
||||
\ 'Jump to previous location list position',
|
||||
\ 'lprev',
|
||||
\ 'Previous location list')
|
||||
call SpaceVim#mapping#def('nnoremap', '<Leader>lq', ':lclose<CR>',
|
||||
\ 'Close the window showing the location list',
|
||||
\ 'lclose',
|
||||
\ 'Close location list window')
|
||||
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader><C-c>',
|
||||
\ ':<c-u>call zvim#util#CopyToClipboard(1)<cr>',
|
||||
\ 'Yank the github link of current file to X11 clipboard',
|
||||
\ 'call zvim#util#CopyToClipboard(1)')
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader><C-l>',
|
||||
\ ':<c-u>call zvim#util#CopyToClipboard(2)<cr>',
|
||||
\ 'Yank the github link of current line to X11 clipboard',
|
||||
\ 'call zvim#util#CopyToClipboard(2)')
|
||||
call SpaceVim#mapping#def('vnoremap <silent>', '<Leader><C-l>',
|
||||
\ ':<c-u>call zvim#util#CopyToClipboard(3)<cr>',
|
||||
\ 'Yank the github link of current selection to X11 clipboard',
|
||||
\ 'call zvim#util#CopyToClipboard(3)')
|
||||
call SpaceVim#mapping#def('vnoremap', '<Leader>S', "y:execute @@<CR>:echo 'Sourced selection.'<CR>",
|
||||
\ 'Sourced selection.',
|
||||
\ "echo 'Use <leader>S to sourced selection.'")
|
||||
call SpaceVim#mapping#def('nnoremap','<Leader>S',"^vg_y:execute @@<CR>:echo 'Sourced line.'<CR>",'Source line',
|
||||
\ "echo 'Use <leader>S to sourced line.'")
|
||||
" quickfix list movement
|
||||
let g:_spacevim_mappings.q = {'name' : 'Quickfix list movement'}
|
||||
call SpaceVim#mapping#def('nnoremap', '<Leader>qj', ':cnext<CR>',
|
||||
\ 'Jump to next quickfix list position',
|
||||
\ 'cnext',
|
||||
\ 'Next quickfix list')
|
||||
call SpaceVim#mapping#def('nnoremap', '<Leader>qk', ':cprev<CR>',
|
||||
\ 'Jump to previous quickfix list position',
|
||||
\ 'cprev',
|
||||
\ 'Previous quickfix list')
|
||||
call SpaceVim#mapping#def('nnoremap', '<Leader>qq', ':cclose<CR>',
|
||||
\ 'Close quickfix list window',
|
||||
\ 'cclose',
|
||||
\ 'Close quickfix list window')
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>qr', 'q',
|
||||
\ 'Toggle recording',
|
||||
\ '',
|
||||
\ 'Toggle recording mode')
|
||||
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>qr', 'q', 'Toggle recording','')
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sv', ':call SpaceVim#mapping#split_previous_buffer()<CR>',
|
||||
\'Open previous buffer in split window' , 'call SpaceVim#mapping#split_previous_buffer()')
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sg', ':call SpaceVim#mapping#vertical_split_previous_buffer()<CR>',
|
||||
\'Open previous buffer in vsplit window' , 'call SpaceVim#mapping#vertical_split_previous_buffer()')
|
||||
" Duplicate lines
|
||||
nnoremap <Leader>d m`YP``
|
||||
vnoremap <Leader>d YPgv
|
||||
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader><C-c>',
|
||||
\ ':<c-u>call zvim#util#CopyToClipboard(1)<cr>',
|
||||
\ 'Yank the github link of current file to X11 clipboard',
|
||||
\ 'call zvim#util#CopyToClipboard(1)')
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader><C-l>',
|
||||
\ ':<c-u>call zvim#util#CopyToClipboard(2)<cr>',
|
||||
\ 'Yank the github link of current line to X11 clipboard',
|
||||
\ 'call zvim#util#CopyToClipboard(2)')
|
||||
call SpaceVim#mapping#def('vnoremap <silent>', '<Leader><C-l>',
|
||||
\ ':<c-u>call zvim#util#CopyToClipboard(3)<cr>',
|
||||
\ 'Yank the github link of current selection to X11 clipboard',
|
||||
\ 'call zvim#util#CopyToClipboard(3)')
|
||||
call SpaceVim#mapping#def('vnoremap', '<Leader>S', "y:execute @@<CR>:echo 'Sourced selection.'<CR>",
|
||||
\ 'Sourced selection.',
|
||||
\ "echo 'Use <leader>S to sourced selection.'")
|
||||
call SpaceVim#mapping#def('nnoremap','<Leader>S',"^vg_y:execute @@<CR>:echo 'Sourced line.'<CR>",'Source line',
|
||||
\ "echo 'Use <leader>S to sourced line.'")
|
||||
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sv', ':call SpaceVim#mapping#split_previous_buffer()<CR>',
|
||||
\'Open previous buffer in split window' , 'call SpaceVim#mapping#split_previous_buffer()', 'Split previout buffer')
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sg', ':call SpaceVim#mapping#vertical_split_previous_buffer()<CR>',
|
||||
\'Open previous buffer in vsplit window' , 'call SpaceVim#mapping#vertical_split_previous_buffer()')
|
||||
endfunction
|
||||
function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort
|
||||
if !empty(a:key)
|
||||
call zvim#util#defineMap('nnoremap', '[Window]', '<Nop>' , 'Defind window prefix' ,'normal [Window]')
|
||||
call zvim#util#defineMap('nmap' , a:key, '[Window]', 'Use ' . a:key . ' as window prefix' ,'normal ' . a:key)
|
||||
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]p', ':<C-u>vsplit<CR>:wincmd w<CR>',
|
||||
\'vsplit vertically,switch to next window','vsplit | wincmd w')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]v', ':<C-u>split<CR>', 'split window','split')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]g', ':<C-u>vsplit<CR>', 'vsplit window','vsplit')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]t', ':<C-u>tabnew<CR>', 'Create new tab','tabnew')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]o', ':<C-u>only<CR>', 'Close other windows','only')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]x', ':<C-u>call zvim#util#BufferEmpty()<CR>',
|
||||
\'Empty current buffer','call zvim#util#BufferEmpty()')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]\', ':<C-u>b#<CR>', 'Switch to the last buffer','b#')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]q', ':<C-u>close<CR>', 'Close current windows','close')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]Q',
|
||||
\ ':<C-u>call SpaceVim#mapping#close_current_buffer()<CR>',
|
||||
\ 'delete current windows',
|
||||
\ 'call SpaceVim#mapping#close_current_buffer()')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]c', ':<C-u>call SpaceVim#mapping#clearBuffers()<CR>',
|
||||
\'Clear all the buffers','call SpaceVim#mapping#clearBuffers()')
|
||||
endif
|
||||
function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort
|
||||
if !empty(a:key)
|
||||
call zvim#util#defineMap('nnoremap', '[Window]', '<Nop>' , 'Defind window prefix' ,'normal [Window]')
|
||||
call zvim#util#defineMap('nmap' , a:key, '[Window]', 'Use ' . a:key . ' as window prefix' ,'normal ' . a:key)
|
||||
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]p', ':<C-u>vsplit<CR>:wincmd w<CR>',
|
||||
\'vsplit vertically,switch to next window','vsplit | wincmd w')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]v', ':<C-u>split<CR>', 'split window','split')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]g', ':<C-u>vsplit<CR>', 'vsplit window','vsplit')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]t', ':<C-u>tabnew<CR>', 'Create new tab','tabnew')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]o', ':<C-u>only<CR>', 'Close other windows','only')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]x', ':<C-u>call zvim#util#BufferEmpty()<CR>',
|
||||
\'Empty current buffer','call zvim#util#BufferEmpty()')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]\', ':<C-u>b#<CR>', 'Switch to the last buffer','b#')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]q', ':<C-u>close<CR>', 'Close current windows','close')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]Q',
|
||||
\ ':<C-u>call SpaceVim#mapping#close_current_buffer()<CR>',
|
||||
\ 'delete current windows',
|
||||
\ 'call SpaceVim#mapping#close_current_buffer()')
|
||||
call zvim#util#defineMap('nnoremap <silent>', '[Window]c', ':<C-u>call SpaceVim#mapping#clearBuffers()<CR>',
|
||||
\'Clear all the buffers','call SpaceVim#mapping#clearBuffers()')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#mapping#leader#defindUniteLeader(key) abort
|
||||
if !empty(a:key)
|
||||
" The prefix key.
|
||||
nnoremap [unite] <Nop>
|
||||
exe 'nmap ' .a:key . ' [unite]'
|
||||
nnoremap <silent> [unite]r
|
||||
\ :<C-u>Unite -buffer-name=resume resume<CR>
|
||||
if has('nvim')
|
||||
nnoremap <silent> [unite]f :<C-u>Unite file_rec/neovim<cr>
|
||||
else
|
||||
nnoremap <silent> [unite]f :<C-u>Unite file_rec/async<cr>
|
||||
endif
|
||||
nnoremap <silent> [unite]i :<C-u>Unite file_rec/git<cr>
|
||||
nnoremap <silent> [unite]g :<C-u>Unite grep<cr>
|
||||
nnoremap <silent> [unite]u :<C-u>Unite source<CR>
|
||||
nnoremap <silent> [unite]t :<C-u>Unite tag<CR>
|
||||
nnoremap <silent> [unite]T :<C-u>Unite tag/include<CR>
|
||||
nnoremap <silent> [unite]l :<C-u>Unite locationlist<CR>
|
||||
nnoremap <silent> [unite]q :<C-u>Unite quickfix<CR>
|
||||
nnoremap <silent> [unite]e :<C-u>Unite
|
||||
\ -buffer-name=register register<CR>
|
||||
nnoremap <silent> [unite]j :<C-u>Unite jump<CR>
|
||||
nnoremap <silent> [unite]h :<C-u>Unite history/yank<CR>
|
||||
nnoremap <silent> [unite]s :<C-u>Unite session<CR>
|
||||
nnoremap <silent> [unite]o :<C-u>Unite -buffer-name=outline -start-insert -auto-preview -split outline<CR>
|
||||
nnoremap <silent> [unite]ma
|
||||
\ :<C-u>Unite mapping<CR>
|
||||
nnoremap <silent> [unite]me
|
||||
\ :<C-u>Unite output:message<CR>
|
||||
|
||||
nnoremap <silent> [unite]c :<C-u>UniteWithCurrentDir
|
||||
\ -buffer-name=files buffer bookmark file<CR>
|
||||
nnoremap <silent> [unite]b :<C-u>UniteWithBufferDir
|
||||
\ -buffer-name=files -prompt=%\ buffer bookmark file<CR>
|
||||
nnoremap <silent> [unite]n :<C-u>Unite session/new<CR>
|
||||
nnoremap <silent> [unite]/ :Unite -auto-preview grep:.<cr>
|
||||
nnoremap <silent> [unite]w
|
||||
\ :<C-u>Unite -buffer-name=files -no-split
|
||||
\ jump_point file_point buffer_tab
|
||||
\ file_rec:! file file/new<CR>
|
||||
nnoremap <silent>[unite]<Space> :Unite -silent -ignorecase -winheight=17 -start-insert menu:CustomKeyMaps<CR>
|
||||
if !empty(a:key)
|
||||
" The prefix key.
|
||||
nnoremap [unite] <Nop>
|
||||
exe 'nmap ' .a:key . ' [unite]'
|
||||
nnoremap <silent> [unite]r
|
||||
\ :<C-u>Unite -buffer-name=resume resume<CR>
|
||||
if has('nvim')
|
||||
nnoremap <silent> [unite]f :<C-u>Unite file_rec/neovim<cr>
|
||||
else
|
||||
nnoremap <silent> [unite]f :<C-u>Unite file_rec/async<cr>
|
||||
endif
|
||||
nnoremap <silent> [unite]i :<C-u>Unite file_rec/git<cr>
|
||||
nnoremap <silent> [unite]g :<C-u>Unite grep<cr>
|
||||
nnoremap <silent> [unite]u :<C-u>Unite source<CR>
|
||||
nnoremap <silent> [unite]t :<C-u>Unite tag<CR>
|
||||
nnoremap <silent> [unite]T :<C-u>Unite tag/include<CR>
|
||||
nnoremap <silent> [unite]l :<C-u>Unite locationlist<CR>
|
||||
nnoremap <silent> [unite]q :<C-u>Unite quickfix<CR>
|
||||
nnoremap <silent> [unite]e :<C-u>Unite
|
||||
\ -buffer-name=register register<CR>
|
||||
nnoremap <silent> [unite]j :<C-u>Unite jump<CR>
|
||||
nnoremap <silent> [unite]h :<C-u>Unite history/yank<CR>
|
||||
nnoremap <silent> [unite]<C-h> :<C-u>UniteWithCursorWord help<CR>
|
||||
nnoremap <silent> [unite]s :<C-u>Unite session<CR>
|
||||
nnoremap <silent> [unite]o :<C-u>Unite -buffer-name=outline -start-insert -auto-preview -split outline<CR>
|
||||
nnoremap <silent> [unite]ma
|
||||
\ :<C-u>Unite mapping<CR>
|
||||
nnoremap <silent> [unite]me
|
||||
\ :<C-u>Unite output:message<CR>
|
||||
|
||||
nnoremap <silent> [unite]c :<C-u>UniteWithCurrentDir
|
||||
\ -buffer-name=files buffer bookmark file<CR>
|
||||
nnoremap <silent> [unite]b :<C-u>UniteWithBufferDir
|
||||
\ -buffer-name=files -prompt=%\ buffer bookmark file<CR>
|
||||
nnoremap <silent> [unite]n :<C-u>Unite session/new<CR>
|
||||
nnoremap <silent> [unite]/ :Unite -auto-preview grep:.<cr>
|
||||
nnoremap <silent> [unite]w
|
||||
\ :<C-u>Unite -buffer-name=files -no-split
|
||||
\ jump_point file_point buffer_tab
|
||||
\ file_rec:! file file/new<CR>
|
||||
nnoremap <silent>[unite]<Space> :Unite -silent -ignorecase -winheight=17 -start-insert menu:CustomKeyMaps<CR>
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim:set et sw=2 cc=80:
|
||||
|
@ -5,7 +5,7 @@ function! airline#extensions#tabline#formatters#spacevim#format(bufnr, buffers)
|
||||
let id = SpaceVim#api#messletters#get().bubble_num(a:bufnr, g:spacevim_buffer_index_type) . ' '
|
||||
let fn = airline#extensions#tabline#formatters#unique_tail_improved#format(a:bufnr, a:buffers)
|
||||
if g:spacevim_enable_tabline_filetype_icon
|
||||
let icon = SpaceVim#api#import('file').fticon(fn)
|
||||
let icon = SpaceVim#api#import('file').fticon(bufname(a:bufnr))
|
||||
if !empty(icon)
|
||||
let fn = icon . ' ' . fn
|
||||
endif
|
||||
|
@ -114,7 +114,7 @@ function! QuoteDelim(char)
|
||||
endif
|
||||
endf
|
||||
function! JspFileTypeInit()
|
||||
set tags+=/home/wsdjeg/others/openjdk-8-src/tags
|
||||
set tags+=~/others/openjdk-8-src/tags
|
||||
set omnifunc=javacomplete#Complete
|
||||
inoremap . <c-r>=OnmiConfigForJsp()<cr>
|
||||
nnoremap <F4> :JCimportAdd<cr>
|
||||
|
@ -202,8 +202,6 @@ call unite#custom#profile('buffer,buffer_tab', 'context', {
|
||||
\ 'keep_focus' : 1,
|
||||
\ })
|
||||
nnoremap <silent><leader>um :<C-u>Unite -start-insert mapping<CR>
|
||||
nnoremap <C-h> :<C-u>Unite -start-insert help<CR>
|
||||
nnoremap <silent> g<C-h> :<C-u>UniteWithCursorWord help<CR>
|
||||
"" Tag search
|
||||
""" For searching the word in the cursor in tag file
|
||||
nnoremap <silent><leader>f :<c-u>Unite tag/include:<C-R><C-w><CR>
|
||||
@ -219,12 +217,6 @@ noremap <silent><leader>vf :Unite -auto-preview -no-split grep:%::<C-r><C-w><CR>
|
||||
noremap <silent><leader>va :Unite -auto-preview -no-split grep:$buffers::<C-r><C-w><CR>
|
||||
nnoremap <silent><Leader>bl :<C-u>Unite -start-insert -buffer-name=buffer buffer<cr>
|
||||
nnoremap <silent><Leader>ta :<C-u>Unite -start-insert -buffer-name=tag tag<cr>
|
||||
"" outline
|
||||
nnoremap <silent><leader>o :<C-u>Unite -buffer-name=outline -start-insert -auto-preview -no-split outline<cr>
|
||||
"" Line search
|
||||
nnoremap <silent><leader>l :Unite line -start-insert -auto-preview -no-split<CR>
|
||||
"" Yank history
|
||||
nnoremap <silent><leader>y :<C-u>Unite -no-split -buffer-name=yank history/yank<cr>
|
||||
" search plugin
|
||||
" :Unite neobundle/search
|
||||
"for Unite menu{
|
||||
|
@ -38,17 +38,17 @@ let g:airline#extensions#tabline#fnamemod = ':t'
|
||||
let g:airline#extensions#tabline#fnamecollapse = 1
|
||||
let g:airline#extensions#tabline#fnametruncate = 0
|
||||
"let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
|
||||
nmap <leader>1 <Plug>AirlineSelectTab1
|
||||
nmap <leader>2 <Plug>AirlineSelectTab2
|
||||
nmap <leader>3 <Plug>AirlineSelectTab3
|
||||
nmap <leader>4 <Plug>AirlineSelectTab4
|
||||
nmap <leader>5 <Plug>AirlineSelectTab5
|
||||
nmap <leader>6 <Plug>AirlineSelectTab6
|
||||
nmap <leader>7 <Plug>AirlineSelectTab7
|
||||
nmap <leader>8 <Plug>AirlineSelectTab8
|
||||
nmap <leader>9 <Plug>AirlineSelectTab9
|
||||
nmap <leader>- <Plug>AirlineSelectPrevTab
|
||||
nmap <leader>+ <Plug>AirlineSelectNextTab
|
||||
call SpaceVim#mapping#def('nmap', '<leader>1', '<Plug>AirlineSelectTab1', 'Switch to airline tab 1', '', 'window 1')
|
||||
call SpaceVim#mapping#def('nmap', '<leader>2', '<Plug>AirlineSelectTab2', 'Switch to airline tab 2', '', 'window 2')
|
||||
call SpaceVim#mapping#def('nmap', '<leader>3', '<Plug>AirlineSelectTab3', 'Switch to airline tab 3', '', 'window 3')
|
||||
call SpaceVim#mapping#def('nmap', '<leader>4', '<Plug>AirlineSelectTab4', 'Switch to airline tab 4', '', 'window 4')
|
||||
call SpaceVim#mapping#def('nmap', '<leader>5', '<Plug>AirlineSelectTab5', 'Switch to airline tab 5', '', 'window 5')
|
||||
call SpaceVim#mapping#def('nmap', '<leader>6', '<Plug>AirlineSelectTab6', 'Switch to airline tab 6', '', 'window 6')
|
||||
call SpaceVim#mapping#def('nmap', '<leader>7', '<Plug>AirlineSelectTab7', 'Switch to airline tab 7', '', 'window 7')
|
||||
call SpaceVim#mapping#def('nmap', '<leader>8', '<Plug>AirlineSelectTab8', 'Switch to airline tab 8', '', 'window 8')
|
||||
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')
|
||||
if !exists('g:airline_symbols')
|
||||
let g:airline_symbols = {}
|
||||
endif
|
||||
|
8
config/plugins/vim-leader-guide.vim
Normal file
8
config/plugins/vim-leader-guide.vim
Normal file
@ -0,0 +1,8 @@
|
||||
let g:leaderGuide_max_size = 15
|
||||
let g:leaderGuide_submode_mappings =
|
||||
\ { '<C-C>': 'win_close', '<PageDown>': 'page_down', '<PageUp>': 'page_up'}
|
||||
let g:_spacevim_mappings.g = {'name' : 'git function',
|
||||
\ 'd' : ['Gita diff', 'git diff'],
|
||||
\ }
|
||||
call leaderGuide#register_prefix_descriptions("\\", 'g:_spacevim_mappings')
|
||||
call leaderGuide#register_prefix_descriptions("[unite]", 'g:_spacevim_unite_mappings')
|
@ -32,7 +32,6 @@ try
|
||||
\ 'auto_expand': 1,
|
||||
\ 'direction' : 'rightbelow',
|
||||
\ 'parent': 0,
|
||||
\ 'explorer_columns' : 'gitstatus',
|
||||
\ 'status' : 1,
|
||||
\ 'safe' : 0,
|
||||
\ 'split' : 1,
|
||||
|
@ -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*
|
||||
|
||||
|
@ -4,7 +4,7 @@ title: "APIs"
|
||||
|
||||
# SpaceVim public APIs:
|
||||
|
||||
SpaceVim provide many public apis, you can use this apis in your plugins.
|
||||
SpaceVim provide many public apis, you can use this apis in your plugins. SpaceVim api got inspired by [vital.vim](https://github.com/vim-jp/vital.vim)
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -26,6 +26,10 @@ title: "Documentation"
|
||||
|
||||
## Language specific mode
|
||||
|
||||
## Key Mapping
|
||||
|
||||
<iframe width='853' height='480' src='https://embed.coggle.it/diagram/WMlKuKS0uwABF2j1/a35e36df1d64e7b4f5fd7f956bf97a16b194cadb92d82d83e25aaf489349b0d8' frameborder='0' allowfullscreen></iframe>
|
||||
|
||||
### c/c++ support
|
||||
|
||||
1. code completion: autocompletion and fuzzy match.
|
||||
@ -83,6 +87,8 @@ Unite work flow leader can only be used in normal mode. Unite leader need unite
|
||||
|
||||
## Unite centric work-flow
|
||||
|
||||
![unite](https://cloud.githubusercontent.com/assets/13142418/23955542/26fd5348-09d5-11e7-8253-1f43991439b0.png)
|
||||
|
||||
- List all the plugins has been installed, fuzzy find what you want, default action is open the github website of current plugin. default key is `<leader>lp`
|
||||
![2017-01-21_1358x725](https://cloud.githubusercontent.com/assets/13142418/22175019/ce42d902-e027-11e6-89cd-4f44f70a10cd.png)
|
||||
|
||||
|
15
syntax/leaderGuide.vim
Normal file
15
syntax/leaderGuide.vim
Normal file
@ -0,0 +1,15 @@
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
let b:current_syntax = "leaderguide"
|
||||
|
||||
syn region LeaderGuideKeys start="\["hs=e+1 end="\]\s"he=s-1
|
||||
\ contained
|
||||
syn region LeaderGuideBrackets start="\(^\|\s\+\)\[" end="\]\s\+"
|
||||
\ contains=LeaderGuideKeys keepend
|
||||
syn region LeaderGuideDesc start="^" end="$"
|
||||
\ contains=LeaderGuideBrackets
|
||||
|
||||
hi def link LeaderGuideDesc Identifier
|
||||
hi def link LeaderGuideKeys Type
|
||||
hi def link LeaderGuideBrackets Delimiter
|
Loading…
Reference in New Issue
Block a user