Move register_oneshot_snippet function
This commit is contained in:
parent
038d75ce58
commit
7b1f900912
@ -284,33 +284,6 @@ function! s:indent_snippet(begin, end) "{{{
|
||||
endtry
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#register_oneshot_snippet() "{{{
|
||||
let trigger = input('Please input snippet trigger: ', 'oneshot')
|
||||
if trigger == ''
|
||||
return
|
||||
endif
|
||||
|
||||
let selected_text = substitute(
|
||||
\ neosnippet#get_selected_text(visualmode(), 1), '\n$', '', '')
|
||||
call neosnippet#delete_selected_text(visualmode(), 1)
|
||||
|
||||
let base_indent = matchstr(selected_text, '^\s*')
|
||||
|
||||
" Delete base_indent.
|
||||
let selected_text = substitute(selected_text,
|
||||
\'^' . base_indent, '', 'g')
|
||||
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
let options = neosnippet#parser#_initialize_snippet_options()
|
||||
let options.word = 1
|
||||
|
||||
let neosnippet.snippets[trigger] = neosnippet#parser#_initialize_snippet(
|
||||
\ { 'name' : trigger, 'word' : selected_text, 'options' : options },
|
||||
\ '', 0, '', trigger)
|
||||
|
||||
echo 'Registered trigger : ' . trigger
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#_get_snippet_range(begin_line, begin_patterns, end_line, end_patterns) "{{{
|
||||
let pos = getpos('.')
|
||||
|
||||
|
@ -85,6 +85,33 @@ function! neosnippet#mappings#_clear_select_mode_mappings() "{{{
|
||||
snoremap <C-h> a<BS>
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#mappings#_register_oneshot_snippet() "{{{
|
||||
let trigger = input('Please input snippet trigger: ', 'oneshot')
|
||||
if trigger == ''
|
||||
return
|
||||
endif
|
||||
|
||||
let selected_text = substitute(
|
||||
\ neosnippet#get_selected_text(visualmode(), 1), '\n$', '', '')
|
||||
call neosnippet#delete_selected_text(visualmode(), 1)
|
||||
|
||||
let base_indent = matchstr(selected_text, '^\s*')
|
||||
|
||||
" Delete base_indent.
|
||||
let selected_text = substitute(selected_text,
|
||||
\'^' . base_indent, '', 'g')
|
||||
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
let options = neosnippet#parser#_initialize_snippet_options()
|
||||
let options.word = 1
|
||||
|
||||
let neosnippet.snippets[trigger] = neosnippet#parser#_initialize_snippet(
|
||||
\ { 'name' : trigger, 'word' : selected_text, 'options' : options },
|
||||
\ '', 0, '', trigger)
|
||||
|
||||
echo 'Registered trigger : ' . trigger
|
||||
endfunction"}}}
|
||||
|
||||
function! s:snippets_expand(cur_text, col) "{{{
|
||||
let cur_word = neosnippet#get_cursor_snippet(
|
||||
\ neosnippet#get_snippets(),
|
||||
|
@ -1,7 +1,7 @@
|
||||
"=============================================================================
|
||||
" FILE: neosnippet.vim
|
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||
" Last Modified: 19 Nov 2013.
|
||||
" Last Modified: 21 Nov 2013.
|
||||
" License: MIT license {{{
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
@ -63,7 +63,7 @@ xnoremap <silent> <Plug>(neosnippet_expand_target)
|
||||
xnoremap <silent><expr> <Plug>(neosnippet_start_unite_snippet_target)
|
||||
\ unite#sources#snippet_target#start()
|
||||
xnoremap <silent> <Plug>(neosnippet_register_oneshot_snippet)
|
||||
\ :<C-u>call neosnippet#register_oneshot_snippet()<CR>
|
||||
\ :<C-u>call neosnippet#mappings#_register_oneshot_snippet()<CR>
|
||||
|
||||
inoremap <expr><silent> <Plug>(neosnippet_start_unite_snippet)
|
||||
\ unite#sources#snippet#start_complete()
|
||||
|
Loading…
Reference in New Issue
Block a user