mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 10:20:11 -04:00
feat(indent) test mixed indents
This commit is contained in:
parent
73743890eb
commit
930c60e9f7
2 changed files with 34 additions and 0 deletions
6
tests/indent/html/mixed_indent.html
Normal file
6
tests/indent/html/mixed_indent.html
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
@ -6,6 +6,33 @@ local runner = Runner:new(it, 'tests/indent/html', {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('indent HTML:', function()
|
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()
|
describe('whole file:', function()
|
||||||
runner:whole_file('.')
|
runner:whole_file('.')
|
||||||
end)
|
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 = 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 = 9, text = 'const x = 1', indent = 2 })
|
||||||
runner:new_line('script_style.html', { on_line = 11, text = 'Text', 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)
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue