diff --git a/autoload/SpaceVim/default.vim b/autoload/SpaceVim/default.vim index ea6551255..db662e66a 100644 --- a/autoload/SpaceVim/default.vim +++ b/autoload/SpaceVim/default.vim @@ -365,6 +365,7 @@ function! SpaceVim#default#SetMappings() abort call SpaceVim#mapping#def('nnoremap ', 'sg', ':vsplit:wincmd p:e#', \'Open previous buffer in vsplit window' , 'vsplit|wincmd p|e#') call SpaceVim#mapping#def('nnoremap ', 'gf', ':call zvim#gf()', 'Jump to a file under cursor', '') + call SpaceVim#mapping#def('nnoremap ', 'gd', ':call SpaceVim#mapping#gd()', 'Goto declaration', '') endfunction fu! s:tobur(num) abort diff --git a/autoload/SpaceVim/layers/autocomplete.vim b/autoload/SpaceVim/layers/autocomplete.vim index 6047cebb4..b7a470973 100644 --- a/autoload/SpaceVim/layers/autocomplete.vim +++ b/autoload/SpaceVim/layers/autocomplete.vim @@ -22,7 +22,6 @@ function! SpaceVim#layers#autocomplete#plugins() abort \ ['honza/vim-snippets', {'on_i' : 1, 'loadconf_before' : 1}], \ ['Shougo/neco-syntax', { 'on_i' : 1}], \ ['ujihisa/neco-look', { 'on_i' : 1}], - \ ['Shougo/neco-vim', { 'on_i' : 1, 'loadconf_before' : 1}], \ ['Shougo/context_filetype.vim', { 'on_i' : 1}], \ ['Shougo/neoinclude.vim', { 'on_i' : 1}], \ ['Shougo/neosnippet-snippets', { 'merged' : 0}], diff --git a/autoload/SpaceVim/layers/git.vim b/autoload/SpaceVim/layers/git.vim index 854f0cc0c..d16df70fa 100644 --- a/autoload/SpaceVim/layers/git.vim +++ b/autoload/SpaceVim/layers/git.vim @@ -19,4 +19,8 @@ function! SpaceVim#layers#git#config() abort nmap hk (signify-prev-hunk) nmap hJ 9999gj nmap hK 9999gk + augroup spacevim_layer_git + autocmd! + autocmd FileType diff nnoremap q :bd! + augroup END endfunction diff --git a/autoload/SpaceVim/layers/lang/go.vim b/autoload/SpaceVim/layers/lang/go.vim index 84f4515b2..05f2c00a1 100644 --- a/autoload/SpaceVim/layers/lang/go.vim +++ b/autoload/SpaceVim/layers/lang/go.vim @@ -1,3 +1,22 @@ +"" +" @section lang#go, layer-lang-go +" @parentsection layers +" This layer support go development, include code completion and syntax check. +" @subsection mappings +" > +" mode key function +" normal gi go implements +" normal gf go info +" normal ge go rename +" normal gr go run +" normal gb go build +" normal gt go test +" normal gd go doc +" normal gv go doc vertical +" normal gco go coverage +" < + + function! SpaceVim#layers#lang#go#plugins() abort let plugins = [['fatih/vim-go', { 'on_ft' : 'go', 'loadconf_before' : 1}]] if has('nvim') @@ -16,18 +35,18 @@ function! SpaceVim#layers#lang#go#config() abort let g:go_fmt_command = 'goimports' let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck'] let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] } - let g:go_snippet_engine = "neosnippet" + let g:go_snippet_engine = 'neosnippet' augroup SpaceVim_go au! - au FileType go nmap s (go-implements) - au FileType go nmap i (go-info) - au FileType go nmap e (go-rename) - au FileType go nmap r (go-run) - au FileType go nmap b (go-build) - au FileType go nmap t (go-test) - au FileType go nmap gd (go-doc) - au FileType go nmap gv (go-doc-vertical) - au FileType go nmap co (go-coverage) + au FileType go nmap s (go-implements) + au FileType go nmap i (go-info) + au FileType go nmap e (go-rename) + au FileType go nmap r (go-run) + au FileType go nmap b (go-build) + au FileType go nmap t (go-test) + au FileType go nmap gd (go-doc) + au FileType go nmap gv (go-doc-vertical) + au FileType go nmap co (go-coverage) augroup END endfunction diff --git a/autoload/SpaceVim/layers/lang/vim.vim b/autoload/SpaceVim/layers/lang/vim.vim new file mode 100644 index 000000000..1aa54ca52 --- /dev/null +++ b/autoload/SpaceVim/layers/lang/vim.vim @@ -0,0 +1,12 @@ +function! SpaceVim#layers#lang#vim#plugins() abort + let plugins = [] + call add(plugins,['tweekmonster/exception.vim']) + call add(plugins,['mhinz/vim-lookup']) + call add(plugins,['Shougo/neco-vim', { 'on_i' : 1, 'loadconf_before' : 1}]) + call add(plugins,['tweekmonster/helpful.vim', {'on_cmd': 'HelpfulVersion'}]) + return plugins +endfunction + +function! SpaceVim#layers#lang#vim#config() abort + call SpaceVim#mapping#gd#add('vim','lookup#lookup') +endfunction diff --git a/autoload/SpaceVim/layers/tools.vim b/autoload/SpaceVim/layers/tools.vim index 37d0af92d..0612a5bb4 100644 --- a/autoload/SpaceVim/layers/tools.vim +++ b/autoload/SpaceVim/layers/tools.vim @@ -6,7 +6,6 @@ function! SpaceVim#layers#tools#plugins() abort \ ['junegunn/goyo.vim', { 'on_cmd' : 'Goyo', 'loadconf' : 1}], \ ['Yggdroot/LeaderF', {'merged' : 0}], \ ['google/vim-searchindex'], - \ ['tweekmonster/helpful.vim', {'on_cmd': 'HelpfulVersion'}], \ ['simnalamburt/vim-mundo', { 'on_cmd' : 'MundoToggle'}], \ ['wsdjeg/MarkDown.pl', { 'on_cmd' : 'MarkDownPreview'}], \ ['mhinz/vim-grepper' , { 'on_cmd' : 'Grepper', 'loadconf' : 1} ], diff --git a/autoload/SpaceVim/mapping.vim b/autoload/SpaceVim/mapping.vim index 810bacd8f..df4c71478 100644 --- a/autoload/SpaceVim/mapping.vim +++ b/autoload/SpaceVim/mapping.vim @@ -56,3 +56,11 @@ function! SpaceVim#mapping#enter() abort return "\" endif endfunction + +function! SpaceVim#mapping#gd() abort + if !empty(SpaceVim#mapping#gd#get()) + call call(SpaceVim#mapping#gd#get(), []) + else + normal! gd + endif +endfunction diff --git a/autoload/SpaceVim/mapping/gd.vim b/autoload/SpaceVim/mapping/gd.vim new file mode 100644 index 000000000..72c39f0ec --- /dev/null +++ b/autoload/SpaceVim/mapping/gd.vim @@ -0,0 +1,8 @@ +let s:gd = {} +function! SpaceVim#mapping#gd#add(ft, func) abort + call extend(s:gd,{a:ft : a:func}) +endfunction + +function! SpaceVim#mapping#gd#get() abort + return get(s:gd, &filetype, '') +endfunction diff --git a/autoload/SpaceVim/options.vim b/autoload/SpaceVim/options.vim index 3a6a2cf2e..2c04827cc 100644 --- a/autoload/SpaceVim/options.vim +++ b/autoload/SpaceVim/options.vim @@ -1,11 +1,25 @@ function! SpaceVim#options#list() abort let list = [] - if has('patch-7.4.2010') + if has('patch-7.4.2010') && 0 for var in getcompletion('g:spacevim_','var') call add(list, var . ' = ' . string(get(g:, var[2:] , ''))) endfor else - call add(list, 'your vim is too old, getcompletion() need patch7-4-2010') + redraw + for var in filter(map(s:execute('let g:'), "matchstr(v:val, '\\S\\+')"), "v:val =~# '^spacevim_'") + call add(list,'g:' . var . ' = ' . string(get(g:, var , ''))) + endfor endif return list endfunction + +function! s:execute(cmd) abort + if exists('*execute') + return split(execute(a:cmd), "\n") + endif + + redir => output + execute a:cmd + redir END + return split(output, "\n") +endfunction diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 52262e104..02b49c298 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -10,10 +10,11 @@ CONTENTS *SpaceVim-contents* 1. autocomplete..................................|SpaceVim-autocomplete| 2. colorscheme....................................|SpaceVim-colorscheme| 3. lang#c........................................|SpaceVim-layer-lang-c| - 4. lang#java..................................|SpaceVim-layer-lang-java| - 5. lang#php....................................|SpaceVim-layer-lang-php| - 6. lang#rust..................................|SpaceVim-layer-lang-rust| - 7. lang#xml....................................|SpaceVim-layer-lang-xml| + 4. lang#go......................................|SpaceVim-layer-lang-go| + 5. lang#java..................................|SpaceVim-layer-lang-java| + 6. lang#php....................................|SpaceVim-layer-lang-php| + 7. lang#rust..................................|SpaceVim-layer-lang-rust| + 8. lang#xml....................................|SpaceVim-layer-lang-xml| 5. FAQ........................................................|SpaceVim-faq| ============================================================================== @@ -426,6 +427,25 @@ get completions within conditional preprocessor blocks. The default is 50, setting it to 0 disables this feature. +============================================================================== +LANG#GO *SpaceVim-layer-lang-go* + +This layer support go development, include code completion and syntax check. +MAPPINGS + +> + mode key function + normal gi go implements + normal gf go info + normal ge go rename + normal gr go run + normal gb go build + normal gt go test + normal gd go doc + normal gv go doc vertical + normal gco go coverage +< + ============================================================================== LANG#JAVA *SpaceVim-layer-lang-java*