Update README with automatic highlighting instructions

Added instructions for automatic highlighting based on filetypes in README.
This commit is contained in:
Elias 2026-01-15 17:42:26 +01:00 committed by GitHub
parent 15b3416cc1
commit 7a8e5e0842
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: