2013-11-19 07:04:32 +00:00
|
|
|
"=============================================================================
|
|
|
|
" FILE: init.vim
|
2017-06-15 00:11:15 +00:00
|
|
|
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
|
2017-06-15 00:04:27 +00:00
|
|
|
" License: MIT license
|
2013-11-19 07:04:32 +00:00
|
|
|
"=============================================================================
|
|
|
|
|
2017-10-01 13:40:17 +00:00
|
|
|
function! neosnippet#init#_initialize() abort
|
2013-11-19 07:04:32 +00:00
|
|
|
let s:is_initialized = 1
|
|
|
|
|
|
|
|
call s:initialize_others()
|
|
|
|
call s:initialize_cache()
|
2017-10-01 13:40:17 +00:00
|
|
|
endfunction
|
2013-11-19 07:04:32 +00:00
|
|
|
|
2017-10-01 13:40:17 +00:00
|
|
|
function! neosnippet#init#check() abort
|
2013-11-19 07:04:32 +00:00
|
|
|
if !exists('s:is_initialized')
|
|
|
|
call neosnippet#init#_initialize()
|
|
|
|
endif
|
2017-10-01 13:40:17 +00:00
|
|
|
endfunction
|
2013-11-19 07:04:32 +00:00
|
|
|
|
2017-10-01 13:40:17 +00:00
|
|
|
function! s:initialize_cache() abort
|
2013-11-19 07:19:33 +00:00
|
|
|
" Make cache for _ snippets.
|
|
|
|
call neosnippet#commands#_make_cache('_')
|
2013-11-19 07:04:32 +00:00
|
|
|
|
|
|
|
" Initialize check.
|
2013-11-21 09:10:26 +00:00
|
|
|
call neosnippet#commands#_make_cache(&filetype)
|
2017-10-01 13:40:17 +00:00
|
|
|
endfunction
|
|
|
|
function! s:initialize_others() abort
|
|
|
|
augroup neosnippet
|
2013-11-19 07:04:32 +00:00
|
|
|
autocmd!
|
2013-11-21 09:54:04 +00:00
|
|
|
" Set make cache event.
|
2015-12-15 18:40:40 +00:00
|
|
|
autocmd FileType *
|
|
|
|
\ call neosnippet#commands#_make_cache(&filetype)
|
2013-11-21 09:54:04 +00:00
|
|
|
" Re make cache events
|
2013-11-19 07:04:32 +00:00
|
|
|
autocmd BufWritePost *.snip,*.snippets
|
2013-11-21 09:10:26 +00:00
|
|
|
\ call neosnippet#variables#set_snippets({})
|
2013-11-19 07:04:32 +00:00
|
|
|
autocmd BufEnter *
|
2013-11-19 07:07:04 +00:00
|
|
|
\ call neosnippet#mappings#_clear_select_mode_mappings()
|
2017-10-01 13:40:17 +00:00
|
|
|
augroup END
|
2015-12-19 01:00:57 +00:00
|
|
|
|
|
|
|
if g:neosnippet#enable_auto_clear_markers
|
|
|
|
autocmd neosnippet CursorMoved,CursorMovedI *
|
2015-08-29 00:33:43 +00:00
|
|
|
\ call neosnippet#handlers#_cursor_moved()
|
2015-12-19 01:00:57 +00:00
|
|
|
autocmd neosnippet BufWritePre *
|
2015-12-15 18:40:40 +00:00
|
|
|
\ call neosnippet#handlers#_all_clear_markers()
|
2015-12-19 01:00:57 +00:00
|
|
|
endif
|
2013-11-19 07:04:32 +00:00
|
|
|
|
2016-02-17 21:12:47 +00:00
|
|
|
if exists('##TextChanged') && exists('##TextChangedI')
|
|
|
|
autocmd neosnippet TextChanged,TextChangedI *
|
|
|
|
\ call neosnippet#handlers#_restore_unnamed_register()
|
|
|
|
endif
|
|
|
|
|
2013-11-19 07:04:32 +00:00
|
|
|
augroup neosnippet
|
|
|
|
autocmd BufNewFile,BufRead,Syntax *
|
|
|
|
\ execute 'syntax match neosnippetExpandSnippets'
|
|
|
|
\ "'".neosnippet#get_placeholder_marker_pattern(). '\|'
|
|
|
|
\ .neosnippet#get_sync_placeholder_marker_pattern().'\|'
|
|
|
|
\ .neosnippet#get_mirror_placeholder_marker_pattern()."'"
|
|
|
|
\ 'containedin=ALL oneline'
|
2015-06-23 12:51:14 +00:00
|
|
|
if g:neosnippet#enable_conceal_markers && has('conceal')
|
2013-11-19 07:04:32 +00:00
|
|
|
autocmd BufNewFile,BufRead,Syntax *
|
|
|
|
\ syntax region neosnippetConcealExpandSnippets
|
|
|
|
\ matchgroup=neosnippetExpandSnippets
|
2017-02-08 22:46:29 +00:00
|
|
|
\ start='<`\d\+:\=\%(#:\)\?\|<{\d\+:\=\%(#:\)\?\|<|'
|
2013-11-19 07:04:32 +00:00
|
|
|
\ end='`>\|}>\||>'
|
|
|
|
\ containedin=ALL
|
|
|
|
\ concealends oneline
|
|
|
|
endif
|
|
|
|
augroup END
|
|
|
|
doautocmd neosnippet BufRead
|
|
|
|
|
|
|
|
hi def link neosnippetExpandSnippets Special
|
|
|
|
|
2013-11-19 07:07:04 +00:00
|
|
|
call neosnippet#mappings#_clear_select_mode_mappings()
|
2013-11-21 09:16:10 +00:00
|
|
|
|
2017-10-01 13:40:17 +00:00
|
|
|
if g:neosnippet#enable_snipmate_compatibility
|
2013-11-21 09:16:10 +00:00
|
|
|
" For snipMate function.
|
2016-02-08 12:48:14 +00:00
|
|
|
function! Filename(...) abort
|
2013-11-21 09:16:10 +00:00
|
|
|
let filename = expand('%:t:r')
|
|
|
|
if filename == ''
|
|
|
|
return a:0 == 2 ? a:2 : ''
|
|
|
|
elseif a:0 == 0 || a:1 == ''
|
|
|
|
return filename
|
|
|
|
else
|
|
|
|
return substitute(a:1, '$1', filename, 'g')
|
|
|
|
endif
|
|
|
|
endfunction
|
2017-10-01 13:40:17 +00:00
|
|
|
endif
|
|
|
|
endfunction
|