mirror of
https://github.com/windwp/nvim-ts-autotag.git
synced 2025-01-01 12:49:15 -06:00
93 lines
1.7 KiB
Markdown
93 lines
1.7 KiB
Markdown
# nvim-ts-autotag
|
|
|
|
Use treesitter to **autoclose** and **autorename** html tag
|
|
|
|
It work with html,tsx,vue,svelte,php,rescript.
|
|
|
|
## Usage
|
|
|
|
``` text
|
|
Before Input After
|
|
------------------------------------
|
|
<div > <div></div>
|
|
<div></div> ciwspan<esc> <span></span>
|
|
------------------------------------
|
|
```
|
|
|
|
|
|
## Setup
|
|
Neovim 0.7 and nvim-treesitter to work
|
|
|
|
User treesitter setup
|
|
```lua
|
|
require'nvim-treesitter.configs'.setup {
|
|
autotag = {
|
|
enable = true,
|
|
}
|
|
}
|
|
|
|
```
|
|
or you can use a set up function
|
|
|
|
``` lua
|
|
require('nvim-ts-autotag').setup()
|
|
|
|
```
|
|
|
|
### Enable update on insert
|
|
|
|
If you have that issue
|
|
[#19](https://github.com/windwp/nvim-ts-autotag/issues/19)
|
|
|
|
```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,
|
|
}
|
|
)
|
|
```
|
|
## Default values
|
|
|
|
``` lua
|
|
local filetypes = {
|
|
'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'tsx', 'jsx', 'rescript',
|
|
'xml',
|
|
'php',
|
|
'markdown',
|
|
'glimmer','handlebars','hbs'
|
|
}
|
|
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
|
|
|
|
require'nvim-treesitter.configs'.setup {
|
|
autotag = {
|
|
enable = true,
|
|
filetypes = { "html" , "xml" },
|
|
}
|
|
}
|
|
-- OR
|
|
require('nvim-ts-autotag').setup({
|
|
filetypes = { "html" , "xml" },
|
|
})
|
|
|
|
```
|
|
|
|
## Sponsor
|
|
If you find this plugin useful, please consider sponsoring the project.
|
|
|
|
[Sponsor](https://paypal.me/trieule1vn)
|