diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2022-01-22 11:02:55 +0100 |
|---|---|---|
| committer | Christian Clason <christian.clason@uni-due.de> | 2022-01-22 22:56:50 +0100 |
| commit | bb319daf5f374064e824f84f1f7cda487313af4e (patch) | |
| tree | cbcd3a473db29d8a7b407c98183ee9be689aa2b0 /lua/nvim-treesitter/utils.lua | |
| parent | 020905ff26e3c9f8a450d009b635d8611df492f7 (diff) | |
feat: specify abi version for generate on newer ts cli
Check tree-sitter CLI version and if > 0.20.3 and generating a parser
from grammar, use `--abi=vim.treesitter.language_version`.
Besides being able to opt-in to newer ABI benefits, this is a necessary
workaround for an upstream bug with 0.20.3, where `parser.h` is not
generated if the (optional) `--abi` flag is omitted.
Diffstat (limited to 'lua/nvim-treesitter/utils.lua')
| -rw-r--r-- | lua/nvim-treesitter/utils.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/utils.lua b/lua/nvim-treesitter/utils.lua index e6a6358a..0e836404 100644 --- a/lua/nvim-treesitter/utils.lua +++ b/lua/nvim-treesitter/utils.lua @@ -193,4 +193,13 @@ function M.to_func(a) return type(a) == "function" and a or M.constant(a) end +function M.ts_cli_version() + if fn.executable "tree-sitter" == 1 then + local handle = io.popen "tree-sitter -V" + local result = handle:read "*a" + handle:close() + return vim.split(result, "\n")[1]:match "[^tree%psitter ].*" + end +end + return M |
