nvim-ts-autotag/README.md

110 lines
1.9 KiB
Markdown
Raw Normal View History

2021-03-08 19:19:01 +07:00
# nvim-ts-autotag
Use treesitter to **autoclose** and **autorename** html tag
2021-03-08 19:19:01 +07:00
It works with:
- astro
- glimmer
- handlebars
- html
- javascript
- jsx
- markdown
- php
- rescript
- svelte
- tsx
- typescript
- vue
- xml
2021-03-08 10:47:09 +07:00
## Usage
``` text
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
------------------------------------
```
2021-03-08 19:19:01 +07:00
2021-03-08 10:47:09 +07:00
## Setup
2023-03-17 09:19:39 +07:00
Neovim 0.7 and nvim-treesitter to work
2021-03-08 10:47:09 +07:00
2021-03-10 13:09:41 +07:00
User treesitter setup
```lua
require'nvim-treesitter.configs'.setup {
autotag = {
enable = true,
}
}
```
or you can use a set up function
2021-03-08 10:47:09 +07:00
``` lua
2021-03-08 21:18:10 +07:00
require('nvim-ts-autotag').setup()
2021-03-10 13:09:41 +07:00
2021-03-08 10:47:09 +07:00
```
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,
}
)
```
2021-03-08 10:47:09 +07:00
## Default values
``` lua
local filetypes = {
2022-02-22 11:28:19 -05:00
'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'tsx', 'jsx', 'rescript',
'xml',
'php',
'markdown',
'astro', 'glimmer', 'handlebars', 'hbs'
2021-03-08 10:47:09 +07:00
}
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 13:09:41 +07:00
require'nvim-treesitter.configs'.setup {
autotag = {
enable = true,
2023-06-16 09:48:52 +07:00
enable_rename = true,
enable_close = true,
enable_close_on_slash = true,
2021-03-10 13:09:41 +07:00
filetypes = { "html" , "xml" },
}
}
-- OR
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
## Sponsor
If you find this plugin useful, please consider sponsoring the project.
[Sponsor](https://paypal.me/trieule1vn)