- Improved snipMate compatibility.

This commit is contained in:
Shougo Matsushita 2012-10-28 18:47:26 +09:00
parent d305dde1cc
commit f1a6401519
2 changed files with 17 additions and 6 deletions

View File

@ -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: 27 Oct 2012. " Last Modified: 28 Oct 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
@ -207,10 +207,15 @@ function! s:set_snippet_pattern(dict)"{{{
\ . '.*' . s:get_placeholder_marker_substitute_pattern()) ? \ . '.*' . s:get_placeholder_marker_substitute_pattern()) ?
\ '<Snip> ' : '[Snip] ' \ '<Snip> ' : '[Snip] '
let abbr = get(a:dict, 'abbr', substitute(a:dict.word, if !has_key(a:dict, 'abbr') || a:dict.abbr == ''
" Set default abbr.
let abbr = substitute(a:dict.word,
\ s:get_placeholder_marker_pattern(). '\|'. \ s:get_placeholder_marker_pattern(). '\|'.
\ s:get_mirror_placeholder_marker_pattern(). \ s:get_mirror_placeholder_marker_pattern().
\ '\|\s\+\|\n', ' ', 'g')) \ '\|\s\+\|\n', ' ', 'g')
else
let abbr = a:dict.abbr
endif
let dict = { let dict = {
\ 'word' : a:dict.name, 'snip' : a:dict.word, \ 'word' : a:dict.name, 'snip' : a:dict.word,
@ -351,9 +356,12 @@ function! s:load_snippets(snippet, snippets_file)"{{{
" SnipMate snippets may have duplicate names, but different " SnipMate snippets may have duplicate names, but different
" descriptions (abbrs). " descriptions (abbrs).
if has_key(dup_check, snippet_pattern.name) if has_key(dup_check, snippet_pattern.name)
let snippet_pattern.name = let description = matchstr(line, '^snippet\s\+\zs.*$')
\ substitute(matchstr(line, '^snippet\s\+\zs.*$'), if description !=# snippet_pattern.name
\ '\s\+', '_', 'g') " Convert description.
let snippet_pattern.name =
\ substitute(description, '\W\+', '_', 'g')
endif
endif endif
" Collect the description (abbr) of the snippet, if set on snippet line. " Collect the description (abbr) of the snippet, if set on snippet line.

View File

@ -454,6 +454,9 @@ snippet *neosnippet-unite-action-snippet*
============================================================================== ==============================================================================
CHANGELOG *neosnippet-changelog* CHANGELOG *neosnippet-changelog*
2012-10-28
- Improved snipMate compatibility.
2012-10-27 2012-10-27
- Fixed for :SnippetEdit. - Fixed for :SnippetEdit.
- Improved g:neosnippet#disable_select_mode_mappings behavior. - Improved g:neosnippet#disable_select_mode_mappings behavior.