style: apply formatting
This commit is contained in:
+26
-24
@@ -21,11 +21,7 @@ end
|
||||
local function start_treesitter(buf)
|
||||
local ok, err = pcall(vim.treesitter.start, buf)
|
||||
if not ok then
|
||||
log.error(
|
||||
"Failed to enable treesitter for buffer %d: %s",
|
||||
buf,
|
||||
err
|
||||
)
|
||||
log.error("Failed to enable treesitter for buffer %d: %s", buf, err)
|
||||
return
|
||||
end
|
||||
for _, win in ipairs(vim.fn.win_findbuf(buf)) do
|
||||
@@ -38,7 +34,8 @@ end
|
||||
local function activate_open_buffers(lang)
|
||||
local fts = vim.treesitter.language.get_filetypes(lang)
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_is_loaded(buf)
|
||||
if
|
||||
vim.api.nvim_buf_is_loaded(buf)
|
||||
and vim.list_contains(fts, vim.bo[buf].filetype)
|
||||
then
|
||||
start_treesitter(buf)
|
||||
@@ -49,8 +46,7 @@ end
|
||||
---@param plugin ow.Pack.Plugin
|
||||
---@param spec ow.TS.ParserSpec
|
||||
function M.build(plugin, spec)
|
||||
local cwd = spec.location
|
||||
and vim.fs.joinpath(plugin.path, spec.location)
|
||||
local cwd = spec.location and vim.fs.joinpath(plugin.path, spec.location)
|
||||
or plugin.path
|
||||
local out = parser_path(plugin, spec.lang)
|
||||
vim.fn.mkdir(vim.fs.dirname(out), "p")
|
||||
@@ -78,26 +74,32 @@ function M.build(plugin, spec)
|
||||
|
||||
if spec.generate then
|
||||
local cmd = {
|
||||
"tree-sitter", "generate",
|
||||
"--abi", tostring(vim.treesitter.language_version),
|
||||
"tree-sitter",
|
||||
"generate",
|
||||
"--abi",
|
||||
tostring(vim.treesitter.language_version),
|
||||
}
|
||||
if spec.from_json ~= false then
|
||||
table.insert(cmd, "src/grammar.json")
|
||||
end
|
||||
vim.system(cmd, {
|
||||
cwd = cwd,
|
||||
env = { TREE_SITTER_JS_RUNTIME = "native" },
|
||||
}, vim.schedule_wrap(function(r)
|
||||
if r.code ~= 0 then
|
||||
log.error(
|
||||
"Failed to generate parser for %s: %s",
|
||||
spec.lang,
|
||||
r.stderr or ""
|
||||
)
|
||||
return
|
||||
end
|
||||
do_build()
|
||||
end))
|
||||
vim.system(
|
||||
cmd,
|
||||
{
|
||||
cwd = cwd,
|
||||
env = { TREE_SITTER_JS_RUNTIME = "native" },
|
||||
},
|
||||
vim.schedule_wrap(function(r)
|
||||
if r.code ~= 0 then
|
||||
log.error(
|
||||
"Failed to generate parser for %s: %s",
|
||||
spec.lang,
|
||||
r.stderr or ""
|
||||
)
|
||||
return
|
||||
end
|
||||
do_build()
|
||||
end)
|
||||
)
|
||||
else
|
||||
do_build()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user