You can enable treesitter features for installed grammars in a `FileType` autocommand
or in an `ftplugin/<language>.lua` script, e.g.
```lua
vim.api.nvim_create_autocmd('FileType',{
pattern={'rust','javascript','zig'},
callback=function(ev)
localbufnr=ev.buf
-- Enable treesitter syntax highlighting and parsing for the current buffer
-- (Requires queries to be installed)
vim.treesitter.start(bufnr)
-- Enable treesitter based code folding
-- (folds are window-scoped, not buffer-scoped)
-- (Requires queries to be installed)
vim.wo.foldexpr='v:lua.vim.treesitter.foldexpr()'
vim.wo.foldmethod='expr'
end,
})
```
##### Treesitter grammars as plugin dependencies {#neovim-plugin-treesitter-grammar-dependencies}
Some Neovim plugins (like `neotest` adapters, `markdoc-nvim`, `hurl-nvim`) depend on treesitter grammars.
These dependencies are usually declared in plugin overrides.
::: {.important}
Some plugin READMEs may suggest that they depend on `nvim-treesitter`.
**This is almost always not the case.**
`nvim-treesitter` no longer provides a Lua module API for other plugins to use.
In the vast majority of cases, these plugins:
-**Depend on parsers** (not on `nvim-treesitter` or its queries).
-**Bundle their own queries** (either as `*.scm` files or hardcoded in the Lua sources).
:::
To add grammars as a plugin dependency, add an [override](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/overrides.nix):
```nix
{
foo-nvim=super.foo-nvim.overrideAttrs{
dependencies=withself.nvim-treesitter-parsers;[
markdown
markdown_inline
html
];
};
}
```
If a plugin actually does depend on the `nvim-treesitter` legacy module API, you can add