- Fixed snippet source errors.
This commit is contained in:
parent
e3fa0bbf64
commit
e31b261755
@ -1,7 +1,7 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
" FILE: snippet.vim
|
" FILE: snippet.vim
|
||||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||||
" Last Modified: 07 Mar 2012.
|
" Last Modified: 30 Sep 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,7 +45,7 @@ function! unite#sources#snippet#define() "{{{
|
|||||||
return s:source
|
return s:source
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
" neocomplcache snippet source.
|
" neosnippet source.
|
||||||
let s:source = {
|
let s:source = {
|
||||||
\ 'name': 'snippet',
|
\ 'name': 'snippet',
|
||||||
\ 'hooks' : {},
|
\ 'hooks' : {},
|
||||||
@ -54,10 +54,9 @@ let s:source = {
|
|||||||
|
|
||||||
function! s:source.hooks.on_init(args, context) "{{{
|
function! s:source.hooks.on_init(args, context) "{{{
|
||||||
let a:context.source__cur_keyword_pos =
|
let a:context.source__cur_keyword_pos =
|
||||||
\ s:get_keyword_pos(neocomplcache#get_cur_text(1))
|
\ s:get_keyword_pos(neosnippet#util#get_cur_text())
|
||||||
let a:context.source__snippets =
|
let a:context.source__snippets =
|
||||||
\ sort(values(neocomplcache#sources#snippets_complete#get_snippets()),
|
\ sort(values(neosnippet#get_snippets()), 's:compare_words')
|
||||||
\ 's:compare_words')
|
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:source.gather_candidates(args, context) "{{{
|
function! s:source.gather_candidates(args, context) "{{{
|
||||||
@ -89,11 +88,10 @@ let s:action_table.expand = {
|
|||||||
\ 'description' : 'expand snippet',
|
\ 'description' : 'expand snippet',
|
||||||
\ }
|
\ }
|
||||||
function! s:action_table.expand.func(candidate)"{{{
|
function! s:action_table.expand.func(candidate)"{{{
|
||||||
let cur_text = neocomplcache#get_cur_text(1)
|
let cur_text = neosnippet#util#get_cur_text()
|
||||||
let [_, cur_keyword_str] =
|
let cur_keyword_str = matchstr(cur_text, '\S\+$')
|
||||||
\ neocomplcache#match_word(cur_text)
|
|
||||||
let context = unite#get_context()
|
let context = unite#get_context()
|
||||||
call neocomplcache#sources#snippets_complete#expand(
|
call neosnippet#expand(
|
||||||
\ cur_text . a:candidate.action__complete_word[len(cur_keyword_str)],
|
\ cur_text . a:candidate.action__complete_word[len(cur_keyword_str)],
|
||||||
\ context.col, a:candidate.action__complete_word)
|
\ context.col, a:candidate.action__complete_word)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
@ -121,14 +119,14 @@ unlet! s:action_table
|
|||||||
|
|
||||||
function! unite#sources#snippet#start_complete() "{{{
|
function! unite#sources#snippet#start_complete() "{{{
|
||||||
return unite#start_complete(['snippet'],
|
return unite#start_complete(['snippet'],
|
||||||
\ { 'input': neocomplcache#get_cur_text(1) })
|
\ { 'input': neosnippet#util#get_cur_text() })
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:compare_words(i1, i2)"{{{
|
function! s:compare_words(i1, i2)"{{{
|
||||||
return a:i1.menu - a:i2.menu
|
return a:i1.menu - a:i2.menu
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:get_keyword_pos(cur_text)"{{{
|
function! s:get_keyword_pos(cur_text)"{{{
|
||||||
let [cur_keyword_pos, cur_keyword_str] = neocomplcache#match_word(a:cur_text)
|
let cur_keyword_pos = match(a:cur_text, '\S\+$')
|
||||||
if cur_keyword_pos < 0
|
if cur_keyword_pos < 0
|
||||||
" Empty string.
|
" Empty string.
|
||||||
return len(a:cur_text)
|
return len(a:cur_text)
|
||||||
|
@ -401,6 +401,7 @@ CHANGELOG *neosnippet-changelog*
|
|||||||
- Improved documentation.
|
- Improved documentation.
|
||||||
- Changed neocomplcache source behavior.
|
- Changed neocomplcache source behavior.
|
||||||
- Renamed commands.
|
- Renamed commands.
|
||||||
|
- Fixed snippet source errors.
|
||||||
|
|
||||||
2012-09-27
|
2012-09-27
|
||||||
- Ver.3 development is started.
|
- Ver.3 development is started.
|
||||||
|
Loading…
Reference in New Issue
Block a user