diff --git a/lua/nvim-treesitter/_meta/parsers.lua b/lua/nvim-treesitter/_meta/parsers.lua index 3a97b35a5..54b613699 100644 --- a/lua/nvim-treesitter/_meta/parsers.lua +++ b/lua/nvim-treesitter/_meta/parsers.lua @@ -26,6 +26,9 @@ error('Cannot require a meta file') --- ---Directory with queries to be installed ---@field queries? string +--- +---Envrionment variables for generating the parser +---@field env table ---@class ParserInfo --- diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 1020e7da9..82cb1cf6e 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -167,6 +167,7 @@ end ---@param compile_location string ---@return string? err local function do_generate(logger, repo, compile_location) + local env = vim.tbl_extend('force', { TREE_SITTER_JS_RUNTIME = 'native' }, repo.env) local from_json = true if repo.generate_from_json == false then from_json = false @@ -182,7 +183,7 @@ local function do_generate(logger, repo, compile_location) '--abi', tostring(vim.treesitter.language_version), from_json and 'src/grammar.json' or nil, - }, { cwd = compile_location, env = { TREE_SITTER_JS_RUNTIME = 'native' } }) + }, { cwd = compile_location, env = env }) if r.code > 0 then return logger:error('Error during "tree-sitter generate": %s', r.stderr) end