- Fixed make cache behavior.
This commit is contained in:
parent
003ecce466
commit
f0a97fa957
@ -1,7 +1,7 @@
|
||||
"=============================================================================
|
||||
" FILE: snippets_complete.vim
|
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||
" Last Modified: 17 Oct 2012.
|
||||
" Last Modified: 19 Oct 2012.
|
||||
" License: MIT license {{{
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
@ -45,18 +45,8 @@ function! s:source.get_keyword_pos(cur_text)"{{{
|
||||
endfunction"}}}
|
||||
|
||||
function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)"{{{
|
||||
let all_snippets = neosnippet#get_snippets()
|
||||
|
||||
for filetype in neocomplcache#get_source_filetypes(
|
||||
\ neosnippet#get_filetype())
|
||||
if !has_key(all_snippets, filetype)
|
||||
" Caching snippets.
|
||||
call neosnippet#make_cache(filetype)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return s:keyword_filter(neocomplcache#dup_filter(
|
||||
\ values(all_snippets)), a:cur_keyword_str)
|
||||
\ values(neosnippet#get_snippets())), a:cur_keyword_str)
|
||||
endfunction"}}}
|
||||
|
||||
function! s:keyword_filter(list, cur_keyword_str)"{{{
|
||||
|
@ -179,6 +179,10 @@ function! neosnippet#caching()"{{{
|
||||
call neosnippet#make_cache(&filetype)
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#recaching()"{{{
|
||||
let s:snippets = {}
|
||||
endfunction"}}}
|
||||
|
||||
function! s:set_snippet_dict(snippet_pattern, snippet_dict, dup_check, snippets_file)"{{{
|
||||
if !has_key(a:snippet_pattern, 'name')
|
||||
return
|
||||
@ -294,6 +298,10 @@ function! neosnippet#make_cache(filetype)"{{{
|
||||
let filetype = 'nothing'
|
||||
endif
|
||||
|
||||
if has_key(s:snippets, filetype)
|
||||
return
|
||||
endif
|
||||
|
||||
let snippets_dir = neosnippet#get_snippets_directory()
|
||||
let snippet = {}
|
||||
let snippets_files =
|
||||
@ -811,16 +819,11 @@ function! s:eval_snippet(snippet_text)"{{{
|
||||
return snip_word
|
||||
endfunction"}}}
|
||||
function! neosnippet#get_snippets()"{{{
|
||||
if !has_key(s:snippets, '_')
|
||||
" Caching _ snippets.
|
||||
call neosnippet#make_cache('_')
|
||||
endif
|
||||
|
||||
let snippets = {}
|
||||
for source in s:get_sources_list(s:snippets, neosnippet#get_filetype())
|
||||
call extend(snippets, source, 'keep')
|
||||
for filetype in s:get_sources_filetypes(neosnippet#get_filetype())
|
||||
call neosnippet#make_cache(filetype)
|
||||
call extend(snippets, s:snippets[filetype], 'keep')
|
||||
endfor
|
||||
call extend(snippets, copy(s:snippets['_']), 'keep')
|
||||
|
||||
if !s:is_beginning_of_line(neosnippet#util#get_cur_text())
|
||||
call filter(snippets, '!v:val.is_head')
|
||||
@ -842,10 +845,10 @@ function! neosnippet#get_filetype()"{{{
|
||||
return exists('*neocomplcache#get_context_filetype') ?
|
||||
\ neocomplcache#get_context_filetype(1) : &filetype
|
||||
endfunction"}}}
|
||||
function! s:get_sources_list(snippets, filetype)"{{{
|
||||
return exists('*neocomplcache#get_sources_list') ?
|
||||
\ neocomplcache#get_sources_list(a:snippets, a:filetype) :
|
||||
\ get(a:snippets, a:filetype, [])
|
||||
function! s:get_sources_filetypes(filetype)"{{{
|
||||
return (exists('*neocomplcache#get_source_filetypes') ?
|
||||
\ neocomplcache#get_source_filetypes(a:filetype) :
|
||||
\ [a:filetype]) + ['_']
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#edit_complete(arglead, cmdline, cursorpos)"{{{
|
||||
|
@ -438,6 +438,7 @@ CHANGELOG *neosnippet-changelog*
|
||||
- Fixed syntax highlight.
|
||||
- Improved documentation.
|
||||
- Search snippets recursively.
|
||||
- Fixed make cache behavior.
|
||||
|
||||
2012-10-18
|
||||
- Fixed s:get_sources_list().
|
||||
|
@ -1,7 +1,7 @@
|
||||
"=============================================================================
|
||||
" FILE: neosnippet.vim
|
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||
" Last Modified: 30 Sep 2012.
|
||||
" Last Modified: 19 Oct 2012.
|
||||
" License: MIT license {{{
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
@ -84,7 +84,7 @@ augroup neosnippet"{{{
|
||||
autocmd FileType * call neosnippet#caching()
|
||||
" Recaching events
|
||||
autocmd BufWritePost *.snip,*.snippets
|
||||
\ call neosnippet#make_cache(expand('<afile>:t:r'))
|
||||
\ call neosnippet#recaching()
|
||||
augroup END"}}}
|
||||
|
||||
" Commands."{{{
|
||||
|
Loading…
Reference in New Issue
Block a user