refacto: deprecate used_by in parsers.lua

- remove print_warning function from utils.lua (unused)
- cleanup some functions in parsers.lua (parameters overloading
  and wrong bufnr used).
- log a deprecation notice when using used_by in a parser definition
- default the filetype_to_parsername table to the list of filetypes
  previously in the used_by keys
- update the README to indicate that change
This commit is contained in:
kiyan 2022-02-06 13:34:08 +01:00 committed by Kiyan
parent d7eab3a5a9
commit 58a4897e6d
3 changed files with 37 additions and 37 deletions

View file

@ -355,12 +355,19 @@ parser_config.zimbu = {
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
},
filetype = "zu", -- if filetype does not agrees with parser name
used_by = {"bar", "baz"} -- additional filetypes that use this parser
filetype = "zu", -- if filetype does not match the parser name
}
EOF
```
If you wish to set a specific parser for a filetype, you should extend the `filetype_to_parsername` table:
```vim
lua <<EOF
local ft_to_parser = require"nvim-treesitter.parser".filetype_to_parsername
filetype_to_parsername.someft = "python" -- the someft filetype will use the python parser and queries.
EOF
```
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`.