docs: add hint on configuring custom filetypes (#5552)

I thought that this functionality was not possible but there's actually
an API for it. This seems like a useful place for others to find more
information on it.
This commit is contained in:
Hugo 2023-10-20 13:03:50 +02:00 committed by GitHub
parent eb3faef3a4
commit 1bfefd1f98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -745,3 +745,15 @@ require'nvim-treesitter.configs'.setup {
--
}
```
#### Using an existing parser for another filetype
For example, to use the `bash` tree-sitter to highlight file with
`filetype=apkbuild`, use:
```lua
vim.treesitter.language.register("bash", "apkbuild")
```
The `bash` tree-sitter must be installed following the usual procedure [as
described above](#language-parsers).