nvim-ts-autotag/README.md

95 lines
2.0 KiB
Markdown
Raw Normal View History

2021-03-08 06:19:01 -06:00
# nvim-ts-autotag
Use treesitter to **autoclose** and **autorename** html tag
2021-03-08 06:19:01 -06:00
It works with:
- astro
- glimmer
- handlebars
- html
- javascript
- jsx
- markdown
- php
- rescript
- svelte
- tsx
- twig
- typescript
- vue
- xml
2021-03-07 21:47:09 -06:00
## Usage
```text
2021-03-07 21:47:09 -06:00
Before Input After
------------------------------------
2021-08-04 10:37:59 -05:00
<div > <div></div>
<div></div> ciwspan<esc> <span></span>
2021-03-07 21:47:09 -06:00
------------------------------------
```
## Setup
Requires `Nvim 0.9.0` and up.
2021-03-10 00:09:41 -06:00
```lua
2021-03-08 08:18:10 -06:00
require('nvim-ts-autotag').setup()
2021-03-07 21:47:09 -06: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 00:50:35 -05:00
### Enable update on insert
If you have that issue
[#19](https://github.com/windwp/nvim-ts-autotag/issues/19)
2021-06-17 00:33:40 -05: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-07 21:47:09 -06:00
## Default values
```lua
2021-03-07 21:47:09 -06:00
local filetypes = {
2022-02-22 10:28:19 -06:00
'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'tsx', 'jsx', 'rescript',
'xml',
'php',
'markdown',
'astro', 'glimmer', 'handlebars', 'hbs', 'twig'
2021-03-07 21:47:09 -06:00
}
local skip_tag = {
2021-03-07 21:47:09 -06:00
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'slot',
'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr','menuitem'
}
```
### Override default values
```lua
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
```
2023-03-16 21:19:39 -05:00
## Fork Status
This is forked from https://github.com/windwp/nvim-ts-autotag due to the primary maintainer's disappearance. Any
PRs/work given to this fork _may_ end up back in the original repository if the primary maintainer comes back.
2023-03-16 21:19:39 -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.