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