feat(indent) test mixed indents

This commit is contained in:
Rustum Zia 2026-01-30 15:40:40 +01:00
parent 73743890eb
commit 930c60e9f7
2 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,6 @@
<body>
<script>
{
}
</script>
</body>

View file

@ -6,6 +6,33 @@ local runner = Runner:new(it, 'tests/indent/html', {
})
describe('indent HTML:', function()
-- Test embedded language indent
local augroup
before_each(function()
augroup = vim.api.nvim_create_augroup('treesitter.tests.indent', {})
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = 'javascript',
callback = function()
-- use different indent for embedded js than html
vim.bo.tabstop = 4
vim.bo.shiftwidth = 4
end,
})
local css_indent = vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = 'css',
callback = function()
-- use same indent for embedded css as html
vim.bo.tabstop = 2
vim.bo.shiftwidth = 2
end,
})
end)
after_each(function()
vim.api.nvim_del_augroup_by_id(augroup)
end)
describe('whole file:', function()
runner:whole_file('.')
end)
@ -24,5 +51,6 @@ describe('indent HTML:', function()
runner:new_line('script_style.html', { on_line = 6, text = '<div></div>', indent = 2 })
runner:new_line('script_style.html', { on_line = 9, text = 'const x = 1', indent = 2 })
runner:new_line('script_style.html', { on_line = 11, text = 'Text', indent = 2 })
runner:new_line('mixed_indent.html', { on_line = 3, text = 'const x = 1;', indent = 6 })
end)
end)