Skip to content

Commit

Permalink
Templ tag completion (#154)
Browse files Browse the repository at this point in the history
* feat: added support for templ

* chore: try this?

* chore: maybe this

* feat: added templ tag closing for html tags

* chore: change quotations back
  • Loading branch information
AnthonyPoschen authored Feb 7, 2024
1 parent a65b202 commit 531f483
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lua/nvim-ts-autotag/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ M.tbl_filetypes = {
'markdown',
'astro', 'glimmer', 'handlebars', 'hbs',
'htmldjango',
'eruby'
'eruby',
'templ',
}

-- stylua: ignore
Expand Down Expand Up @@ -90,10 +91,25 @@ local SVELTE_TAG = {
skip_tag_pattern = { 'quoted_attribute_value', 'end_tag' },
}

local TEMPL_TAG = {
filetypes = {
"templ",
},
start_tag_pattern = { "tag_start" },
start_name_tag_pattern = { "element_identifier" },
end_tag_pattern = { "tag_end" },
end_name_tag_pattern = { "element_identifier" },
close_tag_pattern = { "erroneous_end_tag" },
close_name_tag_pattern = { "erroneous_end_tag_name" },
element_tag = { "element" },
skip_tag_pattern = { "quoted_attribute_value", "tag_end" },
}

local all_tag = {
HBS_TAG,
SVELTE_TAG,
JSX_TAG,
TEMPL_TAG,
}
M.enable_rename = true
M.enable_close = true
Expand Down Expand Up @@ -244,7 +260,6 @@ local function find_tag_node(opt)
pattern = tag_pattern,
skip_tag_pattern = skip_tag_pattern,
})

else
node = find_parent_match({
target = target,
Expand All @@ -263,7 +278,6 @@ local function find_tag_node(opt)
return name_node
end


-- check current node is have same name of tag_match
if is_in_table(name_tag_pattern, node:type()) then
return node
Expand Down Expand Up @@ -446,7 +460,6 @@ local function rename_start_tag()
name_tag_pattern = ts_tag.close_name_tag_pattern,
})


if close_tag_node == nil then
close_tag_node = find_child_tag_node({
target = tag_node:parent(),
Expand Down

0 comments on commit 531f483

Please sign in to comment.