Refactored

This commit is contained in:
Shougo Matsushita 2017-06-15 09:11:15 +09:00
parent 6dc9701417
commit 382f68dbd0
19 changed files with 43 additions and 190 deletions

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: snippets_complete.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
let s:source = {
\ 'name' : 'snippets_complete',
\ 'kind' : 'complfunc',
@ -74,7 +71,4 @@ function! neocomplcache#sources#snippets_complete#define() abort "{{{
return s:source
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
let s:source = {
\ 'name' : 'neosnippet',
\ 'kind' : 'keyword',
@ -42,7 +39,4 @@ function! neocomplete#sources#neosnippet#define() abort "{{{
return s:source
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
" Global options definition. "{{{
call neosnippet#util#set_default(
\ 'g:neosnippet#disable_runtime_snippets', {})
@ -92,7 +89,4 @@ function! neosnippet#get_mirror_placeholder_marker_substitute_pattern() abort "{
return '\\\@<!\$\(\d\+\)'
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: commands.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
" Variables "{{{
let s:edit_options = [
\ '-runtime',
@ -205,7 +202,4 @@ function! s:get_snippet_files(path, filetype) abort "{{{
return reverse(s:get_list().uniq(snippet_files))
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: handlers.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#handlers#_cursor_moved() abort "{{{
let expand_stack = neosnippet#variables#expand_stack()
@ -51,7 +48,4 @@ function! neosnippet#handlers#_restore_unnamed_register() abort "{{{
endif
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: helpers.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#helpers#get_cursor_snippet(snippets, cur_text) abort "{{{
let cur_word = matchstr(a:cur_text, '\S\+$')
if cur_word != '' && has_key(a:snippets, cur_word)
@ -184,7 +181,4 @@ function! s:get_sources_filetypes(filetype) abort "{{{
return ['_'] + filetypes
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: init.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#init#_initialize() abort "{{{
let s:is_initialized = 1
@ -90,7 +87,4 @@ function! s:initialize_others() abort "{{{
endif"}}}
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: mappings.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#mappings#expandable_or_jumpable() abort "{{{
return neosnippet#mappings#expandable() || neosnippet#mappings#jumpable()
endfunction"}}}
@ -247,7 +244,4 @@ function! neosnippet#mappings#jump_impl() abort
return neosnippet#mappings#_trigger('neosnippet#view#_jump')
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: parser.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
let s:Cache = neosnippet#util#get_vital().import('System.Cache.Deprecated')
function! neosnippet#parser#_parse_snippets(filename) abort "{{{
@ -409,8 +406,4 @@ function! neosnippet#parser#_get_in_paren(key, pair, str) abort "{{{
return ''
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: util.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#util#get_vital() abort "{{{
if !exists('s:V')
let s:V = vital#neosnippet#new()
@ -147,7 +144,4 @@ function! neosnippet#util#option2list(str) abort "{{{
return type(a:str) == type('') ? split(a:str, '\s*,\s*') : a:str
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: variables.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#variables#current_neosnippet() abort "{{{
if !exists('b:neosnippet')
let b:neosnippet = {
@ -89,7 +86,4 @@ function! neosnippet#variables#data_dir() abort "{{{
return g:neosnippet#data_directory
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: view.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#view#_expand(cur_text, col, trigger_name) abort "{{{
let snippets = neosnippet#helpers#get_snippets()
@ -557,7 +554,4 @@ function! s:skip_next_auto_completion() abort "{{{
endif
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! unite#sources#neosnippet#define() abort "{{{
let kind = {
\ 'name' : 'neosnippet',
@ -140,7 +137,4 @@ function! s:get_keyword_pos(cur_text) abort "{{{
return cur_keyword_pos
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: neosnippet_file.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! unite#sources#neosnippet_file#define() abort "{{{
return [s:source_user, s:source_runtime]
endfunction "}}}
@ -91,7 +88,4 @@ function! s:get_snippet_candidates(dirs) abort "{{{
return _
endfunction "}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View File

@ -2,7 +2,7 @@
The neo-snippet plugin contains snippet source
Version: 5.0
Author: Shougo <Shougo.Matsu@gmail.com>
Author: Shougo <Shougo.Matsu at gmail.com>
License: MIT license
CONTENTS *neosnippet-contents*

View File

@ -1,12 +1,9 @@
"=============================================================================
" FILE: snippets.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
if !exists('b:undo_ftplugin')
let b:undo_ftplugin = ''
else
@ -21,6 +18,3 @@ let &l:commentstring="#%s"
let b:undo_ftplugin .= '
\ setlocal expandtab< shiftwidth< softtabstop< tabstop< commentstring<
\'
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -1,26 +1,7 @@
"=============================================================================
" FILE: snippets.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
" Only load this indent file when no other was loaded.
@ -29,13 +10,10 @@ if exists('b:did_indent')
endif
let b:did_indent = 1
let s:save_cpo = &cpo
set cpo&vim
if !exists('b:undo_indent')
let b:undo_indent = ''
let b:undo_indent = ''
else
let b:undo_indent .= '|'
let b:undo_indent .= '|'
endif
setlocal autoindent
@ -49,34 +27,31 @@ let b:undo_indent .= 'setlocal
\'
function! SnippetsIndent() abort "{{{
let line = getline('.')
let prev_line = (line('.') == 1)? '' : getline(line('.')-1)
let syntax = '\%(include\|snippet\|abbr\|prev_word\|delete\|alias\|options\|regexp\)\s'
let defining = '\%(snippet\|abbr\|prev_word\|alias\|options\|regexp\)\s'
let line = getline('.')
let prev_line = (line('.') == 1)? '' : getline(line('.')-1)
let syntax = '\%(include\|snippet\|abbr\|prev_word\|delete\|alias\|options\|regexp\)\s'
let defining = '\%(snippet\|abbr\|prev_word\|alias\|options\|regexp\)\s'
"for indentkeys o,O
if s:is_empty(line)
if prev_line =~ '^' . defining
return shiftwidth()
else
return -1
endif
"for indentkeys o,O
if s:is_empty(line)
if prev_line =~ '^' . defining
return shiftwidth()
else
return -1
endif
"for indentkeys =words
else
if line =~ '^\s*' . syntax
\ && (s:is_empty(prev_line)
\ || prev_line =~ '^' . defining)
return 0
else
if line =~ '^\s*' . syntax
\ && (s:is_empty(prev_line)
\ || prev_line =~ '^' . defining)
return 0
else
return -1
endif
return -1
endif
endif
endfunction"}}}
function! s:is_empty(line)
return a:line =~ '^\s*$'
return a:line =~ '^\s*$'
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -1,6 +1,6 @@
"=============================================================================
" FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
@ -11,9 +11,6 @@ elseif v:version < 704
finish
endif
let s:save_cpo = &cpo
set cpo&vim
" Plugin key-mappings. "{{{
inoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)
\ neosnippet#mappings#expand_or_jump_impl()
@ -69,8 +66,5 @@ command! -bar NeoSnippetClearMarkers
let g:loaded_neosnippet = 1
let &cpo = s:save_cpo
unlet s:save_cpo
" __END__
" vim: foldmethod=marker

View File

@ -1,31 +1,9 @@
"=============================================================================
" FILE: syntaxtax/snippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================
let s:save_cpo = &cpo
set cpo&vim
if version < 700
syntax clear
elseif exists("b:current_syntax")
@ -109,7 +87,4 @@ highlight def link neosnippetOption PreProc
highlight def link neosnippetAlias Identifier
highlight def link neosnippetEscape Special
let b:current_syntax = "snippet"
let &cpo = s:save_cpo
unlet s:save_cpo
let b:current_syntax = 'snippet'