@@ -18,32 +18,31 @@ local checkSnippetSource = function()
1818 local snippet_source = opt .get_option (' enable_snippet' )
1919 if snippet_source == nil then
2020 health_info (" You haven't setup any snippet source." )
21- elseif snippet_source == ' UltiSnips' then
22- if string.match (api .nvim_get_option (" rtp" ), " .*ultisnips.*" ) then
23- health_ok (" You are using UltiSnips as your snippet source" )
24- else
25- health_error (" UltiSnips is not available! Check if you installed Ultisnips correctly." )
26- end
27- elseif snippet_source == ' Neosnippet' then
28- if string.match (api .nvim_get_option (" rtp" ), " .*neosnippet.vim.*" ) then
29- health_ok (" You are using Neosnippet as your snippet source" )
30- else
31- health_error (" Neosnippet is not available! Check if you installed Neosnippet correctly." )
32- end
33- elseif snippet_source == ' vim-vsnip' then
34- if string.match (api .nvim_get_option (" rtp" ), " .*vsnip.*" ) then
35- health_ok (" You are using vim-vsnip as your snippet source" )
36- else
37- health_error (" vim-vsnip is not available! Check if you installed vim-vsnip correctly." )
21+ else
22+ local rtp = string.lower (api .nvim_get_option (" rtp" ))
23+ local unknown_snippet_source = true
24+ local snippet_sources = {
25+ [" UltiSnips" ] = " ultisnips" ,
26+ [" Neosnippet" ] = " neosnippet.vim" ,
27+ [" vim-snip" ] = " vsnip" ,
28+ [" snippets.nvim" ] = " snippets.nvim"
29+ }
30+
31+ for k ,v in pairs (snippet_sources ) do
32+ if snippet_source == k then
33+ unknown_snippet_source = false
34+ if string.match (rtp , " .*" .. v .. " .*" ) then
35+ health_ok (" You are using " .. k .. " as your snippet source" )
36+ else
37+ health_error (k .. " is not available! Check if you install " .. k .. " correctly." )
38+ end
39+ break
40+ end
3841 end
39- elseif snippet_source == ' snippets.nvim' then
40- if string.match (api .nvim_get_option (" rtp" ), " .*snippets.nvim.*" ) then
41- health_ok (" You are using snippets.nvim as your snippet source" )
42- else
43- health_error (" snippets.nvim is not available! Check if you installed snippets.nvim correctly." )
42+
43+ if unknown_snippet_source then
44+ health_error (" Your snippet source is not available! Possible values are: UltiSnips, Neosnippet, vim-vsnip, snippets.nvim" )
4445 end
45- else
46- health_error (" Your snippet source is not available! Possible values are: UltiSnips, Neosnippet, vim-vsnip, snippets.nvim" )
4746 end
4847end
4948
0 commit comments