Go to file
2021-10-08 19:34:40 +07:00
.github fix: check parser nil #29 2021-10-08 19:34:40 +07:00
lua fix: check parser nil #29 2021-10-08 19:34:40 +07:00
plugin refactor to ts module 2021-03-10 13:09:41 +07:00
sample add php 2021-06-09 20:43:17 +07:00
tests add php 2021-06-09 20:43:17 +07:00
.gitignore add autorename 2021-03-08 21:14:32 +07:00
LICENSE Initial commit 2021-03-08 07:59:24 +07:00
Makefile add autorename 2021-03-08 21:14:32 +07:00
README.md Update README.md 2021-08-04 22:37:59 +07:00

nvim-ts-autotag

Use treesitter to autoclose and autorename html tag

It work with html,tsx,vue,svelte,php.

Usage

Before        Input         After
------------------------------------
<div           >              <div></div>
<div></div>    ciwspan<esc>   <span></span>
------------------------------------

Setup

Neovim 0.5 and nvim-treesitter to work

User treesitter setup

require'nvim-treesitter.configs'.setup {
  autotag = {
    enable = true,
  }
}

or you can use a set up function

require('nvim-ts-autotag').setup()

Enable update on insert

If you have that issue #19

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

local filetypes = {
  'html', '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


require'nvim-treesitter.configs'.setup {
  autotag = {
    enable = true,
    filetypes = { "html" , "xml" },
  }
}
-- OR
require('nvim-ts-autotag').setup({
  filetypes = { "html" , "xml" },
})