Rename snippet to neosnippet

This commit is contained in:
Shougo Matsushita 2013-12-31 07:50:41 +09:00
parent 3a2e43a934
commit eafef3c2d3
6 changed files with 30 additions and 37 deletions

View File

@ -27,9 +27,9 @@
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! unite#sources#snippet#define() "{{{ function! unite#sources#neosnippet#define() "{{{
let kind = { let kind = {
\ 'name' : 'snippet', \ 'name' : 'neosnippet',
\ 'default_action' : 'expand', \ 'default_action' : 'expand',
\ 'action_table': {}, \ 'action_table': {},
\ 'parents': ['jump_list', 'completion'], \ 'parents': ['jump_list', 'completion'],
@ -42,7 +42,7 @@ endfunction "}}}
" neosnippet source. " neosnippet source.
let s:source = { let s:source = {
\ 'name': 'snippet', \ 'name': 'neosnippet',
\ 'hooks' : {}, \ 'hooks' : {},
\ 'action_table' : {}, \ 'action_table' : {},
\ } \ }
@ -58,8 +58,7 @@ function! s:source.gather_candidates(args, context) "{{{
return map(copy(a:context.source__snippets), "{ return map(copy(a:context.source__snippets), "{
\ 'word' : v:val.word, \ 'word' : v:val.word,
\ 'abbr' : printf('%-50s %s', v:val.word, v:val.menu_abbr), \ 'abbr' : printf('%-50s %s', v:val.word, v:val.menu_abbr),
\ 'kind' : 'snippet', \ 'kind' : 'neosnippet',
\ 'dup' : 1,
\ 'action__complete_word' : v:val.word, \ 'action__complete_word' : v:val.word,
\ 'action__complete_pos' : a:context.source__cur_keyword_pos, \ 'action__complete_pos' : a:context.source__cur_keyword_pos,
\ 'action__path' : v:val.action__path, \ 'action__path' : v:val.action__path,
@ -67,7 +66,7 @@ function! s:source.gather_candidates(args, context) "{{{
\ 'source__menu' : v:val.menu_abbr, \ 'source__menu' : v:val.menu_abbr,
\ 'source__snip' : v:val.snip, \ 'source__snip' : v:val.snip,
\ 'source__snip_ref' : v:val, \ 'source__snip_ref' : v:val,
\ "}) \ }")
endfunction "}}} endfunction "}}}
" Actions "{{{ " Actions "{{{
@ -138,7 +137,7 @@ let s:source.action_table = s:action_table
unlet! s:action_table unlet! s:action_table
"}}} "}}}
function! unite#sources#snippet#start_complete() "{{{ function! unite#sources#neosnippet#start_complete() "{{{
if !exists(':Unite') if !exists(':Unite')
call neosnippet#util#print_error( call neosnippet#util#print_error(
\ 'unite.vim is not installed.') \ 'unite.vim is not installed.')

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: snippet_target.vim " FILE: snippet_target.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 21 Nov 2013. " Last Modified: 31 Dec 2013.
" 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
@ -27,7 +27,7 @@
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! unite#sources#snippet_target#define() "{{{ function! unite#sources#neosnippet_target#define() "{{{
if !exists('*unite#version') || unite#version() < 150 if !exists('*unite#version') || unite#version() < 150
echoerr 'Your unite.vim is too old.' echoerr 'Your unite.vim is too old.'
return [] return []
@ -37,7 +37,7 @@ function! unite#sources#snippet_target#define() "{{{
endfunction "}}} endfunction "}}}
let s:source = { let s:source = {
\ 'name': 'snippet/target', \ 'name': 'neosnippet/target',
\ 'hooks' : {}, \ 'hooks' : {},
\ 'default_action' : 'select', \ 'default_action' : 'select',
\ 'action_table' : {}, \ 'action_table' : {},
@ -54,20 +54,13 @@ function! s:source.hooks.on_init(args, context) "{{{
endfunction"}}} endfunction"}}}
function! s:source.gather_candidates(args, context) "{{{ function! s:source.gather_candidates(args, context) "{{{
let list = [] return map(copy(a:context.source__snippets), "{
for keyword in a:context.source__snippets \ 'word' : printf('%-50s %s', v:val.word, v:val.menu_abbr),
let dict = { \ 'source__trigger' : v:val.word,
\ 'word' : printf('%-50s %s', keyword.word, keyword.menu_abbr), \ 'source__menu' : v:val.menu_abbr,
\ 'source__trigger' : keyword.word, \ 'source__snip' : v:val.snip,
\ 'source__menu' : keyword.menu_abbr,
\ 'source__snip' : keyword.snip,
\ 'source__context' : a:context, \ 'source__context' : a:context,
\ } \ }")
call add(list, dict)
endfor
return list
endfunction "}}} endfunction "}}}
" Actions "{{{ " Actions "{{{
@ -82,11 +75,12 @@ function! s:source.action_table.select.func(candidate) "{{{
return return
endif endif
call neosnippet#mappings#_expand_target_trigger(a:candidate.source__trigger) call neosnippet#mappings#_expand_target_trigger(
\ a:candidate.source__trigger)
endfunction"}}} endfunction"}}}
"}}} "}}}
function! unite#sources#snippet_target#start() "{{{ function! unite#sources#neosnippet_target#start() "{{{
if !exists(':Unite') if !exists(':Unite')
call neosnippet#util#print_error( call neosnippet#util#print_error(
\ 'unite.vim is not installed.') \ 'unite.vim is not installed.')
@ -101,8 +95,8 @@ function! unite#sources#snippet_target#start() "{{{
return '' return ''
endif endif
return unite#start_complete(['snippet/target'], return unite#start_complete(['neosnippet/target'],
\ { 'buffer_name' : 'snippet/target' }) \ { 'buffer_name' : 'neosnippet/target' })
endfunction "}}} endfunction "}}}
function! s:get_keyword_pos(cur_text) "{{{ function! s:get_keyword_pos(cur_text) "{{{

View File

@ -642,14 +642,14 @@ insert empty line in snippet end, you must insert placeholder.
============================================================================== ==============================================================================
UNITE SOURCES *neosnippet-unite-sources* UNITE SOURCES *neosnippet-unite-sources*
*neosnippet-unite-source-snippet* *neosnippet-unite-source-neosnippet*
snippet neosnippet
The candidates of the snippet source are neosnippet snippets. The candidates of the snippet source are neosnippet snippets.
and their kind is "snippet". You can use the snippet source and their kind is "snippet". You can use the snippet source
with the mapping |<Plug>(neosnippet_start_unite_snippet)|. with the mapping |<Plug>(neosnippet_start_unite_snippet)|.
But you can also execute it by ":Unite snippet". The snippet But you can also execute it by ":Unite neosnippet". The
source offers an edit action you can use to edit the snippet snippet source offers an edit action you can use to edit the
files. snippet files.
Example: Example:
> >
@ -665,7 +665,7 @@ neosnippet/runtime
source actions source actions
snippet *neosnippet-unite-action-snippet* neosnippet *neosnippet-unite-action-neosnippet*
expand Expand snippet (default action) expand Expand snippet (default action)
edit Edit snippet edit Edit snippet
preview View snippet definition preview View snippet definition

View File

@ -1,2 +1,2 @@
" Detect syntax file. " Detect syntax file.
autocmd BufNewFile,BufRead *.snip,*.snippets set filetype=snippet autocmd BufNewFile,BufRead *.snip,*.snippets set filetype=neosnippet

View File

@ -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: 25 Dec 2013. " Last Modified: 31 Dec 2013.
" 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
@ -61,12 +61,12 @@ xnoremap <silent> <Plug>(neosnippet_get_selected_text)
xnoremap <silent> <Plug>(neosnippet_expand_target) xnoremap <silent> <Plug>(neosnippet_expand_target)
\ :<C-u>call neosnippet#mappings#_expand_target()<CR> \ :<C-u>call neosnippet#mappings#_expand_target()<CR>
xnoremap <silent><expr> <Plug>(neosnippet_start_unite_snippet_target) xnoremap <silent><expr> <Plug>(neosnippet_start_unite_snippet_target)
\ unite#sources#snippet_target#start() \ unite#sources#neosnippet_target#start()
xnoremap <silent> <Plug>(neosnippet_register_oneshot_snippet) xnoremap <silent> <Plug>(neosnippet_register_oneshot_snippet)
\ :<C-u>call neosnippet#mappings#_register_oneshot_snippet()<CR> \ :<C-u>call neosnippet#mappings#_register_oneshot_snippet()<CR>
inoremap <expr><silent> <Plug>(neosnippet_start_unite_snippet) inoremap <expr><silent> <Plug>(neosnippet_start_unite_snippet)
\ unite#sources#snippet#start_complete() \ unite#sources#neosnippet#start_complete()
"}}} "}}}
augroup neosnippet "{{{ augroup neosnippet "{{{