From e7f9b327de9f102b984170c1db345be081fd9557 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 2 Mar 2013 18:27:24 +0900 Subject: [PATCH] - Improved menu truncate behavior. --- .../neocomplcache/sources/snippets_complete.vim | 8 +++----- autoload/neosnippet.vim | 16 ++++------------ autoload/neosnippet/util.vim | 5 ++++- doc/neosnippet.txt | 1 + 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/autoload/neocomplcache/sources/snippets_complete.vim b/autoload/neocomplcache/sources/snippets_complete.vim index df98259..a07a408 100644 --- a/autoload/neocomplcache/sources/snippets_complete.vim +++ b/autoload/neocomplcache/sources/snippets_complete.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: snippets_complete.vim " AUTHOR: Shougo Matsushita -" Last Modified: 10 Nov 2012. +" Last Modified: 02 Mar 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 @@ -55,15 +55,14 @@ endfunction"}}} function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) "{{{ let list = s:keyword_filter(neosnippet#get_snippets(), a:cur_keyword_str) - " Substitute abbr. - let abbr_pattern = printf('%%.%ds..%%s', - \ g:neocomplcache_max_keyword_width-10) for snippet in list let snippet.dup = 1 let snippet.neocomplcache__convertable = 0 let snippet.kind = get(snippet, \ 'neocomplcache__refresh', 0) ? '~' : '' + let snippet.menu = neosnippet#util#truncate( + \ snippet.menu_template, winwidth(0)/3) endfor return list @@ -111,7 +110,6 @@ function! s:keyword_filter(snippets, cur_keyword_str) "{{{ return values(dict) endfunction"}}} - function! neocomplcache#sources#snippets_complete#define() "{{{ return s:source endfunction"}}} diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index 2042f0d..d6fc7d3 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: neosnippet.vim " AUTHOR: Shougo Matsushita -" Last Modified: 17 Feb 2013. +" Last Modified: 02 Mar 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 @@ -154,22 +154,14 @@ function! s:initialize_snippet(dict, path, line, pattern, name) "{{{ let a:dict.word .= '${0}' endif - if a:dict.word =~ '\\\@ ' - else - let menu_prefix = '[Snip] ' - endif + let menu_prefix = '[nsnip] ' 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\|TARGET', ' ', 'g') let a:dict.abbr = a:dict.name else let abbr = a:dict.abbr @@ -179,7 +171,7 @@ function! s:initialize_snippet(dict, path, line, pattern, name) "{{{ \ 'word' : a:dict.name, 'snip' : a:dict.word, \ 'filter_str' : a:dict.name . ' ' . a:dict.abbr, \ 'description' : a:dict.word, - \ 'menu' : menu_prefix . abbr, + \ 'menu_template' : menu_prefix . abbr, \ 'options' : a:dict.options, \ 'action__path' : a:path, 'action__line' : a:line, \ 'action__pattern' : a:pattern, 'real_name' : a:name, diff --git a/autoload/neosnippet/util.vim b/autoload/neosnippet/util.vim index 314c089..35124b0 100644 --- a/autoload/neosnippet/util.vim +++ b/autoload/neosnippet/util.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: util.vim " AUTHOR: Shougo Matsushita -" Last Modified: 17 Nov 2012. +" Last Modified: 02 Mar 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 @@ -53,6 +53,9 @@ endfunction"}}} function! neosnippet#util#iconv(...) "{{{ return call(s:V.iconv, a:000) endfunction"}}} +function! neosnippet#util#truncate(...) "{{{ + return call(s:V.truncate, a:000) +endfunction"}}} function! neosnippet#util#expand(path) "{{{ return neosnippet#util#substitute_path_separator( diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index 69a24cb..295a659 100755 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -743,6 +743,7 @@ CHANGELOG *neosnippet-changelog* 2013-03-02 - Ver.3.1 development is started. +- Improved truncate menu behavior. ------------------------------------------------------------------------------ ChangeLog 3.0: