mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Update README with automatic highlighting instructions
Added instructions for automatic highlighting based on filetypes in README.
This commit is contained in:
parent
15b3416cc1
commit
7a8e5e0842
1 changed files with 14 additions and 0 deletions
14
README.md
14
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue