indents(c): add zero_indent for #if

This commit is contained in:
Stephan Seitz 2022-01-22 18:24:38 +01:00
parent 616dc885fc
commit fd5a551d7c
7 changed files with 18 additions and 13 deletions

View file

@ -35,6 +35,7 @@ local get_indents = tsutils.memoize_by_buf_tick(function(bufnr, root, lang)
branch = {},
ignore = {},
aligned_indent = {},
zero_indent = {},
}
for name, node, metadata in queries.iter_captures(bufnr, "indents", root, lang) do
@ -88,6 +89,10 @@ function M.get_indent(lnum)
-- tracks to ensure multiple indent levels are not applied for same line
local is_processed_by_row = {}
if q.zero_indent[node:id()] then
return 0
end
while node do
-- do 'autoindent' if not marked as @indent
if not q.indent[node:id()] and q.auto[node:id()] and node:start() < lnum - 1 and lnum - 1 <= node:end_() then