Fix #392 filetype problem

This commit is contained in:
Shougo Matsushita 2017-07-15 13:39:24 +09:00
parent d6333c191b
commit 4bf88a9e49
2 changed files with 19 additions and 1 deletions

View File

@ -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

View File

@ -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