From 1b4bf3f6206b406c1e152d93877779765993770a Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 26 Jan 2026 23:13:02 +0200 Subject: [PATCH] docs: add instructions for enabling highlighting for all filetypes This adds documentation on how to enable treesitter highlighting for all filetypes that have a parser available, using pcall to safely handle cases where no parser is installed. This pattern is already used in the plugin's minimal_init.lua and is a common use case for users who want to enable highlighting globally rather than per-filetype. Co-Authored-By: Claude Sonnet 4.5 --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index f542e4933..3ab1b5e9b 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,18 @@ vim.api.nvim_create_autocmd('FileType', { }) ``` +To enable highlighting for **all filetypes** that have a parser available, use `pcall` to safely start treesitter without specifying patterns: + +```lua +vim.api.nvim_create_autocmd('FileType', { + callback = function() + pcall(vim.treesitter.start) + end, +}) +``` + +This will automatically enable highlighting for any filetype with an installed parser, while gracefully skipping filetypes without available parsers. + ## Folds Treesitter-based folding is provided by Neovim. To enable it, put the following in your `ftplugin` or `FileType` autocommand: