- Refactored variables.
This commit is contained in:
parent
4fe36ca340
commit
6cebc087a2
@ -27,6 +27,15 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
|
" Global options definition."{{{
|
||||||
|
call neosnippet#util#set_default('g:neosnippet#disable_runtime_snippets',
|
||||||
|
\ 0, 'g:neocomplcache_snippets_disable_runtime_snippets')
|
||||||
|
call neosnippet#util#set_default('g:neosnippet#snippets_directory',
|
||||||
|
\ '', 'g:neocomplcache_snippets_dir')
|
||||||
|
call neosnippet#util#set_default('g:neosnippet#disable_select_mode_mappings',
|
||||||
|
\ 0, 'g:neocomplcache_disable_select_mode_mappings')
|
||||||
|
"}}}
|
||||||
|
|
||||||
function! s:initialize()"{{{
|
function! s:initialize()"{{{
|
||||||
" Initialize.
|
" Initialize.
|
||||||
let s:snippets_expand_stack = []
|
let s:snippets_expand_stack = []
|
||||||
@ -35,7 +44,7 @@ function! s:initialize()"{{{
|
|||||||
let s:runtime_dir = split(globpath(&runtimepath,
|
let s:runtime_dir = split(globpath(&runtimepath,
|
||||||
\ 'autoload/neosnippet/snippets'), '\n')
|
\ 'autoload/neosnippet/snippets'), '\n')
|
||||||
|
|
||||||
if !g:neocomplcache_snippets_disable_runtime_snippets
|
if !g:neosnippet#disable_runtime_snippets
|
||||||
" Set snippets dir.
|
" Set snippets dir.
|
||||||
let s:snippets_dir += (exists('g:snippets_dir') ?
|
let s:snippets_dir += (exists('g:snippets_dir') ?
|
||||||
\ split(g:snippets_dir, '\s*,\s*')
|
\ split(g:snippets_dir, '\s*,\s*')
|
||||||
@ -43,25 +52,23 @@ function! s:initialize()"{{{
|
|||||||
\ + s:runtime_dir
|
\ + s:runtime_dir
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists('g:neocomplcache_snippets_dir')
|
for dir in split(g:neocomplcache_snippets_dir, '\s*,\s*')
|
||||||
for dir in split(g:neocomplcache_snippets_dir, '\s*,\s*')
|
let dir = neosnippet#util#expand(dir)
|
||||||
let dir = neosnippet#util#expand(dir)
|
if !isdirectory(dir)
|
||||||
if !isdirectory(dir)
|
call mkdir(dir, 'p')
|
||||||
call mkdir(dir, 'p')
|
endif
|
||||||
endif
|
call add(s:snippets_dir, dir)
|
||||||
call add(s:snippets_dir, dir)
|
endfor
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
call map(s:snippets_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
|
call map(s:snippets_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
|
||||||
|
|
||||||
if has('conceal')
|
if has('conceal')
|
||||||
" Supported conceal features.
|
" Supported conceal features.
|
||||||
augroup neosnippet
|
augroup neosnippet
|
||||||
autocmd BufNewFile,BufRead,ColorScheme *
|
autocmd BufNewFile,BufRead,ColorScheme *
|
||||||
\ syn match neocomplcacheExpandSnippets
|
\ syn match neosnippetExpandSnippets
|
||||||
\ '<`\d\+:\|`>\|<{\d\+:\|}>' conceal
|
\ '<`\d\+:\|`>\|<{\d\+:\|}>' conceal
|
||||||
autocmd BufNewFile,BufRead,ColorScheme *
|
autocmd BufNewFile,BufRead,ColorScheme *
|
||||||
\ execute 'syn match neocomplcacheExpandSnippets'
|
\ execute 'syn match neosnippetExpandSnippets'
|
||||||
\ '''<`\d\+\\\@<!`>\|<{\d\+\\\@<!}>\|'
|
\ '''<`\d\+\\\@<!`>\|<{\d\+\\\@<!}>\|'
|
||||||
\ .s:get_mirror_placeholder_marker_pattern()."'"
|
\ .s:get_mirror_placeholder_marker_pattern()."'"
|
||||||
\ 'conceal cchar=$'
|
\ 'conceal cchar=$'
|
||||||
@ -69,14 +76,14 @@ function! s:initialize()"{{{
|
|||||||
else
|
else
|
||||||
augroup neosnippet
|
augroup neosnippet
|
||||||
autocmd BufNewFile,BufRead,ColorScheme *
|
autocmd BufNewFile,BufRead,ColorScheme *
|
||||||
\ execute 'syn match neocomplcacheExpandSnippets'
|
\ execute 'syn match neosnippetExpandSnippets'
|
||||||
\ "'".s:get_placeholder_marker_pattern(). '\|'
|
\ "'".s:get_placeholder_marker_pattern(). '\|'
|
||||||
\ .s:get_sync_placeholder_marker_pattern().'\|'
|
\ .s:get_sync_placeholder_marker_pattern().'\|'
|
||||||
\ .s:get_mirror_placeholder_marker_pattern()."'"
|
\ .s:get_mirror_placeholder_marker_pattern()."'"
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
hi def link NeoComplCacheExpandSnippets Special
|
hi def link neosnippetExpandSnippets Special
|
||||||
|
|
||||||
command! -nargs=? -complete=customlist,neocomplcache#filetype_complete
|
command! -nargs=? -complete=customlist,neocomplcache#filetype_complete
|
||||||
\ NeoComplCacheEditSnippets
|
\ NeoComplCacheEditSnippets
|
||||||
@ -88,8 +95,8 @@ function! s:initialize()"{{{
|
|||||||
\ NeoComplCacheCachingSnippets
|
\ NeoComplCacheCachingSnippets
|
||||||
\ call neosnippet#caching_snippets(<q-args>)
|
\ call neosnippet#caching_snippets(<q-args>)
|
||||||
|
|
||||||
" Select mode mappings.
|
" Select mode mappings."{{{
|
||||||
if !exists('g:neocomplcache_disable_select_mode_mappings')
|
if g:neosnippet#disable_select_mode_mappings
|
||||||
snoremap <CR> a<BS>
|
snoremap <CR> a<BS>
|
||||||
snoremap <BS> a<BS>
|
snoremap <BS> a<BS>
|
||||||
snoremap <right> <ESC>a
|
snoremap <right> <ESC>a
|
||||||
@ -101,7 +108,7 @@ function! s:initialize()"{{{
|
|||||||
snoremap ^ a<BS>^
|
snoremap ^ a<BS>^
|
||||||
snoremap \ a<BS>\
|
snoremap \ a<BS>\
|
||||||
snoremap <C-x> a<BS><c-x>
|
snoremap <C-x> a<BS><c-x>
|
||||||
endif
|
endif"}}}
|
||||||
|
|
||||||
" Caching _ snippets.
|
" Caching _ snippets.
|
||||||
call neosnippet#caching_snippets('_')
|
call neosnippet#caching_snippets('_')
|
||||||
@ -109,14 +116,14 @@ function! s:initialize()"{{{
|
|||||||
" Initialize check.
|
" Initialize check.
|
||||||
call neosnippet#caching()
|
call neosnippet#caching()
|
||||||
|
|
||||||
if neocomplcache#exists_echodoc()
|
if get(g:, 'loaded_echodoc', 0)
|
||||||
call echodoc#register('snippets_complete', s:doc_dict)
|
call echodoc#register('snippets_complete', s:doc_dict)
|
||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
" For echodoc."{{{
|
" For echodoc."{{{
|
||||||
let s:doc_dict = {
|
let s:doc_dict = {
|
||||||
\ 'name' : 'snippets_complete',
|
\ 'name' : 'neosnippet',
|
||||||
\ 'rank' : 100,
|
\ 'rank' : 100,
|
||||||
\ 'filetypes' : {},
|
\ 'filetypes' : {},
|
||||||
\ }
|
\ }
|
||||||
|
@ -61,6 +61,14 @@ function! neosnippet#util#expand(path)"{{{
|
|||||||
\ '^\$\h\w*', '\=eval(submatch(0))', '') :
|
\ '^\$\h\w*', '\=eval(submatch(0))', '') :
|
||||||
\ a:path)
|
\ a:path)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
function! neosnippet#util#set_default(var, val, ...) "{{{
|
||||||
|
if !exists(a:var) || type({a:var}) != type(a:val)
|
||||||
|
let alternate_var = get(a:000, 0, '')
|
||||||
|
|
||||||
|
let {a:var} = exists(alternate_var) ?
|
||||||
|
\ {alternate_var} : a:val
|
||||||
|
endif
|
||||||
|
endfunction"}}}
|
||||||
function! neosnippet#util#set_dictionary_helper(...)"{{{
|
function! neosnippet#util#set_dictionary_helper(...)"{{{
|
||||||
return call(s:V.set_dictionary_helper, a:000)
|
return call(s:V.set_dictionary_helper, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
@ -321,6 +321,7 @@ CHANGELOG *neosnippet-changelog*
|
|||||||
- Changed runtime directory.
|
- Changed runtime directory.
|
||||||
- Vitalized.
|
- Vitalized.
|
||||||
- Deleted neocomplcache#util functions.
|
- Deleted neocomplcache#util functions.
|
||||||
|
- Refactored variables.
|
||||||
|
|
||||||
2012-09-27
|
2012-09-27
|
||||||
- Ver.3 development is started.
|
- Ver.3 development is started.
|
||||||
|
@ -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: 28 Sep 2012.
|
" Last Modified: 30 Sep 2012.
|
||||||
" 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
|
||||||
@ -36,11 +36,6 @@ set cpo&vim
|
|||||||
|
|
||||||
" Obsolute options check."{{{
|
" Obsolute options check."{{{
|
||||||
"}}}
|
"}}}
|
||||||
" Global options definition."{{{
|
|
||||||
if !exists('g:neocomplcache_snippets_disable_runtime_snippets')
|
|
||||||
let g:neocomplcache_snippets_disable_runtime_snippets = 0
|
|
||||||
endif
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Plugin key-mappings."{{{
|
" Plugin key-mappings."{{{
|
||||||
inoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)
|
inoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)
|
||||||
|
Loading…
Reference in New Issue
Block a user