From f1a64015198b3da53c1e37852b64a728c8fb7d08 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sun, 28 Oct 2012 18:47:26 +0900 Subject: [PATCH] - Improved snipMate compatibility. --- autoload/neosnippet.vim | 20 ++++++++++++++------ doc/neosnippet.txt | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index e968c16..340cfc3 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: neosnippet.vim " AUTHOR: Shougo Matsushita -" Last Modified: 27 Oct 2012. +" Last Modified: 28 Oct 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 @@ -207,10 +207,15 @@ function! s:set_snippet_pattern(dict)"{{{ \ . '.*' . s:get_placeholder_marker_substitute_pattern()) ? \ ' ' : '[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_mirror_placeholder_marker_pattern(). - \ '\|\s\+\|\n', ' ', 'g')) + \ '\|\s\+\|\n', ' ', 'g') + else + let abbr = a:dict.abbr + endif let dict = { \ '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 " descriptions (abbrs). if has_key(dup_check, snippet_pattern.name) - let snippet_pattern.name = - \ substitute(matchstr(line, '^snippet\s\+\zs.*$'), - \ '\s\+', '_', 'g') + let description = matchstr(line, '^snippet\s\+\zs.*$') + if description !=# snippet_pattern.name + " Convert description. + let snippet_pattern.name = + \ substitute(description, '\W\+', '_', 'g') + endif endif " Collect the description (abbr) of the snippet, if set on snippet line. diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index 21f82d9..c4ff305 100644 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -454,6 +454,9 @@ snippet *neosnippet-unite-action-snippet* ============================================================================== CHANGELOG *neosnippet-changelog* +2012-10-28 +- Improved snipMate compatibility. + 2012-10-27 - Fixed for :SnippetEdit. - Improved g:neosnippet#disable_select_mode_mappings behavior.