mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
fix(format): update scripts to support nightly (#6126)
No need for assert as the use is contained within the script only
This commit is contained in:
parent
be5f9b0eaa
commit
039fe9095d
1 changed files with 27 additions and 12 deletions
|
|
@ -14,25 +14,40 @@ else
|
|||
end
|
||||
|
||||
ts.query.add_predicate('kind-eq?', function(match, _, _, pred)
|
||||
local cap = match[pred[2]]
|
||||
local node = type(cap) == 'table' and cap[1] or cap
|
||||
if not node then
|
||||
local nodes = match[pred[2]]
|
||||
local types = { unpack(pred, 3) }
|
||||
|
||||
if not nodes or #nodes == 0 then
|
||||
return true
|
||||
end
|
||||
|
||||
local types = { unpack(pred, 3) }
|
||||
return vim.tbl_contains(types, node:type())
|
||||
end, true)
|
||||
for _, node in pairs(nodes) do
|
||||
if not vim.tbl_contains(types, node:type()) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end, {
|
||||
force = true,
|
||||
all = true,
|
||||
})
|
||||
|
||||
ts.query.add_predicate('is-start-of-line?', function(match, _, _, pred)
|
||||
local cap = match[pred[2]]
|
||||
local node = type(cap) == 'table' and cap[1] or cap
|
||||
if not node then
|
||||
local nodes = match[pred[2]]
|
||||
if not nodes or #nodes == 0 then
|
||||
return true
|
||||
end
|
||||
local start_row, start_col = node:start()
|
||||
return vim.fn.indent(start_row + 1) == start_col
|
||||
end)
|
||||
for _, node in pairs(nodes) do
|
||||
local start_row, start_col = node:start()
|
||||
if vim.fn.indent(start_row + 1) ~= start_col then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end, {
|
||||
force = true,
|
||||
all = true,
|
||||
})
|
||||
|
||||
--- Control the indent here. Change to \t if uses tab instead
|
||||
local indent_str = ' '
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue