Improve variables methods
This commit is contained in:
@@ -94,7 +94,7 @@ function! neosnippet#commands#_make_cache(filetype) "{{{
|
||||
let filetype = 'nothing'
|
||||
endif
|
||||
|
||||
let snippets = neosnippet#variables#get_snippets()
|
||||
let snippets = neosnippet#variables#snippets()
|
||||
if has_key(snippets, filetype)
|
||||
return
|
||||
endif
|
||||
@@ -112,14 +112,14 @@ function! neosnippet#commands#_make_cache(filetype) "{{{
|
||||
call neosnippet#parser#_parse(snippet, snippets_file)
|
||||
endfor
|
||||
|
||||
let snippets = neosnippet#variables#get_snippets()
|
||||
let snippets = neosnippet#variables#snippets()
|
||||
let snippets[filetype] = snippet
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#commands#_source(filename) "{{{
|
||||
call neosnippet#init#check()
|
||||
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||
call neosnippet#parser#_parse(neosnippet.snippets, a:filename)
|
||||
endfunction"}}}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ endfunction"}}}
|
||||
|
||||
function! s:initialize_script_variables() "{{{
|
||||
" Set runtime dir.
|
||||
let runtime_dir = neosnippet#variables#get_runtime_dir()
|
||||
let runtime_dir = neosnippet#variables#runtime_dir()
|
||||
let runtime_dir += split(globpath(&runtimepath,
|
||||
\ 'autoload/neosnippet/snippets'), '\n')
|
||||
if g:neosnippet#enable_snipmate_compatibility
|
||||
@@ -57,7 +57,7 @@ function! s:initialize_script_variables() "{{{
|
||||
call map(runtime_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
|
||||
|
||||
" Set snippets_dir.
|
||||
let snippets_dir = neosnippet#variables#get_snippets_dir()
|
||||
let snippets_dir = neosnippet#variables#snippets_dir()
|
||||
for dir in neosnippet#util#option2list(g:neosnippet#snippets_directory)
|
||||
let dir = neosnippet#util#expand(dir)
|
||||
if !isdirectory(dir) && !neosnippet#util#is_sudo()
|
||||
@@ -130,11 +130,11 @@ function! s:initialize_others() "{{{
|
||||
endfunction"}}}
|
||||
|
||||
function! s:on_insert_leave() "{{{
|
||||
let expand_stack = neosnippet#variables#get_expand_stack()
|
||||
let expand_stack = neosnippet#variables#expand_stack()
|
||||
|
||||
" Get patterns and count.
|
||||
if empty(expand_stack)
|
||||
\ || neosnippet#get_current_neosnippet().trigger
|
||||
\ || neosnippet#variables#current_neosnippet().trigger
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ function! neosnippet#mappings#_register_oneshot_snippet() "{{{
|
||||
let selected_text = substitute(selected_text,
|
||||
\'^' . base_indent, '', 'g')
|
||||
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||
let options = neosnippet#parser#_initialize_snippet_options()
|
||||
let options.word = 1
|
||||
|
||||
@@ -164,7 +164,7 @@ function! s:trigger(function) "{{{
|
||||
endif
|
||||
|
||||
" Get selected text.
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||
let neosnippet.trigger = 1
|
||||
if mode() ==# 's' && neosnippet.selected_text =~ '^#:'
|
||||
let expr .= "\<C-o>\"_d"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"=============================================================================
|
||||
" FILE: variables.vim
|
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||
" Last Modified: 19 Nov 2013.
|
||||
" Last Modified: 21 Nov 2013.
|
||||
" License: MIT license {{{
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
@@ -27,14 +27,26 @@
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! neosnippet#variables#get_expand_stack() "{{{
|
||||
function! neosnippet#variables#current_neosnippet() "{{{
|
||||
if !exists('b:neosnippet')
|
||||
let b:neosnippet = {
|
||||
\ 'snippets' : {},
|
||||
\ 'selected_text' : '',
|
||||
\ 'target' : '',
|
||||
\ 'trigger' : 0,
|
||||
\}
|
||||
endif
|
||||
|
||||
return b:neosnippet
|
||||
endfunction"}}}
|
||||
function! neosnippet#variables#expand_stack() "{{{
|
||||
if !exists('s:expand_stack')
|
||||
let s:expand_stack = []
|
||||
endif
|
||||
|
||||
return s:expand_stack
|
||||
endfunction"}}}
|
||||
function! neosnippet#variables#get_snippets() "{{{
|
||||
function! neosnippet#variables#snippets() "{{{
|
||||
if !exists('s:snippets')
|
||||
let s:snippets= {}
|
||||
endif
|
||||
@@ -48,14 +60,14 @@ function! neosnippet#variables#set_snippets(list) "{{{
|
||||
|
||||
let s:snippets = a:list
|
||||
endfunction"}}}
|
||||
function! neosnippet#variables#get_snippets_dir() "{{{
|
||||
function! neosnippet#variables#snippets_dir() "{{{
|
||||
if !exists('s:snippets_dir')
|
||||
let s:snippets_dir = []
|
||||
endif
|
||||
|
||||
return s:snippets_dir
|
||||
endfunction"}}}
|
||||
function! neosnippet#variables#get_runtime_dir() "{{{
|
||||
function! neosnippet#variables#runtime_dir() "{{{
|
||||
if !exists('s:runtime_dir')
|
||||
let s:runtime_dir = []
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user