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.
 
 

89 lines
2.8 KiB

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