- Refactored variables.

This commit is contained in:
Shougo Matsushita 2012-09-30 17:17:31 +09:00
parent 4fe36ca340
commit 6cebc087a2
4 changed files with 36 additions and 25 deletions

View File

@ -27,6 +27,15 @@
let s:save_cpo = &cpo
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()"{{{
" Initialize.
let s:snippets_expand_stack = []
@ -35,7 +44,7 @@ function! s:initialize()"{{{
let s:runtime_dir = split(globpath(&runtimepath,
\ 'autoload/neosnippet/snippets'), '\n')
if !g:neocomplcache_snippets_disable_runtime_snippets
if !g:neosnippet#disable_runtime_snippets
" Set snippets dir.
let s:snippets_dir += (exists('g:snippets_dir') ?
\ split(g:snippets_dir, '\s*,\s*')
@ -43,25 +52,23 @@ function! s:initialize()"{{{
\ + s:runtime_dir
endif
if exists('g:neocomplcache_snippets_dir')
for dir in split(g:neocomplcache_snippets_dir, '\s*,\s*')
let dir = neosnippet#util#expand(dir)
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
call add(s:snippets_dir, dir)
endfor
endif
for dir in split(g:neocomplcache_snippets_dir, '\s*,\s*')
let dir = neosnippet#util#expand(dir)
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
call add(s:snippets_dir, dir)
endfor
call map(s:snippets_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
if has('conceal')
" Supported conceal features.
augroup neosnippet
autocmd BufNewFile,BufRead,ColorScheme *
\ syn match neocomplcacheExpandSnippets
\ syn match neosnippetExpandSnippets
\ '<`\d\+:\|`>\|<{\d\+:\|}>' conceal
autocmd BufNewFile,BufRead,ColorScheme *
\ execute 'syn match neocomplcacheExpandSnippets'
\ execute 'syn match neosnippetExpandSnippets'
\ '''<`\d\+\\\@<!`>\|<{\d\+\\\@<!}>\|'
\ .s:get_mirror_placeholder_marker_pattern()."'"
\ 'conceal cchar=$'
@ -69,14 +76,14 @@ function! s:initialize()"{{{
else
augroup neosnippet
autocmd BufNewFile,BufRead,ColorScheme *
\ execute 'syn match neocomplcacheExpandSnippets'
\ execute 'syn match neosnippetExpandSnippets'
\ "'".s:get_placeholder_marker_pattern(). '\|'
\ .s:get_sync_placeholder_marker_pattern().'\|'
\ .s:get_mirror_placeholder_marker_pattern()."'"
augroup END
endif
hi def link NeoComplCacheExpandSnippets Special
hi def link neosnippetExpandSnippets Special
command! -nargs=? -complete=customlist,neocomplcache#filetype_complete
\ NeoComplCacheEditSnippets
@ -88,8 +95,8 @@ function! s:initialize()"{{{
\ NeoComplCacheCachingSnippets
\ call neosnippet#caching_snippets(<q-args>)
" Select mode mappings.
if !exists('g:neocomplcache_disable_select_mode_mappings')
" Select mode mappings."{{{
if g:neosnippet#disable_select_mode_mappings
snoremap <CR> a<BS>
snoremap <BS> a<BS>
snoremap <right> <ESC>a
@ -101,7 +108,7 @@ function! s:initialize()"{{{
snoremap ^ a<BS>^
snoremap \ a<BS>\
snoremap <C-x> a<BS><c-x>
endif
endif"}}}
" Caching _ snippets.
call neosnippet#caching_snippets('_')
@ -109,14 +116,14 @@ function! s:initialize()"{{{
" Initialize check.
call neosnippet#caching()
if neocomplcache#exists_echodoc()
if get(g:, 'loaded_echodoc', 0)
call echodoc#register('snippets_complete', s:doc_dict)
endif
endfunction"}}}
" For echodoc."{{{
let s:doc_dict = {
\ 'name' : 'snippets_complete',
\ 'name' : 'neosnippet',
\ 'rank' : 100,
\ 'filetypes' : {},
\ }

View File

@ -61,6 +61,14 @@ function! neosnippet#util#expand(path)"{{{
\ '^\$\h\w*', '\=eval(submatch(0))', '') :
\ a:path)
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(...)"{{{
return call(s:V.set_dictionary_helper, a:000)
endfunction"}}}

View File

@ -321,6 +321,7 @@ CHANGELOG *neosnippet-changelog*
- Changed runtime directory.
- Vitalized.
- Deleted neocomplcache#util functions.
- Refactored variables.
2012-09-27
- Ver.3 development is started.

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 28 Sep 2012.
" Last Modified: 30 Sep 2012.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@ -36,11 +36,6 @@ set cpo&vim
" 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."{{{
inoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)