mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 11:50:09 -04:00
feat: use vim.treesitter.language.get_lang/add/register()
This commit is contained in:
parent
f15d3b0322
commit
801ef85f93
3 changed files with 49 additions and 9 deletions
|
|
@ -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`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue