- Improved menu truncate behavior.

This commit is contained in:
Shougo Matsushita 2013-03-02 18:27:24 +09:00
parent bcbbcaf85b
commit e7f9b327de
4 changed files with 12 additions and 18 deletions

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: snippets_complete.vim " FILE: snippets_complete.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 10 Nov 2012. " Last Modified: 02 Mar 2013.
" 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
@ -55,15 +55,14 @@ endfunction"}}}
function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) "{{{ function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) "{{{
let list = s:keyword_filter(neosnippet#get_snippets(), a: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 for snippet in list
let snippet.dup = 1 let snippet.dup = 1
let snippet.neocomplcache__convertable = 0 let snippet.neocomplcache__convertable = 0
let snippet.kind = get(snippet, let snippet.kind = get(snippet,
\ 'neocomplcache__refresh', 0) ? '~' : '' \ 'neocomplcache__refresh', 0) ? '~' : ''
let snippet.menu = neosnippet#util#truncate(
\ snippet.menu_template, winwidth(0)/3)
endfor endfor
return list return list
@ -111,7 +110,6 @@ function! s:keyword_filter(snippets, cur_keyword_str) "{{{
return values(dict) return values(dict)
endfunction"}}} endfunction"}}}
function! neocomplcache#sources#snippets_complete#define() "{{{ function! neocomplcache#sources#snippets_complete#define() "{{{
return s:source return s:source
endfunction"}}} endfunction"}}}

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: 17 Feb 2013. " Last Modified: 02 Mar 2013.
" 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
@ -154,22 +154,14 @@ function! s:initialize_snippet(dict, path, line, pattern, name) "{{{
let a:dict.word .= '${0}' let a:dict.word .= '${0}'
endif endif
if a:dict.word =~ '\\\@<!`.*\\\@<!`' let menu_prefix = '[nsnip] '
let menu_prefix = '`Snip` '
elseif a:dict.word =~
\ s:get_placeholder_marker_substitute_pattern()
\ . '.*' . s:get_placeholder_marker_substitute_pattern()
let menu_prefix = '<Snip> '
else
let menu_prefix = '[Snip] '
endif
if !has_key(a:dict, 'abbr') || a:dict.abbr == '' if !has_key(a:dict, 'abbr') || a:dict.abbr == ''
" Set default abbr. " Set default abbr.
let abbr = substitute(a:dict.word, 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\|TARGET', ' ', 'g')
let a:dict.abbr = a:dict.name let a:dict.abbr = a:dict.name
else else
let abbr = a:dict.abbr 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, \ 'word' : a:dict.name, 'snip' : a:dict.word,
\ 'filter_str' : a:dict.name . ' ' . a:dict.abbr, \ 'filter_str' : a:dict.name . ' ' . a:dict.abbr,
\ 'description' : a:dict.word, \ 'description' : a:dict.word,
\ 'menu' : menu_prefix . abbr, \ 'menu_template' : menu_prefix . abbr,
\ 'options' : a:dict.options, \ 'options' : a:dict.options,
\ 'action__path' : a:path, 'action__line' : a:line, \ 'action__path' : a:path, 'action__line' : a:line,
\ 'action__pattern' : a:pattern, 'real_name' : a:name, \ 'action__pattern' : a:pattern, 'real_name' : a:name,

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: util.vim " FILE: util.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 17 Nov 2012. " Last Modified: 02 Mar 2013.
" 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
@ -53,6 +53,9 @@ endfunction"}}}
function! neosnippet#util#iconv(...) "{{{ function! neosnippet#util#iconv(...) "{{{
return call(s:V.iconv, a:000) return call(s:V.iconv, a:000)
endfunction"}}} endfunction"}}}
function! neosnippet#util#truncate(...) "{{{
return call(s:V.truncate, a:000)
endfunction"}}}
function! neosnippet#util#expand(path) "{{{ function! neosnippet#util#expand(path) "{{{
return neosnippet#util#substitute_path_separator( return neosnippet#util#substitute_path_separator(

View File

@ -743,6 +743,7 @@ CHANGELOG *neosnippet-changelog*
2013-03-02 2013-03-02
- Ver.3.1 development is started. - Ver.3.1 development is started.
- Improved truncate menu behavior.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
ChangeLog 3.0: ChangeLog 3.0: