From 930c60e9f7061dc2813ffb77d6efd768c861fa56 Mon Sep 17 00:00:00 2001 From: Rustum Zia Date: Fri, 30 Jan 2026 15:40:40 +0100 Subject: [PATCH] feat(indent) test mixed indents --- tests/indent/html/mixed_indent.html | 6 ++++++ tests/indent/html_spec.lua | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/indent/html/mixed_indent.html diff --git a/tests/indent/html/mixed_indent.html b/tests/indent/html/mixed_indent.html new file mode 100644 index 000000000..96ecdbdc9 --- /dev/null +++ b/tests/indent/html/mixed_indent.html @@ -0,0 +1,6 @@ + + + diff --git a/tests/indent/html_spec.lua b/tests/indent/html_spec.lua index b240b7150..4aee7e5ae 100644 --- a/tests/indent/html_spec.lua +++ b/tests/indent/html_spec.lua @@ -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 = '
', 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)