diff --git a/docs/recipes.md b/docs/recipes.md index 594339cf..911587a3 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -106,10 +106,10 @@ vim.api.nvim_create_autocmd('User', { ```lua sources.default = function(ctx) - local node = vim.treesitter.get_node() + local success, node = pcall(vim.treesitter.get_node) if vim.bo.filetype == 'lua' then return { 'lsp', 'path' } - elseif node and vim.tbl_contains({ 'comment', 'line_comment', 'block_comment' }, node:type()) then + elseif success and node and vim.tbl_contains({ 'comment', 'line_comment', 'block_comment' }, node:type()) then return { 'buffer' } else return { 'lsp', 'path', 'snippets', 'buffer' }