From 7a8e5e084238c488a2e2bea83490b5fcbf8e6d21 Mon Sep 17 00:00:00 2001 From: Elias <81151432+Elias-Chairi@users.noreply.github.com> Date: Thu, 15 Jan 2026 17:42:26 +0100 Subject: [PATCH] Update README with automatic highlighting instructions Added instructions for automatic highlighting based on filetypes in README. --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f542e4933..d8628f140 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,20 @@ vim.api.nvim_create_autocmd('FileType', { }) ``` +Or if you which to automaticlly enable highlighting for filetypes that correspond to installed languages, place the following in your `init.lua`: + +```lua +vim.api.nvim_create_autocmd("FileType", { + callback = function(args) + local lang = vim.treesitter.language.get_lang(args.match) + if not lang or not vim.treesitter.query.get(lang, "highlights") then + return + end + vim.treesitter.start() + end, +}) + +``` ## Folds Treesitter-based folding is provided by Neovim. To enable it, put the following in your `ftplugin` or `FileType` autocommand: