1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-13 13:04:10 +08:00

Merge branch 'denite' into dev

This commit is contained in:
wsdjeg 2017-03-22 22:19:46 +08:00
commit 604d953ea8
8 changed files with 268 additions and 36 deletions

View File

@ -69,7 +69,7 @@ SpaceVim load custom configuration from `~/.SpaceVim.d/init.vim`,
here is an example:
```vim
```viml
" Here are some basic customizations, please refer to the ~/.SpaceVim.d/init.vim
" file for all possible options:
let g:spacevim_default_indent = 3
@ -142,7 +142,7 @@ Try these Neovim hangouts for any questions, problems or comments.
### Linux/Mac
```sh
```bash
curl -sLf https://spacevim.org/install.sh | bash
```
with this command, SpaceVim will be installed. all the plugins will be install automatically when first time run vim/nvim. Please wait for the end of the installation process.
@ -155,7 +155,7 @@ SpaceVim required Vim7.4 above or neovim, here is the installation of neovim/vim
for more info about the install script, please check:
```sh
```bash
curl -sLf https://spacevim.org/install.sh | bash -s -- -h
```
@ -173,7 +173,7 @@ curl -sLf https://spacevim.org/install.sh | bash -s -- -h
for more info, please check out [neovim's wiki](https://github.com/neovim/neovim/wiki/Installing-Neovim).
by default, when open a cmd, the current dir is your Home directory, run this command in cmd.
```sh
```bash
git clone https://github.com/SpaceVim/SpaceVim.git AppData\Local\nvim
```
@ -192,7 +192,7 @@ If you used SpaceVim in a project and you want to show that fact, you can use th
markdown
```markdown
```md
[![](https://spacevim.org/img/build-with-SpaceVim.svg)](https://spacevim.org)
```

View File

@ -64,6 +64,10 @@ let g:spacevim_windows_leader = 's'
" Unite work flow leader of SpaceVim. Default is `f`.
" Set to empty to disable this feature, or you can set to another char.
let g:spacevim_unite_leader = 'f'
""
" Denite work flow leader of SpaceVim. Default is `F`.
" Set to empty to disable this feature, or you can set to another char.
let g:spacevim_denite_leader = 'F'
let g:spacevim_neobundle_installed = 0
let g:spacevim_dein_installed = 0
let g:spacevim_vim_plug_installed = 0
@ -364,6 +368,9 @@ function! SpaceVim#end() abort
if !empty(g:spacevim_unite_leader)
call SpaceVim#mapping#leader#defindUniteLeader(g:spacevim_unite_leader)
endif
if !empty(g:spacevim_denite_leader)
call SpaceVim#mapping#leader#defindDeniteLeader(g:spacevim_denite_leader)
endif
call SpaceVim#mapping#leader#defindglobalMappings()
if g:spacevim_simple_mode
let g:spacevim_plugin_groups = ['core']

View File

@ -387,8 +387,14 @@ function! s:winopen() " {{{
setlocal nobuflisted buftype=nofile bufhidden=unload noswapfile
setlocal nocursorline nocursorcolumn colorcolumn=
setlocal winfixwidth winfixheight
setlocal statusline=\ Leader\ Guide
call s:updateStatusline()
endfunction " }}}
function! s:updateStatusline() abort
exe 'setlocal statusline=\ Leader\ Guide\ for:\ ' .
\ SpaceVim#mapping#leader#getName(s:prefix_key)
endfunction
function! s:winclose() " {{{
noautocmd execute s:gwin.'wincmd w'
if s:gwin == winnr()
@ -463,6 +469,7 @@ 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 ==? ' '
let s:prefix_key = a:key
if has('nvim') && !exists('s:reg')
let s:reg = ''
@ -503,6 +510,9 @@ call SpaceVim#mapping#guide#register_prefix_descriptions('\',
call SpaceVim#mapping#guide#register_prefix_descriptions(
\ g:spacevim_unite_leader,
\ 'g:_spacevim_mappings_unite')
call SpaceVim#mapping#guide#register_prefix_descriptions(
\ g:spacevim_denite_leader,
\ 'g:_spacevim_mappings_denite')
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -1,3 +1,11 @@
"=============================================================================
" leader.vim --- mapping leader definition file for SpaceVim
" Copyright (c) 2016-2017 Shidong Wang & Contributors
" Author: Shidong Wang < wsdjeg at 163.com >
" URL: https://spacevim.org
" License: MIT license
"=============================================================================
function! SpaceVim#mapping#leader#defindglobalMappings() abort
inoremap <silent> <Leader><Tab> <C-r>=MyLeaderTabfunc()<CR>
@ -89,46 +97,97 @@ function! SpaceVim#mapping#leader#defindglobalMappings() abort
\ ':<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>",
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',
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()')
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', '[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]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()')
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#defindDeniteLeader(key) abort
if !empty(a:key)
exe 'nnoremap <silent><nowait> [denite] :<c-u>LeaderGuide "' .
\ a:key . '"<CR>'
exe 'nmap ' .a:key . ' [denite]'
let g:_spacevim_mappings_denite = {}
nnoremap <silent> [denite]r
\ :<C-u>Denite -buffer-name=resume resume<CR>
let g:_spacevim_mappings_denite.r = ['Denite -buffer-name=resume resume',
\ 'resume denite window']
nnoremap <silent> [denite]f :<C-u>Denite file_rec<cr>
let g:_spacevim_mappings_denite.f = ['Denite file_rec', 'file_rec']
nnoremap <silent> [denite]g :<C-u>Denite grep<cr>
let g:_spacevim_mappings_denite.g = ['Denite grep', 'denite grep']
nnoremap <silent> [denite]j :<C-u>Denite jump<CR>
let g:_spacevim_mappings_denite.j = ['Denite jump', 'denite jump']
nnoremap <silent> [denite]<C-h> :<C-u>DeniteCursorWord help<CR>
let g:_spacevim_mappings_denite['<C-h>'] = ['DeniteCursorWord help',
\ 'denite with cursor word help']
nnoremap <silent> [denite]o :<C-u>Denite -buffer-name=outline
\ -auto-preview outline<CR>
let g:_spacevim_mappings_denite.o = ['Denite outline', 'denite outline']
nnoremap <silent> [denite]e :<C-u>Denite
\ -buffer-name=register register<CR>
let g:_spacevim_mappings_denite.e = ['Denite register', 'denite register']
nnoremap <silent> [denite]<Space> :Denite menu:CustomKeyMaps<CR>
let g:_spacevim_mappings_denite['<space>'] = ['Denite menu:CustomKeyMaps',
\ 'denite customkeymaps']
endif
endfunction
function! SpaceVim#mapping#leader#defindUniteLeader(key) abort
if !empty(a:key)
" The prefix key.
exe 'nnoremap <silent><nowait> [unite] :<c-u>LeaderGuide "' . a:key . '"<CR>'
exe 'nnoremap <silent><nowait> [unite] :<c-u>LeaderGuide "' .
\ a:key . '"<CR>'
exe 'nmap ' .a:key . ' [unite]'
let g:_spacevim_mappings_unite = {}
nnoremap <silent> [unite]r
@ -164,12 +223,15 @@ function! SpaceVim#mapping#leader#defindUniteLeader(key) abort
nnoremap <silent> [unite]j :<C-u>Unite jump<CR>
let g:_spacevim_mappings_unite.j = ['Unite jump', 'unite jump']
nnoremap <silent> [unite]h :<C-u>Unite history/yank<CR>
let g:_spacevim_mappings_unite.h = ['Unite history/yank', 'unite history/yank']
let g:_spacevim_mappings_unite.h = ['Unite history/yank',
\ 'unite history/yank']
nnoremap <silent> [unite]<C-h> :<C-u>UniteWithCursorWord help<CR>
let g:_spacevim_mappings_unite['<C-h>'] = ['UniteWithCursorWord help', 'unite with cursor word help']
let g:_spacevim_mappings_unite['<C-h>'] = ['UniteWithCursorWord help',
\ 'unite with cursor word help']
nnoremap <silent> [unite]s :<C-u>Unite session<CR>
let g:_spacevim_mappings_unite.s = ['Unite session', 'unite session']
nnoremap <silent> [unite]o :<C-u>Unite -buffer-name=outline -start-insert -auto-preview -split outline<CR>
nnoremap <silent> [unite]o :<C-u>Unite -buffer-name=outline
\ -start-insert -auto-preview -split outline<CR>
let g:_spacevim_mappings_unite.o = ['Unite outline', 'unite outline']
" menu
@ -194,9 +256,11 @@ function! SpaceVim#mapping#leader#defindUniteLeader(key) abort
\ ' buffer bookmark file',
\ 'unite files in current dir']
nnoremap <silent> [unite]n :<C-u>Unite session/new<CR>
let g:_spacevim_mappings_unite.n = ['Unite session/new', 'unite session/new']
let g:_spacevim_mappings_unite.n = ['Unite session/new',
\ 'unite session/new']
nnoremap <silent> [unite]/ :Unite -auto-preview grep:.<cr>
let g:_spacevim_mappings_unite['/'] = ['Unite -auto-preview grep:.', 'unite grep with preview']
let g:_spacevim_mappings_unite['/'] = ['Unite -auto-preview grep:.',
\ 'unite grep with preview']
nnoremap <silent> [unite]w
\ :<C-u>Unite -buffer-name=files -no-split
\ jump_point file_point buffer_tab
@ -204,11 +268,22 @@ function! SpaceVim#mapping#leader#defindUniteLeader(key) abort
let g:_spacevim_mappings_unite.w= ['Unite -buffer-name=files -no-split' .
\ ' jump_point file_point buffer_tab file_rec:! file file/new',
\ 'unite all file and jump']
nnoremap <silent>[unite]<Space> :Unite -silent -ignorecase -winheight=17 -start-insert menu:CustomKeyMaps<CR>
nnoremap <silent>[unite]<Space> :Unite -silent -ignorecase -winheight=17
\ -start-insert menu:CustomKeyMaps<CR>
let g:_spacevim_mappings_unite['<space>'] = ['Unite -silent -ignorecase' .
\ ' -winheight=17 -start-insert menu:CustomKeyMaps',
\ 'unite customkeymaps']
endif
endfunction
function! SpaceVim#mapping#leader#getName(key) abort
if a:key == g:spacevim_unite_leader
return '[unite]'
elseif a:key == g:spacevim_denite_leader
return '[denite]'
else
return '<leader>'
endif
endfunction
" vim:set et sw=2 cc=80:

View File

@ -272,7 +272,7 @@ fu! zvim#util#Generate_ignore(ignore,tool) abort
if a:tool ==# 'ag'
for ig in split(a:ignore,',')
call add(ignore, '--ignore')
call add(ignore, '"' . ig . '"')
call add(ignore, ig )
endfor
elseif a:tool ==# 'rg'
for ig in split(a:ignore,',')

View File

@ -1,4 +1,4 @@
let g:ctrlp_map = '<c-p>'
let g:ctrlp_map = get(g:,'ctrlp_map', '<c-p>')
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_root_markers = 'pom.xml'

View File

@ -1 +1,137 @@
let g:denite_config_loaded = 1
scriptencoding utf-8
" load api
let s:sys = SpaceVim#api#import('system')
" denite option
let s:denite_options = {'default' : {
\ 'winheight' : 15,
\ 'mode' : 'insert',
\ 'quit' : 'true',
\ 'highlight_matched_char' : 'MoreMsg',
\ 'highlight_matched_range' : 'MoreMsg',
\ 'direction': 'rightbelow',
\ 'statusline' : 'false',
\ 'prompt' : '➭',
\ }}
function! s:profile(opts) abort
for fname in keys(a:opts)
for dopt in keys(a:opts[fname])
call denite#custom#option(fname, dopt, a:opts[fname][dopt])
endfor
endfor
endfunction
call s:profile(s:denite_options)
" buffer source
call denite#custom#var(
\ 'buffer',
\ 'date_format', '%m-%d-%Y %H:%M:%S')
" denite command
if !s:sys.isWindows
if executable('rg')
" For ripgrep
" Note: It is slower than ag
call denite#custom#var('file_rec', 'command',
\ ['rg', '--hidden', '--files', '--glob', '!.git', '']
\ + zvim#util#Generate_ignore(g:spacevim_wildignore, 'rg')
\ )
elseif executable('ag')
" Change file_rec command.
call denite#custom#var('file_rec', 'command',
\ ['ag' , '--nocolor', '--nogroup', '-g', '']
\ + zvim#util#Generate_ignore(g:spacevim_wildignore, 'ag')
\ )
endif
else
if executable('pt')
" For Pt(the platinum searcher)
" NOTE: It also supports windows.
call denite#custom#var('file_rec', 'command',
\ ['pt', '--follow', '--nocolor', '--nogroup', '-g:', ''])
endif
endif
" FIND and GREP COMMANDS
if executable('rg')
" Ripgrep command on grep source
call denite#custom#var('grep', 'command', ['rg'])
call denite#custom#var('grep', 'default_opts',
\ ['--vimgrep', '--no-heading'])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('grep', 'pattern_opt', ['--regexp'])
call denite#custom#var('grep', 'separator', ['--'])
call denite#custom#var('grep', 'final_opts', [])
elseif executable('pt')
" Pt command on grep source
call denite#custom#var('grep', 'command', ['pt'])
call denite#custom#var('grep', 'default_opts',
\ ['--nogroup', '--nocolor', '--smart-case'])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('grep', 'pattern_opt', [])
call denite#custom#var('grep', 'separator', ['--'])
call denite#custom#var('grep', 'final_opts', [])
elseif executable('ag')
call denite#custom#var('grep', 'command', ['ag'])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('grep', 'pattern_opt', [])
call denite#custom#var('grep', 'separator', ['--'])
call denite#custom#var('grep', 'final_opts', [])
call denite#custom#var('grep', 'default_opts',
\ [ '--vimgrep', '--smart-case' ])
elseif executable('ack')
" Ack command
call denite#custom#var('grep', 'command', ['ack'])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('grep', 'pattern_opt', ['--match'])
call denite#custom#var('grep', 'separator', ['--'])
call denite#custom#var('grep', 'final_opts', [])
call denite#custom#var('grep', 'default_opts',
\ ['--ackrc', $HOME.'/.config/ackrc', '-H',
\ '--nopager', '--nocolor', '--nogroup', '--column'])
endif
" enable unite menu compatibility
call denite#custom#var('menu', 'unite_source_menu_compatibility', 1)
" KEY MAPPINGS
let s:insert_mode_mappings = [
\ ['jk', '<denite:enter_mode:normal>', 'noremap'],
\ ['<Tab>', '<denite:move_to_next_line>', 'noremap'],
\ ['<S-tab>', '<denite:move_to_previous_line>', 'noremap'],
\ ['<Esc>', '<denite:enter_mode:normal>', 'noremap'],
\ ['<C-N>', '<denite:assign_next_matched_text>', 'noremap'],
\ ['<C-P>', '<denite:assign_previous_matched_text>', 'noremap'],
\ ['<Up>', '<denite:assign_previous_text>', 'noremap'],
\ ['<Down>', '<denite:assign_next_text>', 'noremap'],
\ ['<C-Y>', '<denite:redraw>', 'noremap'],
\ ]
let s:normal_mode_mappings = [
\ ["'", '<denite:toggle_select_down>', 'noremap'],
\ ['<C-n>', '<denite:jump_to_next_source>', 'noremap'],
\ ['<C-p>', '<denite:jump_to_previous_source>', 'noremap'],
\ ['gg', '<denite:move_to_first_line>', 'noremap'],
\ ['st', '<denite:do_action:tabopen>', 'noremap'],
\ ['sg', '<denite:do_action:vsplit>', 'noremap'],
\ ['sv', '<denite:do_action:split>', 'noremap'],
\ ['q', '<denite:quit>', 'noremap'],
\ ['r', '<denite:redraw>', 'noremap'],
\ ]
for s:m in s:insert_mode_mappings
call denite#custom#map('insert', s:m[0], s:m[1], s:m[2])
endfor
for s:m in s:normal_mode_mappings
call denite#custom#map('normal', s:m[0], s:m[1], s:m[2])
endfor
unlet s:m s:insert_mode_mappings s:normal_mode_mappings
" vim:set et sw=2 cc=80:

View File

@ -97,6 +97,10 @@ this feature, or you can set to another char.
*g:spacevim_unite_leader*
Unite work flow leader of SpaceVim. Default is `f`. Set to empty to disable
this feature, or you can set to another char.
*g:spacevim_denite_leader*
Denite work flow leader of SpaceVim. Default is `F`. Set to empty to disable
this feature, or you can set to another char.
*g:spacevim_plugin_bundle_dir*