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.
This commit is contained in:
Slotos 2023-04-28 01:19:09 +03:00 committed by GitHub
parent 26761ba684
commit 40615e9607
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 8 deletions

View File

@ -13,7 +13,8 @@ M.tbl_filetypes = {
'php',
'markdown',
'astro', 'glimmer', 'handlebars', 'hbs',
'htmldjango'
'htmldjango',
'eruby'
}
-- stylua: ignore

20
sample/index.html.erb Normal file
View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width= device-width , initial-scale= 1.0 ">
<title> <%= @document.title %> </title>
</head>
<body>
<div>
</div>
</body>
</html>

View File

@ -195,7 +195,6 @@ local data = {
-- after = [[<div>|</div> ]],
-- },
{
name = '19 lit template div',
filepath = './sample/index.ts',
filetype = 'typescript',
@ -204,6 +203,24 @@ local data = {
before = [[<div| ]],
after = [[<div>|</div> ]],
},
{
name = '20 eruby template div',
filepath = './sample/index.html.erb',
filetype = 'eruby',
linenr = 10,
key = [[>]],
before = [[<div| ]],
after = [[<div>|</div> ]],
},
{
name = '20 eruby template ruby string',
filepath = './sample/index.html.erb',
filetype = 'eruby',
linenr = 10,
key = [[>]],
before = [[<%= <div| %>]],
after = [[<%= <div>| %> ]],
},
}
local autotag = require('nvim-ts-autotag')

View File

@ -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]]

View File

@ -257,7 +257,77 @@ local data = {
' </div>',
'</div>',
},
}
},
{
name = 'eruby rename open tag',
filepath = './sample/index.html.erb',
filetype = 'eruby',
linenr = 10,
key = [[ciwlala]],
before = [[<di|v> dsadsa </div> ]],
after = [[<lala|> dsadsa </lala> ]],
},
{
name = 'eruby rename open tag with attr',
filepath = './sample/index.html.erb',
filetype = 'eruby',
linenr = 10,
key = [[ciwlala]],
before = [[<di|v class="lla"> dsadsa </div> ]],
after = [[<lala| class="lla"> dsadsa </lala|> ]],
},
{
name = 'eruby rename close tag with attr',
filepath = './sample/index.html.erb',
filetype = 'eruby',
linenr = 10,
key = [[ciwlala]],
before = [[<div class="lla"> dsadsa </di|v> ]],
after = [[<lala class="lla"> dsadsa </lal|a> ]],
},
{
name = 'eruby not rename close tag on char <',
filepath = './sample/index.html.erb',
filetype = 'eruby',
linenr = 10,
key = [[i<]],
before = [[<div class="lla"> dsadsa |/button> ]],
after = [[<div class="lla"> dsadsa <|/button> ]],
},
{
name = 'eruby not rename close tag with not valid',
filepath = './sample/index.html.erb',
filetype = 'eruby',
linenr = 12,
key = [[ciwlala]],
before = {
[[<di|v class="lla" ]],
[[ dsadsa </div>]],
},
after = [[<lala class="lla" ]],
},
{
name = 'eruby not rename close tag with not valid',
filepath = './sample/index.html.erb',
filetype = 'eruby',
linenr = 12,
key = [[ciwlala]],
before = {
[[<div class="lla" </d|iv>]],
},
after = [[<div class="lla" </lala|>]],
},
{
name = 'eruby not rename tag-like ruby string',
filepath = './sample/index.html.erb',
filetype = 'eruby',
linenr = 12,
key = [[ciwlala]],
before = {
[[<%= <div></d|iv> %>]],
},
after = [[<%= <div></lala|> %>]],
},
}
local autotag = require('nvim-ts-autotag')