mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-15 09:50:04 -04:00
feat(install): support custom env when generating the parser
This commit is contained in:
parent
f8bbc3177d
commit
ec0ec4a103
2 changed files with 5 additions and 1 deletions
|
|
@ -26,6 +26,9 @@ error('Cannot require a meta file')
|
||||||
---
|
---
|
||||||
---Directory with queries to be installed
|
---Directory with queries to be installed
|
||||||
---@field queries? string
|
---@field queries? string
|
||||||
|
---
|
||||||
|
---Envrionment variables for generating the parser
|
||||||
|
---@field env table<string, string|number>
|
||||||
|
|
||||||
---@class ParserInfo
|
---@class ParserInfo
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,7 @@ end
|
||||||
---@param compile_location string
|
---@param compile_location string
|
||||||
---@return string? err
|
---@return string? err
|
||||||
local function do_generate(logger, repo, compile_location)
|
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
|
local from_json = true
|
||||||
if repo.generate_from_json == false then
|
if repo.generate_from_json == false then
|
||||||
from_json = false
|
from_json = false
|
||||||
|
|
@ -182,7 +183,7 @@ local function do_generate(logger, repo, compile_location)
|
||||||
'--abi',
|
'--abi',
|
||||||
tostring(vim.treesitter.language_version),
|
tostring(vim.treesitter.language_version),
|
||||||
from_json and 'src/grammar.json' or nil,
|
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
|
if r.code > 0 then
|
||||||
return logger:error('Error during "tree-sitter generate": %s', r.stderr)
|
return logger:error('Error during "tree-sitter generate": %s', r.stderr)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue