local ts = require 'nvim-treesitter.configs' local log = require('nvim-ts-autotag._log') if not _G.test_rename then return end local helpers = {} ts.setup({ ensure_installed = _G.ts_filetypes, highlight = { use_languagetree = true, enable = true, }, fold = { enable = false }, }) function helpers.feed(text, feed_opts) feed_opts = feed_opts or 'n' local to_feed = vim.api.nvim_replace_termcodes(text, true, false, true) vim.api.nvim_feedkeys(to_feed, feed_opts, true) end function helpers.insert(text) helpers.feed('i' .. text, 'x') end local data = { { name = 'html rename open tag', filepath = './sample/index.html', filetype = 'html', linenr = 10, key = [[ciwlala]], before = [[ dsadsa ]], after = [[ dsadsa ]], }, { name = 'html rename open tag with attr', filepath = './sample/index.html', filetype = 'html', linenr = 10, key = [[ciwlala]], before = [[ dsadsa ]], after = [[ dsadsa ]], }, { name = 'html rename close tag with attr', filepath = './sample/index.html', filetype = 'html', linenr = 10, key = [[ciwlala]], before = [[
dsadsa ]], after = [[ dsadsa ]], }, { name = 'html not rename close tag on char <', filepath = './sample/index.html', filetype = 'html', linenr = 10, key = [[i<]], before = [[
dsadsa |/button> ]], after = [[
dsadsa <|/button> ]], }, { name = 'html not rename close tag with not valid', filepath = './sample/index.html', filetype = 'html', linenr = 12, key = [[ciwlala]], before = { [[]], }, after = [[
]], -- [[
"]] -- }, -- after = [[
]] -- }, { name = 'html not rename close tag with not valid', filepath = './sample/index.html', filetype = 'html', linenr = 12, key = [[ciwlala]], before = { [[
]], }, after = [[
]], }, { name = 'typescriptreact rename open tag', filepath = './sample/index.tsx', filetype = 'typescriptreact', linenr = 12, key = [[ciwlala]], before = [[ dsadsa
]], after = [[ dsadsa ]], }, { name = 'typescriptreact rename open tag with attr', filepath = './sample/index.tsx', filetype = 'typescriptreact', linenr = 12, key = [[ciwlala]], before = [[ dsadsa
]], after = [[ dsadsa
]], }, { name = 'typescriptreact rename close tag with attr', filepath = './sample/index.tsx', filetype = 'html', linenr = 12, key = [[ciwlala]], before = [[
dsadsa ]], after = [[ dsadsa ]], }, { name = '17 typescriptreact nested indentifer ', filepath = './sample/index.tsx', filetype = 'typescriptreact', linenr = 12, key = [[ciwlala]], before = [[ ]], after = [[ ]], }, { name = '18 rename empty node ', filepath = './sample/index.tsx', filetype = 'typescriptreact', linenr = 12, key = [[ilala]], before = [[<|>
]], after = [[
]], }, { name = '19 rename start tag on svelte ', filepath = './sample/index.svelte', filetype = 'svelte', linenr = 18, key = [[ciwlala]], before = [[<|data>]], after = [[]], }, { name = '20 rename end tag on svelte ', filepath = './sample/index.svelte', filetype = 'svelte', linenr = 18, key = [[ciwlala]], before = [[]], after = [[]], }, { name = "21 rescript rename open tag", filepath = './sample/index.res', filetype = "rescript", linenr = 12, key = [[ciwlala]], before = [[ dsadsa
]], after = [[ dsadsa ]] }, { name = "22 rescript rename open tag with attr", filepath = './sample/index.res', filetype = "rescript", linenr = 12, key = [[ciwlala]], before = [[ dsadsa
]], after = [[ dsadsa ]] }, { name = "23 rescript rename close tag with attr", filepath = './sample/index.res', filetype = "rescript", linenr = 12, key = [[ciwlala]], before = [[
dsadsa ]], after = [[ dsadsa ]] }, { name = '24 test check rename same with parent', filepath = './sample/index.tsx', filetype = 'typescriptreact', linenr = 12, key = 'ciwkey', before = { '', ' ', '', ' ', '', }, after = { '', ' ', '', ' ', '', }, }, { name = '25 rename start have same node with parent', filepath = './sample/index.tsx', filetype = 'typescriptreact', linenr = 12, key = [[ciwlala]], before = { '
', ' ', ' test ', '
', '
', }, after = { '
', ' ', ' test ', ' ', '
', }, }, { name = '26 rename should not rename tag on attribute node', filepath = './sample/index.tsx', filetype = 'typescriptreact', linenr = 12, key = [[ciwlala]], before = { '
', '', '
', '
', '
', '
', '
', }, after = { '
', '', '
', '
', '
', '
', '
', }, }, { name = 'eruby rename open tag', filepath = './sample/index.html.erb', filetype = 'eruby', linenr = 10, key = [[ciwlala]], before = [[ dsadsa ]], after = [[ dsadsa ]], }, { name = 'eruby rename open tag with attr', filepath = './sample/index.html.erb', filetype = 'eruby', linenr = 10, key = [[ciwlala]], before = [[ dsadsa ]], after = [[ dsadsa ]], }, { name = 'eruby rename close tag with attr', filepath = './sample/index.html.erb', filetype = 'eruby', linenr = 10, key = [[ciwlala]], before = [[
dsadsa ]], after = [[ dsadsa ]], }, { name = 'eruby not rename close tag on char <', filepath = './sample/index.html.erb', filetype = 'eruby', linenr = 10, key = [[i<]], before = [[
dsadsa |/button> ]], after = [[
dsadsa <|/button> ]], }, { name = 'eruby not rename close tag with not valid', filepath = './sample/index.html.erb', filetype = 'eruby', linenr = 12, key = [[ciwlala]], before = { [[]], }, after = [[]], }, after = [[
]], }, { name = 'eruby not rename tag-like ruby string', filepath = './sample/index.html.erb', filetype = 'eruby', linenr = 12, key = [[ciwlala]], before = { [[<%=
%>]], }, after = [[<%=
%>]], }, } local autotag = require('nvim-ts-autotag') autotag.test = true local run_data = _G.Test_filter(data) describe('[rename tag]', function() _G.Test_withfile(run_data, { cursor_add = 0, before_each = function(value) end, }) end)