2021-03-08 19:19:01 +07:00
# nvim-ts-autotag
2021-03-14 07:33:13 +07:00
Use treesitter to **autoclose** and **autorename** html tag
2021-03-08 19:19:01 +07:00
2023-04-13 13:06:12 +01:00
It works with:
- astro
- glimmer
- handlebars
- html
- javascript
- jsx
- markdown
- php
- rescript
- svelte
- tsx
2024-04-27 13:09:42 +02:00
- twig
2023-04-13 13:06:12 +01:00
- typescript
- vue
- xml
2021-03-08 10:47:09 +07:00
## Usage
2024-05-15 01:44:20 -05:00
```text
2021-03-08 10:47:09 +07:00
Before Input After
------------------------------------
2021-08-04 22:37:59 +07:00
< div > < div > < / div >
< div > < / div > ciwspan< esc > < span > < / span >
2021-03-08 10:47:09 +07:00
------------------------------------
```
## Setup
2024-05-15 01:44:20 -05:00
Requires `Nvim 0.9.0` and up.
2021-03-10 13:09:41 +07:00
2024-05-15 01:44:20 -05:00
```lua
2021-03-08 21:18:10 +07:00
require('nvim-ts-autotag').setup()
2021-03-08 10:47:09 +07:00
```
2024-05-15 01:44:20 -05:00
> [!CAUTION]
> If you are setting up via `nvim-treesitter.configs` it has been deprecated! Please migrate to the
> new way. It will be removed in `1.0.0`.
2021-06-17 12:50:35 +07:00
### Enable update on insert
If you have that issue
[#19 ](https://github.com/windwp/nvim-ts-autotag/issues/19 )
2021-06-17 12:33:40 +07:00
```lua
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
{
underline = true,
virtual_text = {
spacing = 5,
severity_limit = 'Warning',
},
update_in_insert = true,
}
)
```
2024-05-15 01:44:20 -05:00
2021-03-08 10:47:09 +07:00
## Default values
2024-05-15 01:44:20 -05:00
```lua
2021-03-08 10:47:09 +07:00
local filetypes = {
2022-02-22 11:28:19 -05:00
'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'tsx', 'jsx', 'rescript',
'xml',
'php',
'markdown',
2024-04-27 13:09:42 +02:00
'astro', 'glimmer', 'handlebars', 'hbs', 'twig'
2021-03-08 10:47:09 +07:00
}
2024-05-13 04:18:34 -05:00
local skip_tag = {
2021-03-08 10:47:09 +07:00
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'slot',
'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr','menuitem'
}
```
### Override default values
2024-05-15 01:44:20 -05:00
```lua
2021-03-09 11:57:14 +07:00
require('nvim-ts-autotag').setup({
2021-03-08 10:47:09 +07:00
filetypes = { "html" , "xml" },
})
2021-03-10 13:09:41 +07:00
```
2023-03-17 09:19:39 +07:00
2024-05-13 04:14:04 -05:00
## Fork Status
2024-05-15 01:44:20 -05:00
2024-05-13 04:14:04 -05:00
This is forked from https://github.com/windwp/nvim-ts-autotag due to the primary maintainer's disappearance. Any
2024-05-15 01:44:20 -05:00
PRs/work given to this fork _may_ end up back in the original repository if the primary maintainer comes back.
2023-03-17 09:19:39 +07:00
2024-05-13 04:14:04 -05:00
Full credit to [@windwp ](https://github.com/windwp ) for the creation of this plugin. Here's to hoping they're ok and will be back sometime down the line.