You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

97 lines
2.9 KiB

  1. "=============================================================================
  2. " FILE: init.vim
  3. " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
  4. " License: MIT license
  5. "=============================================================================
  6. let s:save_cpo = &cpo
  7. set cpo&vim
  8. function! neosnippet#init#_initialize() abort "{{{
  9. let s:is_initialized = 1
  10. call s:initialize_others()
  11. call s:initialize_cache()
  12. endfunction"}}}
  13. function! neosnippet#init#check() abort "{{{
  14. if !exists('s:is_initialized')
  15. call neosnippet#init#_initialize()
  16. endif
  17. endfunction"}}}
  18. function! s:initialize_cache() abort "{{{
  19. " Make cache for _ snippets.
  20. call neosnippet#commands#_make_cache('_')
  21. " Initialize check.
  22. call neosnippet#commands#_make_cache(&filetype)
  23. endfunction"}}}
  24. function! s:initialize_others() abort "{{{
  25. augroup neosnippet "{{{
  26. autocmd!
  27. " Set make cache event.
  28. autocmd FileType *
  29. \ call neosnippet#commands#_make_cache(&filetype)
  30. " Re make cache events
  31. autocmd BufWritePost *.snip,*.snippets
  32. \ call neosnippet#variables#set_snippets({})
  33. autocmd BufEnter *
  34. \ call neosnippet#mappings#_clear_select_mode_mappings()
  35. augroup END"}}}
  36. if g:neosnippet#enable_auto_clear_markers
  37. autocmd neosnippet CursorMoved,CursorMovedI *
  38. \ call neosnippet#handlers#_cursor_moved()
  39. autocmd neosnippet BufWritePre *
  40. \ call neosnippet#handlers#_all_clear_markers()
  41. endif
  42. if exists('##TextChanged') && exists('##TextChangedI')
  43. autocmd neosnippet TextChanged,TextChangedI *
  44. \ call neosnippet#handlers#_restore_unnamed_register()
  45. endif
  46. augroup neosnippet
  47. autocmd BufNewFile,BufRead,Syntax *
  48. \ execute 'syntax match neosnippetExpandSnippets'
  49. \ "'".neosnippet#get_placeholder_marker_pattern(). '\|'
  50. \ .neosnippet#get_sync_placeholder_marker_pattern().'\|'
  51. \ .neosnippet#get_mirror_placeholder_marker_pattern()."'"
  52. \ 'containedin=ALL oneline'
  53. if g:neosnippet#enable_conceal_markers && has('conceal')
  54. autocmd BufNewFile,BufRead,Syntax *
  55. \ syntax region neosnippetConcealExpandSnippets
  56. \ matchgroup=neosnippetExpandSnippets
  57. \ start='<`\d\+:\=\%(#:\)\?\|<{\d\+:\=\%(#:\)\?\|<|'
  58. \ end='`>\|}>\||>'
  59. \ containedin=ALL
  60. \ concealends oneline
  61. endif
  62. augroup END
  63. doautocmd neosnippet BufRead
  64. hi def link neosnippetExpandSnippets Special
  65. call neosnippet#mappings#_clear_select_mode_mappings()
  66. if g:neosnippet#enable_snipmate_compatibility "{{{
  67. " For snipMate function.
  68. function! Filename(...) abort
  69. let filename = expand('%:t:r')
  70. if filename == ''
  71. return a:0 == 2 ? a:2 : ''
  72. elseif a:0 == 0 || a:1 == ''
  73. return filename
  74. else
  75. return substitute(a:1, '$1', filename, 'g')
  76. endif
  77. endfunction
  78. endif"}}}
  79. endfunction"}}}
  80. let &cpo = s:save_cpo
  81. unlet s:save_cpo
  82. " vim: foldmethod=marker