-
Notifications
You must be signed in to change notification settings - Fork 321
feat(snippets.default): filter_snippets function for disabling certain snippet files #996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…pet files This can be used with eg. ```lua filter_snippets = function(ft, file) return not (string.match(file, "friendly.snippets") and string.match(file, "framework")) end, ``` to disable friendly-snippets frameworks. Closes saghen#291
This is redundant now that users can filter snippets with more control.
|
Long term I think we should move the settings for the registry into the top level |
Thanks for your feature~ snippets = {
preset = "luasnip",
filter_snippets = function(_, file)
return not (string.match(file, "friendly.snippets") and string.match(file, "framework"))
end,
}, |
|
providers = {
snippets = {
opts = {
filter_snippets = function(ft, file)
return not (string.match(file, "friendly.snippets") and string.match(file, "framework"))
end,
},
},
}You're right that there is a filter_snippets = function(ft, file)
return ft == "rust" or not (string.match(file, "friendly.snippets") and string.match(file, "framework"))
end,in order to disable |
|
@stefanboca Could you update the documentation since there are still references to |
|
It also takes me some time to find this thread. Here is a use case that
snippet configsources = {
providers = {
snippets = {
opts = {
-- disable friendly-snippet frameworks, except for in rust.
filter_snippets = function(ft, file)
local disabled_fts = {
javascript = true,
javascriptreact = true, -- .jsx
typescript = true,
typescriptreact = true, -- .tsx
}
-- check if the snippet file path contains 'friendly-snippet' or 'javascript'
if
disabled_fts[ft]
and string.match(file, "friendly.snippets")
and string.match(file, "javascript")
then
return false
end
-- allow everything else by default
return true
end,
},
},
},
},The snippet file path can be referenced from friendly-snippet repo. |
thanks to: [feat(snippets.default): filter_snippets function for disabling certain snippet files by stefanboca Pull Request #996 Saghen/blink.cmp](saghen/blink.cmp#996)
This can be used with eg.
to disable friendly-snippets frameworks.
Closes #291
Also removes the
ignored_filetypesoption, which is redundant now that users can filter snippets with more control.