Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim)
create_autocmd | `boolean?` | `false` | Optionally load all snippets when opening a file. Only needed if not using [nvim-cmp](https://github.com/hrsh7th/nvim-cmp).
create_cmp_source | `boolean?` | `true` | Optionally create a [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) source. Source name will be `snippets`.
friendly_snippets | `boolean?` | `false` | Set to true if using [friendly-snippets](https://github.com/rafamadriz/friendly-snippets).
allowed_filetypes | `string[]?` | `nil` | Passed as `FileType` autocommand pattern (`*` if `nil`) to restrict the set of filetypes. Sometimes it can be more convenient than finding what filetype should be separately ignored (think about noice, mini.notify, etc.).
ignored_filetypes | `string[]?` | `nil` | Filetypes to ignore when loading snippets.
extended_filetypes | `table?` | `nil` | Filetypes to load snippets for in addition to the default ones. `ex: {typescript = {'javascript'}}`
global_snippets | `string[]?` | `{'all'}` | Snippets to load for all filetypes.
Expand Down
3 changes: 3 additions & 0 deletions lua/snippets/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ local defaults = {
--- Should we try to load the friendly-snippets snippets?
---@type boolean
friendly_snippets = false,
--- Passed as `FileType` autocommand pattern (`*` if `nil`) to restrict the set of filetypes. Sometimes it can be more convenient than finding what filetype should be separately ignored (think about noice, mini.notify, etc.).
---@type string[]?
allowed_filetypes = nil,
--- A list of filetypes to ignore snippets for
---@type table|nil
ignored_filetypes = nil,
Expand Down
2 changes: 1 addition & 1 deletion lua/snippets/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function utils.create_autocmd()

vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("snippets_ft_detect", { clear = true }),
pattern = "*",
pattern = Snippets.config.get_option("allowed_filetypes") or "*",
callback = function()
Snippets.load_snippets_for_ft(vim.bo.filetype)
end,
Expand Down