Skip to content

Commit

Permalink
fix: use luasnip get_snippet_filetypes, remove global_snippets option
Browse files Browse the repository at this point in the history
Closes #603
  • Loading branch information
Saghen committed Dec 17, 2024
1 parent 380bccf commit c0b5ae9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,6 @@ MiniDeps.add({
use_show_condition = true,
-- Whether to show autosnippets in the completion list
show_autosnippets = true,
-- Snippet filetypes to always include in the completion list
global_snippets = { 'all' },
}
},
buffer = {
Expand Down
15 changes: 5 additions & 10 deletions lua/blink/cmp/sources/luasnip.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
--- @class blink.cmp.LuasnipSourceOptions
--- @field use_show_condition? boolean Whether to use show_condition for filtering snippets
--- @field show_autosnippets? boolean Whether to show autosnippets in the completion list
--- @field global_snippets? string[] Snippet filetypes to always include in the completion list

--- @class blink.cmp.LuasnipSource : blink.cmp.Source
--- @field config blink.cmp.LuasnipSourceOptions
Expand All @@ -14,7 +13,6 @@ local source = {}
local defaults_config = {
use_show_condition = true,
show_autosnippets = true,
global_snippets = { 'all' },
}

function source.new(opts)
Expand Down Expand Up @@ -45,15 +43,12 @@ function source:get_completions(ctx, callback)
local ls = require('luasnip')
local snippets = {}

for _, extra_ft in ipairs(self.config.global_snippets) do
vim.list_extend(snippets, ls.get_snippets(extra_ft, { type = 'snippets' }))
end
vim.list_extend(snippets, ls.get_snippets(ft, { type = 'snippets' }))
if self.config.show_autosnippets then
for _, extra_ft in ipairs(self.config.global_snippets) do
vim.list_extend(snippets, ls.get_snippets(extra_ft, { type = 'autosnippets' }))
local filetypes = require('luasnip.util.util').get_snippet_filetypes()
for _, filetype in ipairs(filetypes) do
vim.list_extend(snippets, ls.get_snippets(filetype, { type = 'snippets' }))
if self.config.show_autosnippets then
vim.list_extend(snippets, ls.get_snippets(filetype, { type = 'autosnippets' }))
end
vim.list_extend(snippets, ls.get_snippets(ft, { type = 'autosnippets' }))
end
snippets = vim.tbl_filter(function(snip) return not snip.hidden end, snippets)

Expand Down

0 comments on commit c0b5ae9

Please sign in to comment.