From 382f68dbd0fce7fa09a0fad5356df04b83a0a9ec Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Thu, 15 Jun 2017 09:11:15 +0900 Subject: [PATCH] Refactored --- .../sources/snippets_complete.vim | 8 +- autoload/neocomplete/sources/neosnippet.vim | 8 +- autoload/neosnippet.vim | 8 +- autoload/neosnippet/commands.vim | 8 +- autoload/neosnippet/handlers.vim | 8 +- autoload/neosnippet/helpers.vim | 8 +- autoload/neosnippet/init.vim | 8 +- autoload/neosnippet/mappings.vim | 8 +- autoload/neosnippet/parser.vim | 9 +-- autoload/neosnippet/util.vim | 8 +- autoload/neosnippet/variables.vim | 8 +- autoload/neosnippet/view.vim | 8 +- autoload/unite/sources/neosnippet.vim | 8 +- autoload/unite/sources/neosnippet_file.vim | 8 +- doc/neosnippet.txt | 2 +- ftplugin/neosnippet.vim | 8 +- indent/neosnippet.vim | 73 ++++++------------- plugin/neosnippet.vim | 8 +- syntax/neosnippet.vim | 31 +------- 19 files changed, 44 insertions(+), 191 deletions(-) diff --git a/autoload/neocomplcache/sources/snippets_complete.vim b/autoload/neocomplcache/sources/snippets_complete.vim index 86b83f7..d1fcb57 100644 --- a/autoload/neocomplcache/sources/snippets_complete.vim +++ b/autoload/neocomplcache/sources/snippets_complete.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: snippets_complete.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neocomplete/sources/neosnippet.vim b/autoload/neocomplete/sources/neosnippet.vim index 8a89874..a99d319 100644 --- a/autoload/neocomplete/sources/neosnippet.vim +++ b/autoload/neocomplete/sources/neosnippet.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: neosnippet.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index 1bc0925..e6c46b2 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: neosnippet.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 '\\\@ +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neosnippet/handlers.vim b/autoload/neosnippet/handlers.vim index 87f4007..3d06014 100644 --- a/autoload/neosnippet/handlers.vim +++ b/autoload/neosnippet/handlers.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: handlers.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neosnippet/helpers.vim b/autoload/neosnippet/helpers.vim index 8474efe..8053d0a 100644 --- a/autoload/neosnippet/helpers.vim +++ b/autoload/neosnippet/helpers.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: helpers.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neosnippet/init.vim b/autoload/neosnippet/init.vim index ef84a9e..a86bf51 100644 --- a/autoload/neosnippet/init.vim +++ b/autoload/neosnippet/init.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: init.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neosnippet/mappings.vim b/autoload/neosnippet/mappings.vim index c76c7d7..1f30f36 100644 --- a/autoload/neosnippet/mappings.vim +++ b/autoload/neosnippet/mappings.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: mappings.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neosnippet/parser.vim b/autoload/neosnippet/parser.vim index b55e9d9..e8577d4 100644 --- a/autoload/neosnippet/parser.vim +++ b/autoload/neosnippet/parser.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: parser.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neosnippet/util.vim b/autoload/neosnippet/util.vim index a0752ef..7ee8e0a 100644 --- a/autoload/neosnippet/util.vim +++ b/autoload/neosnippet/util.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: util.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neosnippet/variables.vim b/autoload/neosnippet/variables.vim index 938644a..ef3e1f0 100644 --- a/autoload/neosnippet/variables.vim +++ b/autoload/neosnippet/variables.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: variables.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/neosnippet/view.vim b/autoload/neosnippet/view.vim index b878dd6..0334578 100644 --- a/autoload/neosnippet/view.vim +++ b/autoload/neosnippet/view.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: view.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/unite/sources/neosnippet.vim b/autoload/unite/sources/neosnippet.vim index fe6d36c..11760e6 100644 --- a/autoload/unite/sources/neosnippet.vim +++ b/autoload/unite/sources/neosnippet.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: neosnippet.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/autoload/unite/sources/neosnippet_file.vim b/autoload/unite/sources/neosnippet_file.vim index 87492ea..0d4d72f 100644 --- a/autoload/unite/sources/neosnippet_file.vim +++ b/autoload/unite/sources/neosnippet_file.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: neosnippet_file.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index 8d5a4c9..582d76c 100755 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -2,7 +2,7 @@ The neo-snippet plugin contains snippet source Version: 5.0 -Author: Shougo +Author: Shougo License: MIT license CONTENTS *neosnippet-contents* diff --git a/ftplugin/neosnippet.vim b/ftplugin/neosnippet.vim index 45f8edc..d8c5ecd 100644 --- a/ftplugin/neosnippet.vim +++ b/ftplugin/neosnippet.vim @@ -1,12 +1,9 @@ "============================================================================= " FILE: snippets.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 diff --git a/indent/neosnippet.vim b/indent/neosnippet.vim index 87f953b..3b24c75 100644 --- a/indent/neosnippet.vim +++ b/indent/neosnippet.vim @@ -1,26 +1,7 @@ "============================================================================= " FILE: snippets.vim -" AUTHOR: Shougo Matsushita -" 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 +" 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' - - "for indentkeys o,O - if s:is_empty(line) - if prev_line =~ '^' . defining - return shiftwidth() - else - return -1 - endif + 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 =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 diff --git a/plugin/neosnippet.vim b/plugin/neosnippet.vim index 3017d3b..b8bdeb5 100644 --- a/plugin/neosnippet.vim +++ b/plugin/neosnippet.vim @@ -1,6 +1,6 @@ "============================================================================= " FILE: neosnippet.vim -" AUTHOR: Shougo Matsushita +" AUTHOR: Shougo Matsushita " 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 (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 diff --git a/syntax/neosnippet.vim b/syntax/neosnippet.vim index 166e94b..d892abc 100644 --- a/syntax/neosnippet.vim +++ b/syntax/neosnippet.vim @@ -1,31 +1,9 @@ "============================================================================= " FILE: syntaxtax/snippet.vim -" AUTHOR: Shougo Matsushita -" 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 +" 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'