From 4bf88a9e497dc7180e9fe58551ad340de0192f39 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 15 Jul 2017 13:39:24 +0900 Subject: [PATCH] Fix #392 filetype problem --- autoload/neosnippet/helpers.vim | 2 +- autoload/neosnippet/util.vim | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/autoload/neosnippet/helpers.vim b/autoload/neosnippet/helpers.vim index e391a55..590b7eb 100644 --- a/autoload/neosnippet/helpers.vim +++ b/autoload/neosnippet/helpers.vim @@ -178,7 +178,7 @@ function! s:get_sources_filetypes(filetype) abort "{{{ \ exists('*context_filetype#get_filetypes') ? \ context_filetype#get_filetypes(a:filetype) : \ split(((a:filetype == '') ? 'nothing' : a:filetype), '\.') - return ['_'] + filetypes + return neosnippet#util#uniq(['_', a:filetype] + filetypes) endfunction"}}} " vim: foldmethod=marker diff --git a/autoload/neosnippet/util.vim b/autoload/neosnippet/util.vim index 7ee8e0a..1b570cc 100644 --- a/autoload/neosnippet/util.vim +++ b/autoload/neosnippet/util.vim @@ -144,4 +144,22 @@ function! neosnippet#util#option2list(str) abort "{{{ return type(a:str) == type('') ? split(a:str, '\s*,\s*') : a:str endfunction"}}} +function! neosnippet#util#uniq(list) abort + let list = copy(a:list) + let i = 0 + let seen = {} + while i < len(list) + let key = list[i] + if key !=# '' && has_key(seen, key) + call remove(list, i) + else + if key !=# '' + let seen[key] = 1 + endif + let i += 1 + endif + endwhile + return list +endfunction + " vim: foldmethod=marker