mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 11:20:07 -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
|
end
|
||||||
|
|
||||||
ts.query.add_predicate('kind-eq?', function(match, _, _, pred)
|
ts.query.add_predicate('kind-eq?', function(match, _, _, pred)
|
||||||
local cap = match[pred[2]]
|
local nodes = match[pred[2]]
|
||||||
local node = type(cap) == 'table' and cap[1] or cap
|
local types = { unpack(pred, 3) }
|
||||||
if not node then
|
|
||||||
|
if not nodes or #nodes == 0 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local types = { unpack(pred, 3) }
|
for _, node in pairs(nodes) do
|
||||||
return vim.tbl_contains(types, node:type())
|
if not vim.tbl_contains(types, node:type()) then
|
||||||
end, true)
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end, {
|
||||||
|
force = true,
|
||||||
|
all = true,
|
||||||
|
})
|
||||||
|
|
||||||
ts.query.add_predicate('is-start-of-line?', function(match, _, _, pred)
|
ts.query.add_predicate('is-start-of-line?', function(match, _, _, pred)
|
||||||
local cap = match[pred[2]]
|
local nodes = match[pred[2]]
|
||||||
local node = type(cap) == 'table' and cap[1] or cap
|
if not nodes or #nodes == 0 then
|
||||||
if not node then
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
local start_row, start_col = node:start()
|
for _, node in pairs(nodes) do
|
||||||
return vim.fn.indent(start_row + 1) == start_col
|
local start_row, start_col = node:start()
|
||||||
end)
|
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
|
--- Control the indent here. Change to \t if uses tab instead
|
||||||
local indent_str = ' '
|
local indent_str = ' '
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue