feat: use vim.treesitter.language.get_lang/add/register()

This commit is contained in:
Lewis Russell 2023-02-24 09:49:16 +00:00 committed by Lewis Russell
parent f15d3b0322
commit 801ef85f93
3 changed files with 49 additions and 9 deletions

View file

@ -481,13 +481,14 @@ parser_config.zimbu = {
}
```
If you wish to set a specific parser for a filetype, you should extend the `filetype_to_parsername` table:
If you wish to set a specific parser for a filetype, you should use `vim.treesitter.language.register()`:
```lua
local ft_to_parser = require"nvim-treesitter.parsers".filetype_to_parsername
ft_to_parser.someft = "python" -- the someft filetype will use the python parser and queries.
vim.treesitter.language.register('python', 'someft') -- the someft filetype will use the python parser and queries.
```
Note this requires Nvim v0.9.
4. Start `nvim` and `:TSInstall zimbu`.
You can also skip step 2 and use `:TSInstallFromGrammar zimbu` to install directly from a `grammar.js` in the top-level directory specified by `url`.