From 40615e96075c743ef47aaf9de966dc348bec6459 Mon Sep 17 00:00:00 2001 From: Slotos Date: Fri, 28 Apr 2023 01:19:09 +0300 Subject: [PATCH] Add eruby defaults (#104) * Fix minimal test setup Inclusion of any config with `-u` also adds `~/.config/nvim/pack/*/start/*` to rtp, which is probably the reason for tests passing on developers' machines. This "problem" remains, and can in fact break tests through interference with other plugins. * Add eruby to default list of filetypes This merely adds tests and one line of data to default setup values. --- lua/nvim-ts-autotag/internal.lua | 3 +- sample/index.html.erb | 20 +++++++++ tests/closetag_spec.lua | 19 ++++++++- tests/minimal.vim | 12 +++--- tests/renametag_spec.lua | 72 +++++++++++++++++++++++++++++++- 5 files changed, 118 insertions(+), 8 deletions(-) create mode 100644 sample/index.html.erb diff --git a/lua/nvim-ts-autotag/internal.lua b/lua/nvim-ts-autotag/internal.lua index c8f4d1f..3b3e0ba 100644 --- a/lua/nvim-ts-autotag/internal.lua +++ b/lua/nvim-ts-autotag/internal.lua @@ -13,7 +13,8 @@ M.tbl_filetypes = { 'php', 'markdown', 'astro', 'glimmer', 'handlebars', 'hbs', - 'htmldjango' + 'htmldjango', + 'eruby' } -- stylua: ignore diff --git a/sample/index.html.erb b/sample/index.html.erb new file mode 100644 index 0000000..4b92841 --- /dev/null +++ b/sample/index.html.erb @@ -0,0 +1,20 @@ + + + + + + + <%= @document.title %> + + +
+ + + + + + + +
+ + diff --git a/tests/closetag_spec.lua b/tests/closetag_spec.lua index 4c00633..91699bf 100644 --- a/tests/closetag_spec.lua +++ b/tests/closetag_spec.lua @@ -195,7 +195,6 @@ local data = { -- after = [[
|
]], -- }, { - name = '19 lit template div', filepath = './sample/index.ts', filetype = 'typescript', @@ -204,6 +203,24 @@ local data = { before = [[| ]], }, + { + name = '20 eruby template div', + filepath = './sample/index.html.erb', + filetype = 'eruby', + linenr = 10, + key = [[>]], + before = [[| ]], + }, + { + name = '20 eruby template ruby string', + filepath = './sample/index.html.erb', + filetype = 'eruby', + linenr = 10, + key = [[>]], + before = [[<%= ]], + after = [[<%=
| %> ]], + }, } local autotag = require('nvim-ts-autotag') diff --git a/tests/minimal.vim b/tests/minimal.vim index b51881c..90ddb63 100644 --- a/tests/minimal.vim +++ b/tests/minimal.vim @@ -1,13 +1,15 @@ set rtp +=. set rtp +=../plenary.nvim/ -set rtp +=../nvim-treesitter +set rtp +=../nvim-treesitter/ set rtp +=../playground/ +set rtp +=../nvim-treesitter-rescript/ + runtime! plugin/plenary.vim -runtime! plugin/nvim-treesitter.vim -runtime! plugin/playground.vim -runtime! plugin/nvim-treesitter-rescript +runtime! plugin/nvim-treesitter.lua +runtime! plugin/nvim-treesitter-playground.lua +runtime! plugin/nvim-treesitter-rescript.vim set noswapfile @@ -27,7 +29,7 @@ _G.__is_log=true _G.test_rename = true _G.test_close = true _G.ts_filetypes = { - 'html', 'javascript', 'typescript', 'svelte', 'vue', 'tsx', 'php', 'glimmer', 'rescript' + 'html', 'javascript', 'typescript', 'svelte', 'vue', 'tsx', 'php', 'glimmer', 'rescript', 'embedded_template' } require("plenary/busted") vim.cmd[[luafile ./tests/test-utils.lua]] diff --git a/tests/renametag_spec.lua b/tests/renametag_spec.lua index 84eb0aa..faff451 100644 --- a/tests/renametag_spec.lua +++ b/tests/renametag_spec.lua @@ -257,7 +257,77 @@ local data = { '
', '', }, - } + }, + { + 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')