2021-03-08 06:19:01 -06:00
|
|
|
# nvim-ts-autotag
|
|
|
|
|
2021-03-08 08:20:19 -06:00
|
|
|
Use treesitter to **autoclose** and **autorename** xml tag
|
2021-03-08 06:19:01 -06:00
|
|
|
|
2021-03-10 00:12:03 -06:00
|
|
|
It work with html,xml,tsx,vue,svelte.
|
2021-03-07 21:47:09 -06:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
``` text
|
|
|
|
Before Input After
|
|
|
|
------------------------------------
|
2021-03-08 08:20:19 -06:00
|
|
|
<div > <div></div>
|
2021-03-07 21:47:09 -06:00
|
|
|
------------------------------------
|
|
|
|
```
|
|
|
|
|
2021-03-08 06:19:01 -06:00
|
|
|
|
2021-03-07 21:47:09 -06:00
|
|
|
## Setup
|
|
|
|
Neovim 0.5 with and nvim-treesitter to work
|
|
|
|
|
2021-03-10 00:09:41 -06:00
|
|
|
User treesitter setup
|
|
|
|
```lua
|
|
|
|
require'nvim-treesitter.configs'.setup {
|
|
|
|
autotag = {
|
|
|
|
enable = true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
or you can use a set up function
|
|
|
|
|
2021-03-07 21:47:09 -06:00
|
|
|
``` lua
|
2021-03-08 08:18:10 -06:00
|
|
|
require('nvim-ts-autotag').setup()
|
2021-03-10 00:09:41 -06:00
|
|
|
|
2021-03-07 21:47:09 -06:00
|
|
|
```
|
|
|
|
|
|
|
|
## Default values
|
|
|
|
|
|
|
|
``` lua
|
|
|
|
local filetypes = {
|
|
|
|
'html', 'xml', 'javascript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue'
|
|
|
|
}
|
|
|
|
local skip_tags = {
|
|
|
|
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'slot',
|
|
|
|
'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr','menuitem'
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
### Override default values
|
|
|
|
|
|
|
|
``` lua
|
2021-03-10 00:09:41 -06:00
|
|
|
|
|
|
|
require'nvim-treesitter.configs'.setup {
|
|
|
|
autotag = {
|
|
|
|
enable = true,
|
|
|
|
filetypes = { "html" , "xml" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-- OR
|
2021-03-08 22:57:14 -06:00
|
|
|
require('nvim-ts-autotag').setup({
|
2021-03-07 21:47:09 -06:00
|
|
|
filetypes = { "html" , "xml" },
|
|
|
|
})
|
|
|
|
|
2021-03-10 00:09:41 -06:00
|
|
|
```
|