- Renamed commands.
This commit is contained in:
parent
f065035e7f
commit
e3fa0bbf64
@ -40,18 +40,6 @@ function! s:source.initialize()"{{{
|
|||||||
\ g:neocomplcache_auto_completion_start_length)
|
\ g:neocomplcache_auto_completion_start_length)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:source.finalize()"{{{
|
|
||||||
delcommand NeoComplCacheEditSnippets
|
|
||||||
delcommand NeoComplCacheEditRuntimeSnippets
|
|
||||||
delcommand NeoComplCacheCachingSnippets
|
|
||||||
|
|
||||||
hi clear NeoComplCacheExpandSnippets
|
|
||||||
|
|
||||||
if neocomplcache#exists_echodoc()
|
|
||||||
call echodoc#unregister('snippets_complete')
|
|
||||||
endif
|
|
||||||
endfunction"}}}
|
|
||||||
|
|
||||||
function! s:source.get_keyword_pos(cur_text)"{{{
|
function! s:source.get_keyword_pos(cur_text)"{{{
|
||||||
return match(a:cur_text, '\S\+$')
|
return match(a:cur_text, '\S\+$')
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
@ -63,7 +51,7 @@ function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)"{{{
|
|||||||
\ neosnippet#get_filetype())
|
\ neosnippet#get_filetype())
|
||||||
if !has_key(all_snippets, filetype)
|
if !has_key(all_snippets, filetype)
|
||||||
" Caching snippets.
|
" Caching snippets.
|
||||||
call neosnippet#caching_snippets(filetype)
|
call neosnippet#make_cache(filetype)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
@ -36,6 +36,13 @@ call neosnippet#util#set_default('g:neosnippet#disable_select_mode_mappings',
|
|||||||
\ 0, 'g:neocomplcache_disable_select_mode_mappings')
|
\ 0, 'g:neocomplcache_disable_select_mode_mappings')
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
" Variables "{{{
|
||||||
|
let s:neosnippet_options = [
|
||||||
|
\ '-runtime',
|
||||||
|
\ '-vertical', '-horizontal', '-direction=', '-split',
|
||||||
|
\]
|
||||||
|
"}}}
|
||||||
|
|
||||||
function! s:initialize()"{{{
|
function! s:initialize()"{{{
|
||||||
" Initialize.
|
" Initialize.
|
||||||
let s:snippets_expand_stack = []
|
let s:snippets_expand_stack = []
|
||||||
@ -101,7 +108,7 @@ function! s:initialize()"{{{
|
|||||||
endif"}}}
|
endif"}}}
|
||||||
|
|
||||||
" Caching _ snippets.
|
" Caching _ snippets.
|
||||||
call neosnippet#caching_snippets('_')
|
call neosnippet#make_cache('_')
|
||||||
|
|
||||||
" Initialize check.
|
" Initialize check.
|
||||||
call neosnippet#caching()
|
call neosnippet#caching()
|
||||||
@ -166,7 +173,7 @@ function! neosnippet#jumpable()"{{{
|
|||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#caching()"{{{
|
function! neosnippet#caching()"{{{
|
||||||
call neosnippet#caching_snippets(&filetype)
|
call neosnippet#make_cache(&filetype)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:set_snippet_dict(snippet_pattern, snippet_dict, dup_check, snippets_file)"{{{
|
function! s:set_snippet_dict(snippet_pattern, snippet_dict, dup_check, snippets_file)"{{{
|
||||||
@ -219,25 +226,30 @@ function! s:set_snippet_pattern(dict)"{{{
|
|||||||
return dict
|
return dict
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#edit_snippets(filetype, isruntime)"{{{
|
function! neosnippet#edit_snippets(args)"{{{
|
||||||
let filetype = a:filetype
|
let [args, options] = neosnippet#util#parse_options(
|
||||||
|
\ a:args, s:neosnippet_options)
|
||||||
|
|
||||||
|
let filetype = get(args, 0, '')
|
||||||
if filetype == ''
|
if filetype == ''
|
||||||
let filetype = neosnippet#get_filetype()
|
let filetype = neosnippet#get_filetype()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let options = s:initialize_options(options)
|
||||||
|
|
||||||
|
if options.runtime && empty(s:runtime_dir)
|
||||||
|
\ || !options.runtime && empty(s:snippets_dir)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
" Edit snippet file.
|
" Edit snippet file.
|
||||||
if a:isruntime
|
let filename = (options.runtime ? s:runtime_dir[0] : s:snippets_dir[-1])
|
||||||
if empty(s:runtime_dir)
|
\ .'/'.filetype.'.snip'
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let filename = s:runtime_dir[0].'/'.filetype.'.snip'
|
if options.split
|
||||||
else
|
" Split window.
|
||||||
if empty(s:snippets_dir)
|
execute options.direction
|
||||||
return
|
\ (options.vertical ? 'vnew' : 'new')
|
||||||
endif
|
|
||||||
|
|
||||||
let filename = s:snippets_dir[-1].'/'.filetype.'.snip'
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if filereadable(filename)
|
if filereadable(filename)
|
||||||
@ -249,7 +261,26 @@ function! neosnippet#edit_snippets(filetype, isruntime)"{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#caching_snippets(filetype)"{{{
|
function! s:initialize_options(options)"{{{
|
||||||
|
let default_options = {
|
||||||
|
\ 'runtime' : 0,
|
||||||
|
\ 'vertical' : 0,
|
||||||
|
\ 'direction' : 'belowleft',
|
||||||
|
\ 'split' : 0,
|
||||||
|
\ }
|
||||||
|
|
||||||
|
let options = extend(default_options, a:options)
|
||||||
|
|
||||||
|
" Complex initializer.
|
||||||
|
if has_key(options, 'horizontal')
|
||||||
|
" Disable vertically.
|
||||||
|
let context.vertical = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
return options
|
||||||
|
endfunction"}}}
|
||||||
|
|
||||||
|
function! neosnippet#make_cache(filetype)"{{{
|
||||||
let filetype = a:filetype == '' ?
|
let filetype = a:filetype == '' ?
|
||||||
\ &filetype : a:filetype
|
\ &filetype : a:filetype
|
||||||
if filetype ==# ''
|
if filetype ==# ''
|
||||||
@ -782,7 +813,7 @@ endfunction"}}}
|
|||||||
function! neosnippet#get_snippets()"{{{
|
function! neosnippet#get_snippets()"{{{
|
||||||
if !has_key(s:snippets, '_')
|
if !has_key(s:snippets, '_')
|
||||||
" Caching _ snippets.
|
" Caching _ snippets.
|
||||||
call neosnippet#caching_snippets('_')
|
call neosnippet#make_cache('_')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Get buffer filetype.
|
" Get buffer filetype.
|
||||||
@ -808,6 +839,10 @@ function! s:get_sources_list(snippets, filetype)"{{{
|
|||||||
\ neocomplcache#get_sources_list(a:snippets, a:filetype) : a:filetype
|
\ neocomplcache#get_sources_list(a:snippets, a:filetype) : a:filetype
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
function! neosnippet#edit_complete(arglead, cmdline, cursorpos)"{{{
|
||||||
|
return filter(s:neosnippet_options + neosnippet#filetype_complete(
|
||||||
|
\ a:arglead, a:cmdline, a:cursorpos), 'stridx(v:val, a:arglead) == 0')
|
||||||
|
endfunction"}}}
|
||||||
" Complete filetype helper.
|
" Complete filetype helper.
|
||||||
function! neosnippet#filetype_complete(arglead, cmdline, cursorpos)"{{{
|
function! neosnippet#filetype_complete(arglead, cmdline, cursorpos)"{{{
|
||||||
" Dup check.
|
" Dup check.
|
||||||
|
@ -84,6 +84,30 @@ function! neosnippet#util#print_error(string)"{{{
|
|||||||
echohl Error | echomsg a:string | echohl None
|
echohl Error | echomsg a:string | echohl None
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
function! neosnippet#util#parse_options(args, options_list)"{{{
|
||||||
|
let args = []
|
||||||
|
let options = {}
|
||||||
|
for arg in split(a:args, '\%(\\\@<!\s\)\+')
|
||||||
|
let arg = substitute(arg, '\\\( \)', '\1', 'g')
|
||||||
|
|
||||||
|
let matched_list = filter(copy(a:options_list),
|
||||||
|
\ 'stridx(arg, v:val) == 0')
|
||||||
|
for option in matched_list
|
||||||
|
let key = substitute(substitute(option, '-', '_', 'g'), '=$', '', '')[1:]
|
||||||
|
let options[key] = (option =~ '=$') ?
|
||||||
|
\ arg[len(option) :] : 1
|
||||||
|
break
|
||||||
|
endfor
|
||||||
|
|
||||||
|
if empty(matched_list)
|
||||||
|
call add(args, arg)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return [args, options]
|
||||||
|
endfunction"}}}
|
||||||
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
unlet s:save_cpo
|
unlet s:save_cpo
|
||||||
|
|
||||||
|
@ -58,34 +58,65 @@ INTERFACE *neosnippet-interface*
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
COMMANDS *neosnippet-commands*
|
COMMANDS *neosnippet-commands*
|
||||||
|
|
||||||
:NeoComplCacheCachingSnippets [filetype]
|
:NeoSnippetMakeCache [filetype]
|
||||||
*:NeoComplCacheCachingSnippets*
|
*:NeoSnippetMakeCache*
|
||||||
Makes cache of [filetype] snippets. It automatically selects
|
Makes cache of [filetype] snippets. It automatically selects
|
||||||
current buffer's filetype unless you specify [filetype].
|
current buffer's filetype unless you specify [filetype].
|
||||||
|
|
||||||
:NeoComplCacheEditSnippets [filetype]
|
*:NeoSnippetMakeCache-options*
|
||||||
|
{options} are options for the command. You may give the
|
||||||
|
following parameters for a option; you must escape with "\"
|
||||||
|
when it contains spaces.
|
||||||
|
|
||||||
|
*neosnippet-edit-options-vertical*
|
||||||
|
-vertical
|
||||||
|
Splits window vertically.
|
||||||
|
|
||||||
|
*neosnippet-edit-options-horizontal*
|
||||||
|
-horizontal
|
||||||
|
Splits window horizontally.
|
||||||
|
|
||||||
|
The behavior is undefined when both options are defined.
|
||||||
|
|
||||||
|
*neosnippet-edit-options-direction*
|
||||||
|
-direction={direction}
|
||||||
|
Defines split position rule. The default value is "belowleft".
|
||||||
|
|
||||||
|
*neosnippet-edit-options-split*
|
||||||
|
-split
|
||||||
|
Split buffer.
|
||||||
|
|
||||||
|
*neosnippet-edit-options-runtime*
|
||||||
|
-runtime
|
||||||
|
Edit runtime snippets instead of user snippets.
|
||||||
|
|
||||||
|
*:NeoComplCacheCachingSnippets*
|
||||||
|
Note: |:NeoComplCacheCachingSnippets| is obsolute name.
|
||||||
|
|
||||||
|
:NeoSnippetEdit [{options}] [filetype]
|
||||||
|
*:NeoSnippetEdit*
|
||||||
|
Opens [filetype] snippets to edit. It automatically selects
|
||||||
|
current buffer's filetype unless you specify [filetype].
|
||||||
|
|
||||||
|
If [filetype] snippet file doesn't exist, it creates one
|
||||||
|
automatically.
|
||||||
|
|
||||||
|
It edits a snippet file in |g:neosnippet#snippets_directory|
|
||||||
|
with precedence.
|
||||||
|
Re-make cache will be done automatically when you save the
|
||||||
|
file.
|
||||||
|
|
||||||
*:NeoComplCacheEditSnippets*
|
*:NeoComplCacheEditSnippets*
|
||||||
Opens [filetype] snippets to edit. It automatically selects
|
Note: |:NeoComplCacheEditSnippets| is obsolute name.
|
||||||
current buffer's filetype unless you specify [filetype].
|
|
||||||
|
|
||||||
If [filetype] snippet file doesn't exist, it creates one
|
:NeoComplCacheEdit -runtime [filetype]
|
||||||
automatically.
|
|
||||||
|
|
||||||
This command edits a snippet file in
|
It edits a runtime snippet file with neosnippet.
|
||||||
|g:neosnippet#snippets_directory| with precedence.
|
Re-make cache will be done automatically when you save the
|
||||||
Re-cache will be done automatically when you save the file.
|
file.
|
||||||
|
|
||||||
:NeoComplCacheEditRuntimeSnippets [filetype]
|
|
||||||
*:NeoComplCacheEditRuntimeSnippets*
|
*:NeoComplCacheEditRuntimeSnippets*
|
||||||
Opens [filetype] snippets to edit. It automatically selects
|
Note: |:NeoComplCacheEditRuntimeSnippets| is obsolute name.
|
||||||
current buffer's filetype unless you specify [filetype].
|
|
||||||
|
|
||||||
If [filetype] snippet file doesn't exist, it creates one
|
|
||||||
automatically.
|
|
||||||
|
|
||||||
This command edits a runtime snippet file with
|
|
||||||
snippets_complete. Re-cache will be done automatically when
|
|
||||||
you save the file.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
VARIABLES *neosnippet-variables*
|
VARIABLES *neosnippet-variables*
|
||||||
@ -274,8 +305,8 @@ Eval snippet feature is available.
|
|||||||
prev_word '^'
|
prev_word '^'
|
||||||
`expand("%")`
|
`expand("%")`
|
||||||
<
|
<
|
||||||
If you use |:NeoComplCacheEditSnippets| command for easy snippet editing, the
|
If you use |:NeoSnippetEdit| command for easy snippet editing, the file will
|
||||||
file will be loaded automatically when you save the file.
|
be loaded automatically when you save the file.
|
||||||
|
|
||||||
Neosnippet doesn't map snippet-expand key by default. If you want to use
|
Neosnippet doesn't map snippet-expand key by default. If you want to use
|
||||||
snippet feature, you can define below mappings in your .vimrc:
|
snippet feature, you can define below mappings in your .vimrc:
|
||||||
@ -369,6 +400,7 @@ CHANGELOG *neosnippet-changelog*
|
|||||||
- Improved filetype complete.
|
- Improved filetype complete.
|
||||||
- Improved documentation.
|
- Improved documentation.
|
||||||
- Changed neocomplcache source behavior.
|
- Changed neocomplcache source behavior.
|
||||||
|
- Renamed commands.
|
||||||
|
|
||||||
2012-09-27
|
2012-09-27
|
||||||
- Ver.3 development is started.
|
- Ver.3 development is started.
|
||||||
|
@ -88,15 +88,23 @@ augroup neosnippet"{{{
|
|||||||
augroup END"}}}
|
augroup END"}}}
|
||||||
|
|
||||||
" Commands."{{{
|
" Commands."{{{
|
||||||
|
command! -nargs=? -complete=customlist,neosnippet#edit_complete
|
||||||
|
\ NeoSnippetEdit
|
||||||
|
\ call neosnippet#edit_snippets(<q-args>)
|
||||||
|
|
||||||
command! -nargs=? -complete=customlist,neosnippet#filetype_complete
|
command! -nargs=? -complete=customlist,neosnippet#filetype_complete
|
||||||
\ NeoComplCacheEditSnippets
|
\ NeoSnippetMakeCache
|
||||||
\ call neosnippet#edit_snippets(<q-args>, 0)
|
\ call neosnippet#make_cache(<q-args>)
|
||||||
command! -nargs=? -complete=customlist,neosnippet#filetype_complete
|
|
||||||
\ NeoComplCacheEditRuntimeSnippets
|
|
||||||
\ call neosnippet#edit_snippets(<q-args>, 1)
|
|
||||||
command! -nargs=? -complete=customlist,neosnippet#filetype_complete
|
command! -nargs=? -complete=customlist,neosnippet#filetype_complete
|
||||||
\ NeoComplCacheCachingSnippets
|
\ NeoComplCacheCachingSnippets
|
||||||
\ call neosnippet#caching_snippets(<q-args>)
|
\ NeoSnippetMakeCache <args>
|
||||||
|
command! -nargs=? -complete=customlist,neosnippet#filetype_complete
|
||||||
|
\ NeoComplCacheEditSnippets
|
||||||
|
\ NeoSnippetEdit <args>
|
||||||
|
command! -nargs=? -complete=customlist,neosnippet#filetype_complete
|
||||||
|
\ NeoComplCacheEditRuntimeSnippets
|
||||||
|
\ NeoSnippetEdit -runtime <args>
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
let g:loaded_neosnippet = 1
|
let g:loaded_neosnippet = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user