{"id":13412838,"url":"https://github.com/windwp/nvim-ts-autotag","last_synced_at":"2025-05-14T07:08:56.204Z","repository":{"id":37235745,"uuid":"345491438","full_name":"windwp/nvim-ts-autotag","owner":"windwp","description":"Use treesitter to auto close and auto rename html tag","archived":false,"fork":false,"pushed_at":"2025-02-18T20:24:37.000Z","size":160,"stargazers_count":1885,"open_issues_count":11,"forks_count":101,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-05-14T03:18:07.315Z","etag":null,"topics":["autotag","treesitter"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/windwp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://paypal.me/trieule1vn"]}},"created_at":"2021-03-08T00:59:23.000Z","updated_at":"2025-05-11T16:15:23.000Z","dependencies_parsed_at":"2023-12-10T09:23:08.895Z","dependency_job_id":"21862622-b052-4c0d-8ef5-85c6a135809d","html_url":"https://github.com/windwp/nvim-ts-autotag","commit_stats":{"total_commits":137,"total_committers":39,"mean_commits":"3.5128205128205128","dds":0.6642335766423357,"last_synced_commit":"e239a560f338be31337e7abc3ee42515daf23f5e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwp%2Fnvim-ts-autotag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwp%2Fnvim-ts-autotag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwp%2Fnvim-ts-autotag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwp%2Fnvim-ts-autotag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/windwp","download_url":"https://codeload.github.com/windwp/nvim-ts-autotag/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092776,"owners_count":22013290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autotag","treesitter"],"created_at":"2024-07-30T20:01:29.875Z","updated_at":"2025-05-14T07:08:51.191Z","avatar_url":"https://github.com/windwp.png","language":"Lua","funding_links":["https://paypal.me/trieule1vn"],"categories":["Editing Support","Lua"],"sub_categories":["Scrollbar"],"readme":"# nvim-ts-autotag\n\nUse treesitter to **autoclose** and **autorename** html tag\n\nIt works with:\n\n- astro\n- glimmer\n- handlebars\n- html\n- javascript\n- jsx\n- liquid\n- markdown\n- php\n- rescript\n- svelte\n- tsx\n- twig\n- typescript\n- vue\n- xml\n\nand more\n\n## Usage\n\n```text\nBefore        Input         After\n------------------------------------\n\u003cdiv           \u003e              \u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\u003c/div\u003e    ciwspan\u003cesc\u003e   \u003cspan\u003e\u003c/span\u003e\n------------------------------------\n```\n\n## Setup\n\nRequires `Nvim 0.9.5` and up.\n\nNote that `nvim-ts-autotag` will not work unless you have treesitter parsers (like `html`) installed for a given\nfiletype. See [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) for installing parsers.\n\n```lua\nrequire('nvim-ts-autotag').setup({\n  opts = {\n    -- Defaults\n    enable_close = true, -- Auto close tags\n    enable_rename = true, -- Auto rename pairs of tags\n    enable_close_on_slash = false -- Auto close on trailing \u003c/\n  },\n  -- Also override individual filetype configs, these take priority.\n  -- Empty by default, useful if one of the \"opts\" global settings\n  -- doesn't work well in a specific filetype\n  per_filetype = {\n    [\"html\"] = {\n      enable_close = false\n    }\n  }\n})\n```\n\n\u003e [!CAUTION]\n\u003e If you are setting up via `nvim-treesitter.configs` it has been deprecated! Please migrate to the\n\u003e new way. It will be removed in `1.0.0`.\n\n### A note on lazy loading\n\nFor those of you using lazy loading through a plugin manager (like [lazy.nvim](https://github.com/folke/lazy.nvim)) lazy\nloading is not particularly necessary for this plugin. `nvim-ts-autotag` is efficient in choosing when it needs to load.\nIf you still insist on lazy loading `nvim-ts-autotag`, then two good events to use are `BufReadPre` \u0026 `BufNewFile`.\n\n### Extending the default config\n\nLet's say that there's a language that `nvim-ts-autotag` doesn't currently support and you'd like to support it in your\nconfig. While it would be the preference of the author that you upstream your changes, perhaps you would rather not 😢.\n\nFor example, if you have a language that has a very similar layout in its Treesitter Queries as `html`, you could add an\nalias like so:\n\n```lua\nrequire('nvim-ts-autotag').setup({\n  aliases = {\n    [\"your language here\"] = \"html\",\n  }\n})\n\n-- or\nlocal TagConfigs = require(\"nvim-ts-autotag.config.init\")\nTagConfigs:add_alias(\"your language here\", \"html\")\n```\n\nThat will make `nvim-ts-autotag` close tags according to the rules of the `html` config in the given language.\n\nBut what if a parser breaks for whatever reason, for example the upstream Treesitter tree changes its node names and now\nthe default queries that `nvim-ts-autotag` provides no longer work.\n\nFear not! You can directly extend and override the existing configs. For example, let's say the start and end tag\npatterns have changed for `xml`. We can directly override the `xml` config:\n\n```lua\nlocal TagConfigs = require(\"nvim-ts-autotag.config.init\")\nTagConfigs:update(TagConfigs:get(\"xml\"):override(\"xml\", {\n    start_tag_pattern = { \"STag\" },\n    end_tag_pattern = { \"ETag\" },\n}))\n```\n\nIn fact, this very nearly what we do during our own internal initialization phase for `nvim-ts-autotag`.\n\n### Enable update on insert\n\nIf you have that issue\n[#19](https://github.com/windwp/nvim-ts-autotag/issues/19)\n\n```lua\nvim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(\n    vim.lsp.diagnostic.on_publish_diagnostics,\n    {\n        underline = true,\n        virtual_text = {\n            spacing = 5,\n            severity_limit = 'Warning',\n        },\n        update_in_insert = true,\n    }\n)\n```\n## Contributors\nThank [@PriceHiller](https://github.com/PriceHiller) for his work on this plugin.\n\n## Sponsor\nIf you find this plugin useful, please consider sponsoring the project.\n\n[Sponsor](https://paypal.me/trieule1vn)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwp%2Fnvim-ts-autotag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindwp%2Fnvim-ts-autotag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwp%2Fnvim-ts-autotag/lists"}