Closed seriiserii825 closed 3 months ago
not working for me either, no errors, using the default set up. I am on a new version of NeoVim though.
neovim: NVIM v0.8.0-dev+406-g502f03fc0
windwp/nvim-ts-autotag: latest master
Same here.
Have you ran :TSInstall html
?
Have you ran
:TSInstall html
?
@YoungeonLee I have, but still the same.
I'm trying to run on LunarVim.
$ lvim -v
NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@HMBRW-A-001-M1-004.local
@danilobjr Try adding
lvim.builtin.treesitter.autotag.enable = true
to your config. If that doesn't work, try running :TSEnable autotag
.
lvim.builtin.treesitter.autotag.enable = true
@YoungeonLee This works like a charm now. Thank you so much! 🎉
require("nvim-treesitter.configs").setup({ ensure_installed = { "c", "c_sharp", "css", "go", "graphql", "html", "json", "http", "javascript", "lua", "markdown", "python", "rust", "typescript", "yaml", "bash", "comment", "java", }, sync_install = false, highlight = { enable = true, additional_vim_regex_highlighting = true, }, indent = { enable = true, disable = { "yaml" } }, rainbow = { enable = true, extended_mode = true, max_file_lines = nil, }, context_commentstring = { enable = true, enable_autocmd = false, }, autotag = { enable = true, }, })
This is my setup and it only works in html files, no jsx or tsx files
PS
Seems like adding tsx
parser solved the problem for me
@danilobjr Try adding
lvim.builtin.treesitter.autotag.enable = true
to your config. If that doesn't work, try running
:TSEnable autotag
.
That worked, thanks man!
I'm having the same problem. It just doesn't work. I tried in html, and tsx. Neither autotagging nor autorenaming Here is the setup I tried with. Here is my treesitter setup.
I'm on nvim 0.8
Finally, I figured out how to make it work.
Content of plugins.configs.treesitter
local options = {
auto_install = true,
ensure_installed = {
"lua",
"vim",
"go",
"toml",
"css",
"tsx",
"css",
"html",
"lua"
},
highlight = {
enable = true,
use_languagetree = true,
},
autotag = {
enable = true,
filetypes = {
'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'tsx', 'jsx', 'rescript',
'css', 'lua', 'xml', 'php', 'markdown'
},
},
indent = { enable = true },
}
require('nvim-treesitter.configs').setup(options)
I enabled auto install lang parsers.
I am on neovim 0.8
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@danilobjr Try adding
lvim.builtin.treesitter.autotag.enable = true
to your config. If that doesn't work, try running
:TSEnable autotag
.
works well with html, how could i do it with jsx?
@danilobjr Try adding
lvim.builtin.treesitter.autotag.enable = true
to your config. If that doesn't work, try running
:TSEnable autotag
.
Where do i have to put this line?
Same for me. nvim-ts-autotag
closes tags, but doesn't rename.
Update! It works!
But r
or x
mappings to change/delete one character don't trigger plugin!
Yeah, this isn't working for me either. I followed the instructions exactly as they are in the readme and nothing happens.
same here even tried this but nothing for PHP and TS files
Finally, I figured out how to make it work.
Content of plugins.configs.treesitter
local options = { auto_install = true, ensure_installed = { "lua", "vim", "go", "toml", "css", "tsx", "css", "html", "lua" }, highlight = { enable = true, use_languagetree = true, }, autotag = { enable = true, filetypes = { 'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'tsx', 'jsx', 'rescript', 'css', 'lua', 'xml', 'php', 'markdown' }, }, indent = { enable = true }, } require('nvim-treesitter.configs').setup(options)
I enabled auto install lang parsers.
I am on neovim 0.8
it's sad, this plugin doesn't documented properly on how to install.. i need to find open ticket just to figure out on how to install it properly
Many people, including myself, initially believe that simply configuring nvim-treesitter with the following code will make it work:
autotag = {
enable = true
}
However, to ensure it functions correctly, you also need to install the package using your Package Manager.
In my case, using NvChad and Lazy, the configuration should be:
{
"nvim-treesitter/nvim-treesitter",
opts = overrides.treesitter,
},
{
"windwp/nvim-ts-autotag",
dependencies = "nvim-treesitter/nvim-treesitter",
config = function ()
require('nvim-ts-autotag').setup({
-- your config
})
end,
lazy = true,
event = "VeryLazy"
},
It would be helpful to include this information in the documentation.
For me, I have to disable alvan/vim-closetag
plugin to make this plug-in work.
I'm using lazy.nvim. I could make it work on HTML files. But, it didn't work on ERB(Ruby template language)
I did a :TSEnable autotag
on a erb
file and it wasn't able to end a p
tag.
https://user-images.githubusercontent.com/97436/234002768-cff1b6bf-d6f0-4981-936c-d533411df560.mov
https://user-images.githubusercontent.com/97436/234002775-88bba0e1-9513-4949-b148-b58543c4d16e.mov
Note the different attempts by using embedded_template
, erb
, and eruby
.
{
'nvim-treesitter/nvim-treesitter',
build = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
dependencies = {
"RRethy/nvim-treesitter-endwise", -- Needed to prevent treesitter ident issue with Ruby: https://github.com/tree-sitter/tree-sitter-ruby/issues/230#issuecomment-1312403487
'windwp/nvim-ts-autotag'
},
config = function()
require'nvim-treesitter.configs'.setup {
ensure_installed = { "ruby", "html", "embedded_template", "css", "scss", "javascript" },
highlight = {
disable = { "lua" },
enable = { "ruby", "html", "embedded_template", "eruby", "css", "scss", "javascript" }
},
additional_vim_regex_highlighting = false,
endwise = {
enable = true,
},
autotag = {
enable = true,
filetypes = { "html" , "xml", "eruby", "erb", "embedded_template" },
}
}
end
},
UPDATE: After reading this https://github.com/windwp/nvim-ts-autotag/issues/85#issuecomment-1365556082, applying the suggested patch, and changed to call the setup on nvim-ts-autotag, I got the same behavior.
I'm using lazy.nvim. I could make it work on HTML files. But, it didn't work on ERB(Ruby template language)...
If my tests are correct, this PR https://github.com/windwp/nvim-ts-autotag/pull/104 fixed the issue for eruby
files.
I need to config it separately, this way:
{
'windwp/nvim-ts-autotag',
config = function()
require('nvim-ts-autotag').setup({
filetypes = { "html" , "xml", "eruby", "embedded_template" }
})
end
}
https://user-images.githubusercontent.com/97436/235331284-20b79b9e-c533-4a07-9334-9deeeaecde10.mov
Turn out, it missing the tsx module for treesitting for my case, make sure you have it installed by
:TSInstall tsx
The plugin only seems to work when exiting insert mode with esc
, and not with ctrl-c
Many people, including myself, initially believe that simply configuring nvim-treesitter with the following code will make it work:
autotag = { enable = true }
However, to ensure it functions correctly, you also need to install the package using your Package Manager.
In my case, using NvChad and Lazy, the configuration should be:
{ "nvim-treesitter/nvim-treesitter", opts = overrides.treesitter, }, { "windwp/nvim-ts-autotag", dependencies = "nvim-treesitter/nvim-treesitter", config = function () require('nvim-ts-autotag').setup({ -- your config }) end, lazy = true, event = "VeryLazy" },
It would be helpful to include this information in the documentation.
@hvquy001 if you would not mind, I would like to update README using your information. This will help in proper installation. I myself struggle with the installation process until found your comment. Thanks
Many people, including myself, initially believe that simply configuring nvim-treesitter with the following code will make it work:
autotag = { enable = true }
However, to ensure it functions correctly, you also need to install the package using your Package Manager. In my case, using NvChad and Lazy, the configuration should be:
{ "nvim-treesitter/nvim-treesitter", opts = overrides.treesitter, }, { "windwp/nvim-ts-autotag", dependencies = "nvim-treesitter/nvim-treesitter", config = function () require('nvim-ts-autotag').setup({ -- your config }) end, lazy = true, event = "VeryLazy" },
It would be helpful to include this information in the documentation.
@hvquy001 if you would not mind, I would like to update README using your information. This will help in proper installation. I myself struggle with the installation process until found your comment. Thanks
Thank you for posting this. I got this to work immediately with lazy.nvim using this config.
Something this crucial should be documented imo...
Hey there!
I have autotag = { enable = true, }
in my treesitter config, but it works only after I execute :TSEnable autotag
after starting nvim.
How to enable it automatically?
Thanks!
Update:
I discovered that it enables automatically when I open a file from NerdTree after starting nvim in a directory, rather than directly opening a path from the command line. It's possible to live with that, but I'd love to know whether it's possible to fix. :)
This config worked for me by throwing it in my packer.lua:
use { 'windwp/nvim-ts-autotag', config = function() require('nvim-ts-autotag').setup({ filetypes = { "html", "javascript", "javascriptreact", "typescriptreact"} })
I'm facing the autotag issue in html, but it only happens when script tag is in the buffer, weird behavior.
For me auto tag doesn't work in .html
files, but it works in .ts
files. haven't found a solution.
I have tried the proposed solution which worked for some here, but it doesn't work in my case.
I am using lazy vim It does not work for xml files for me.
ensure_installed = { "c", "query", "vimdoc", "vim", "lua", "xml", "javascript", "typescript", "css", "java", "html", "python", "vue" }, autotag = { enable = true, enable_rename = true, enable_close = true, enable_close_on_slash = true, filetypes = { "html", "xml", "vue", "typescript" }, },
Mine doesn't work yet,
custom/plugins.lua
...
{
"windwp/nvim-ts-autotag",
ft = {
"javascript", "typescript", 'javascriptreact', 'typescriptreact'
},
config = function()
require('nvim-ts-autotag').setup()
end,
lazy = true,
event = "VeryLazy"
},
{
"nvim-treesitter/nvim-treesitter",
opts = function()
opts = require "plugins.configs.treesitter"
opts.ensure_installed = {
"lua", "javascript", "typescript", "jsx", "tsx", "css", "ts", "js"
}
return opts
end
}
...
plugins/configs/treesitter.lua
local options = {
ensure_installed = { "lua", "vim", "vimdoc" },
highlight = {
enable = true,
use_languagetree = true,
},
indent = { enable = true },
autotag = { enable = true },
}
return options
Please help, Thanks.
I managed to get it work inspired by https://github.com/windwp/nvim-ts-autotag/issues/64#issuecomment-1509722026 This config is working for me using NvChad and Lazy:
{
"nvim-treesitter/nvim-treesitter",
opts = {
auto_install = true,
autotag = {
enable = true,
filetypes = {
'html', 'javascript', 'typescript', 'svelte', 'vue', 'tsx', 'jsx', 'rescript',
'css', 'lua', 'xml', 'php', 'markdown'
},
},
indent = { enable = true },
ensure_installed = {
-- defaults
"vim",
"lua",
"vimdoc",
-- web dev
"html",
"css",
"javascript",
"typescript",
"tsx",
"astro",
"vue",
"svelte",
"markdown",
"markdown_inline",
"json",
"scss",
"yaml"
}
}
},
{
"windwp/nvim-ts-autotag",
dependencies = "nvim-treesitter/nvim-treesitter",
config = function ()
require('nvim-ts-autotag').setup()
end,
lazy = true,
event = "VeryLazy"
},
Mine isn't working with markdown, too.
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
return
end
local autotag_filetypes = {
'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'tsx', 'jsx', 'rescript',
'xml',
'php',
'markdown',
'glimmer','handlebars','hbs'
}
configs.setup {
ensure_installed = { "c", "cpp", "lua", "python", "c_sharp", "typescript", "javascript", "markdown", "scss", "fish", "vim" },
sync_install = false,
ignore_install = { "" }, -- List of parsers to ignore installing
autopairs = {
enable = true,
},
autotag = {
enable = true,
filetypes = autotag_filetypes,
},
highlight = {
enable = true, -- false will disable the whole extension
disable = { "" }, -- list of language that will be disabled
additional_vim_regex_highlighting = false,
},
indent = { enable = true, disable = { "yaml" } },
rainbow = {
enable = true,
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
max_file_lines = nil, -- Do not enable for files with more than n lines, int
}
}
Many people, including myself, initially believe that simply configuring nvim-treesitter with the following code will make it work:
autotag = { enable = true }
However, to ensure it functions correctly, you also need to install the package using your Package Manager.
In my case, using NvChad and Lazy, the configuration should be:
{ "nvim-treesitter/nvim-treesitter", opts = overrides.treesitter, }, { "windwp/nvim-ts-autotag", dependencies = "nvim-treesitter/nvim-treesitter", config = function () require('nvim-ts-autotag').setup({ -- your config }) end, lazy = true, event = "VeryLazy" },
It would be helpful to include this information in the documentation.
I am using vanilla NeoVim with lazy package manager, ans this does not work for me (Stable) NVIM v0.9.6-dev-0ef2718 - Released: 19th Jan, 2024
UPDATE: Works now, just TSInstall the parser for whatever filetype you want
Hey folks, I highly encourage you to check out the new changes on main
.
This plugin will not work for certain filetypes unless you have their associated treesitter parser installed.
nvim-treesitter
does include an auto_install
flag in its config to automatically install parsers for known filetypes. Recommend you give that a shot or install the parsers as needed.
@windwp am I ok to close this issue? Been open since 2022 and the core solution is to install the correct parsers (or let nvim-treesitter
auto install them).
We can close it. The old setting configuration will not work with the current version, so it's better to open a new issue.
Many people, including myself, initially believe that simply configuring nvim-treesitter with the following code will make it work:
autotag = { enable = true }
However, to ensure it functions correctly, you also need to install the package using your Package Manager.
In my case, using NvChad and Lazy, the configuration should be:
{ "nvim-treesitter/nvim-treesitter", opts = overrides.treesitter, }, { "windwp/nvim-ts-autotag", dependencies = "nvim-treesitter/nvim-treesitter", config = function () require('nvim-ts-autotag').setup({ -- your config }) end, lazy = true, event = "VeryLazy" },
It would be helpful to include this information in the documentation.
Thanks a lot! What's missing in this answer is to verify if your target language is in ensure_installed
(I was missing html):
There's now a deprecation message when adding autotag
inside treesitter.setup
or when creating a standalone config for nvim-ts-autotag
.
Correct usage is to add import nvim-ts-autotag
inside the treesitter config:
require('nvim-ts-autotag').setup({
enable = true,
filetypes = { "html", "xml", "tsx" },
})
My full working setup:
return {
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPre", "BufNewFile" },
build = ":TSUpdate",
dependencies = {
"windwp/nvim-ts-autotag",
},
config = function()
-- import nvim-treesitter plugin
local treesitter = require("nvim-treesitter.configs")
require('nvim-ts-autotag').setup({
enable = true,
filetypes = { "html", "xml", "tsx" },
})
-- configure treesitter
treesitter.setup({ -- enable syntax highlighting
highlight = {
enable = true,
},
-- enable indentation
indent = { enable = true },
-- ensure these language parsers are installed
ensure_installed = {
"json", "html", -- add others here
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = false,
node_decremental = "<bs>",
},
},
})
end,
}
Install plugins in neovim + lua.
Create a file tree-sitter.lua and include in init.lua
In html file i can't rename html tag.