Closed robertshawjmark closed 1 year ago
same behaviour in lazyvim
Same behaviour happening in lazyvim NvChad 2.0.. not sure what's going wrong
I think there is an installed plugin preventing the nvim-ts-autotag
plugin to work, if you don't mind can you share your plugins list? maybe i can help you
Yep, I can confirm that autoclose does not work in TSX files on my vanilla config. Autorename on the other hand, does work just fine.
@kayuxcodes
Here's a minimal reproducible config. To run it, save the snippet to a file and run nvim -nu <file>
.
@musjj i think you should try the other way to setup the nvim-ts-autotag
plugin, you can make changes to your config function as this way:
config = function()
require('nvim-ts-autotag').setup({
-- optional
-- filetypes = {'tsx', 'html'}
})
end,
this should work
tsx
and typescriptreact
is already a part of the default filetypes, so adding them to the setup doesn't really do anything. Auto-rename works just fine after all, so autotag is already running in the buffer.
I think there is an installed plugin preventing the
nvim-ts-autotag
plugin to work, if you don't mind can you share your plugins list? maybe i can help you
Default:
-- All plugins have lazy=true by default,to load a plugin on startup just lazy=false
-- List of all default plugins & their definitions
local default_plugins = {
"nvim-lua/plenary.nvim",
-- nvchad plugins
{ "NvChad/extensions", branch = "v2.0" },
{
"NvChad/base46",
branch = "v2.0",
build = function()
require("base46").load_all_highlights()
end,
},
{
"NvChad/ui",
branch = "v2.0",
lazy = false,
config = function()
require "nvchad_ui"
end,
},
{
"NvChad/nvterm",
init = function()
require("core.utils").load_mappings "nvterm"
end,
config = function(_, opts)
require "base46.term"
require("nvterm").setup(opts)
end,
},
{
"NvChad/nvim-colorizer.lua",
init = function()
require("core.utils").lazy_load "nvim-colorizer.lua"
end,
config = function(_, opts)
require("colorizer").setup(opts)
-- execute colorizer as soon as possible
vim.defer_fn(function()
require("colorizer").attach_to_buffer(0)
end, 0)
end,
},
{
"nvim-tree/nvim-web-devicons",
opts = function()
return { override = require("nvchad_ui.icons").devicons }
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "devicons")
require("nvim-web-devicons").setup(opts)
end,
},
{
"lukas-reineke/indent-blankline.nvim",
init = function()
require("core.utils").lazy_load "indent-blankline.nvim"
end,
opts = function()
return require("plugins.configs.others").blankline
end,
config = function(_, opts)
require("core.utils").load_mappings "blankline"
dofile(vim.g.base46_cache .. "blankline")
require("indent_blankline").setup(opts)
end,
},
{
"nvim-treesitter/nvim-treesitter",
init = function()
require("core.utils").lazy_load "nvim-treesitter"
end,
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
build = ":TSUpdate",
opts = function()
return require "plugins.configs.treesitter"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "syntax")
require("nvim-treesitter.configs").setup(opts)
end,
},
-- git stuff
{
"lewis6991/gitsigns.nvim",
ft = { "gitcommit", "diff" },
init = function()
-- load gitsigns only when a git file is opened
vim.api.nvim_create_autocmd({ "BufRead" }, {
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
callback = function()
vim.fn.system("git -C " .. '"' .. vim.fn.expand "%:p:h" .. '"' .. " rev-parse")
if vim.v.shell_error == 0 then
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
vim.schedule(function()
require("lazy").load { plugins = { "gitsigns.nvim" } }
end)
end
end,
})
end,
opts = function()
return require("plugins.configs.others").gitsigns
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "git")
require("gitsigns").setup(opts)
end,
},
-- lsp stuff
{
"williamboman/mason.nvim",
cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" },
opts = function()
return require "plugins.configs.mason"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "mason")
require("mason").setup(opts)
-- custom nvchad cmd to install all mason binaries listed
vim.api.nvim_create_user_command("MasonInstallAll", function()
vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " "))
end, {})
vim.g.mason_binaries_list = opts.ensure_installed
end,
},
{
"neovim/nvim-lspconfig",
init = function()
require("core.utils").lazy_load "nvim-lspconfig"
end,
config = function()
require "plugins.configs.lspconfig"
end,
},
-- load luasnips + cmp related in insert mode only
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
{
-- snippet plugin
"L3MON4D3/LuaSnip",
dependencies = "rafamadriz/friendly-snippets",
opts = { history = true, updateevents = "TextChanged,TextChangedI" },
config = function(_, opts)
require("plugins.configs.others").luasnip(opts)
end,
},
-- autopairing of (){}[] etc
{
"windwp/nvim-autopairs",
opts = {
fast_wrap = {},
disable_filetype = { "TelescopePrompt", "vim" },
},
config = function(_, opts)
require("nvim-autopairs").setup(opts)
-- setup cmp for autopairs
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
end,
},
-- cmp sources plugins
{
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
},
opts = function()
return require "plugins.configs.cmp"
end,
config = function(_, opts)
require("cmp").setup(opts)
end,
},
{
"numToStr/Comment.nvim",
keys = { "gcc", "gbc" },
init = function()
require("core.utils").load_mappings "comment"
end,
config = function()
require("Comment").setup()
end,
},
-- file managing , picker etc
{
"nvim-tree/nvim-tree.lua",
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
init = function()
require("core.utils").load_mappings "nvimtree"
end,
opts = function()
return require "plugins.configs.nvimtree"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "nvimtree")
require("nvim-tree").setup(opts)
vim.g.nvimtree_side = opts.view.side
end,
},
{
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
init = function()
require("core.utils").load_mappings "telescope"
end,
opts = function()
return require "plugins.configs.telescope"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "telescope")
local telescope = require "telescope"
telescope.setup(opts)
-- load extensions
for _, ext in ipairs(opts.extensions_list) do
telescope.load_extension(ext)
end
end,
},
-- Only load whichkey after all the gui
{
"folke/which-key.nvim",
keys = { "<leader>", '"', "'", "`", "c", "v" },
init = function()
require("core.utils").load_mappings "whichkey"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "whichkey")
require("which-key").setup(opts)
end,
},
}
local config = require("core.utils").load_config()
if #config.plugins > 0 then
table.insert(default_plugins, { import = config.plugins })
end
require("lazy").setup(default_plugins, config.lazy_nvim)
Custom:
local plugins = {
-- copilot
{
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup {
panel = {
layout = {
position = "right",
},
},
}
end,
},
-- markdown preview
{
"iamcco/markdown-preview.nvim",
build = "cd app && npm install",
setup = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
},
-- install language servers
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"black",
"emmet-ls",
"eslint_d",
"hadolint",
"goimports",
--"gopls",
"isort",
"mypy",
"prettierd",
"pydocstyle",
"ruff",
--"rust-analyzer",
"rustfmt",
"shellcheck",
"shfmt",
"sqlfluff",
"stylua",
"tailwindcss-language-server",
"terraform-ls",
"tflint",
"tfsec",
"typescript-language-server",
"yaml-language-server",
},
},
},
-- configure language servers
{
"neovim/nvim-lspconfig",
dependencies = {
"jose-elias-alvarez/null-ls.nvim",
config = function()
require "custom.configs.null-ls"
end,
},
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end,
},
{
"nvim-treesitter/nvim-treesitter",
dependencies = {
"windwp/nvim-ts-autotag",
},
opts = {
autotag = {
enable = true,
filetypes = { "html", "tsx" },
},
ensure_installed = {
"bash",
"dockerfile",
"css",
"html",
"go",
"javascript",
"json",
"make",
"python",
"rst",
"terraform",
"tsx",
"typescript",
"yaml",
},
},
},
{
"windwp/nvim-ts-autotag",
config = function()
require("nvim-ts-autotag").setup {
filetypes = { "html", "tsx" },
}
end,
},
}
return plugins
local plugins = {
{
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
event = "VeryLazy",
config = function()
require("nvim-surround").setup {
-- Configuration here, or leave empty to use defaults
}
end,
},
{
"windwp/nvim-ts-autotag",
event = "VeryLazy",
lazy = true,
dependencies = "nvim-treesitter/nvim-treesitter",
config = function()
require("nvim-ts-autotag").setup {}
end,
},
{
"williamboman/mason-lspconfig.nvim",
lazy = false,
opts = function()
return require "custom.configs.mason"
end,
config = function(_, opts)
require("mason-lspconfig").setup(opts)
end,
},
{
"neovim/nvim-lspconfig",
dependencies = {
"jose-elias-alvarez/null-ls.nvim",
config = function()
require "custom.configs.null-ls"
end,
},
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end,
},
{
"jay-babu/mason-null-ls.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"williamboman/mason.nvim",
"jose-elias-alvarez/null-ls.nvim",
},
config = function()
require("mason-null-ls").setup {
ensure_installed = {
"prettier",
"stylua",
"eslint_d",
},
}
require "custom.configs.null-ls" -- require your null-ls config here (example below)
end,
},
{
"jose-elias-alvarez/typescript.nvim",
},
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "html", "json", "jsonc", "javascript", "prisma", "scss", "css", "typescript", "tsx", "yaml" },
autotag = {
enable = true,
},
},
},
}
return plugins
This is the custom plugin configuration
-- All plugins have lazy=true by default,to load a plugin on startup just lazy=false
-- List of all default plugins & their definitions
local default_plugins = {
"nvim-lua/plenary.nvim",
-- nvchad plugins
{ "NvChad/extensions", branch = "v2.0" },
{
"NvChad/base46",
branch = "v2.0",
build = function()
require("base46").load_all_highlights()
end,
},
{
"NvChad/ui",
branch = "v2.0",
lazy = false,
config = function()
require "nvchad_ui"
end,
},
{
"NvChad/nvterm",
init = function()
require("core.utils").load_mappings "nvterm"
end,
config = function(_, opts)
require "base46.term"
require("nvterm").setup(opts)
end,
},
{
"NvChad/nvim-colorizer.lua",
init = function()
require("core.utils").lazy_load "nvim-colorizer.lua"
end,
config = function(_, opts)
require("colorizer").setup(opts)
-- execute colorizer as soon as possible
vim.defer_fn(function()
require("colorizer").attach_to_buffer(0)
end, 0)
end,
},
{
"nvim-tree/nvim-web-devicons",
opts = function()
return { override = require("nvchad_ui.icons").devicons }
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "devicons")
require("nvim-web-devicons").setup(opts)
end,
},
{
"lukas-reineke/indent-blankline.nvim",
init = function()
require("core.utils").lazy_load "indent-blankline.nvim"
end,
opts = function()
return require("plugins.configs.others").blankline
end,
config = function(_, opts)
require("core.utils").load_mappings "blankline"
dofile(vim.g.base46_cache .. "blankline")
require("indent_blankline").setup(opts)
end,
},
{
"nvim-treesitter/nvim-treesitter",
init = function()
require("core.utils").lazy_load "nvim-treesitter"
end,
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
build = ":TSUpdate",
opts = function()
return require "plugins.configs.treesitter"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "syntax")
require("nvim-treesitter.configs").setup(opts)
end,
},
-- git stuff
{
"lewis6991/gitsigns.nvim",
ft = { "gitcommit", "diff" },
init = function()
-- load gitsigns only when a git file is opened
vim.api.nvim_create_autocmd({ "BufRead" }, {
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
callback = function()
vim.fn.system("git -C " .. '"' .. vim.fn.expand "%:p:h" .. '"' .. " rev-parse")
if vim.v.shell_error == 0 then
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
vim.schedule(function()
require("lazy").load { plugins = { "gitsigns.nvim" } }
end)
end
end,
})
end,
opts = function()
return require("plugins.configs.others").gitsigns
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "git")
require("gitsigns").setup(opts)
end,
},
-- lsp stuff
{
"williamboman/mason.nvim",
cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" },
opts = function()
return require "plugins.configs.mason"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "mason")
require("mason").setup(opts)
-- custom nvchad cmd to install all mason binaries listed
vim.api.nvim_create_user_command("MasonInstallAll", function()
vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " "))
end, {})
vim.g.mason_binaries_list = opts.ensure_installed
end,
},
{
"neovim/nvim-lspconfig",
init = function()
require("core.utils").lazy_load "nvim-lspconfig"
end,
config = function()
require "plugins.configs.lspconfig"
end,
},
-- load luasnips + cmp related in insert mode only
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
{
-- snippet plugin
"L3MON4D3/LuaSnip",
dependencies = "rafamadriz/friendly-snippets",
opts = { history = true, updateevents = "TextChanged,TextChangedI" },
config = function(_, opts)
require("plugins.configs.others").luasnip(opts)
end,
},
-- autopairing of (){}[] etc
{
"windwp/nvim-autopairs",
opts = {
fast_wrap = {},
disable_filetype = { "TelescopePrompt", "vim" },
},
config = function(_, opts)
require("nvim-autopairs").setup(opts)
-- setup cmp for autopairs
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
end,
},
-- cmp sources plugins
{
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
},
opts = function()
return require "plugins.configs.cmp"
end,
config = function(_, opts)
require("cmp").setup(opts)
end,
},
{
"numToStr/Comment.nvim",
keys = {
{ "gcc", mode = "n" },
{ "gc", mode = "v" },
{ "gbc", mode = "n" },
{ "gb", mode = "v" },
},
init = function()
require("core.utils").load_mappings "comment"
end,
config = function(_, opts)
require("Comment").setup(opts)
end,
},
-- file managing , picker etc
{
"nvim-tree/nvim-tree.lua",
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
init = function()
require("core.utils").load_mappings "nvimtree"
end,
opts = function()
return require "plugins.configs.nvimtree"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "nvimtree")
require("nvim-tree").setup(opts)
vim.g.nvimtree_side = opts.view.side
end,
},
{
"nvim-telescope/telescope.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
cmd = "Telescope",
init = function()
require("core.utils").load_mappings "telescope"
end,
opts = function()
return require "plugins.configs.telescope"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "telescope")
local telescope = require "telescope"
telescope.setup(opts)
-- load extensions
for _, ext in ipairs(opts.extensions_list) do
telescope.load_extension(ext)
end
end,
},
-- Only load whichkey after all the gui
{
"folke/which-key.nvim",
keys = { "<leader>", '"', "'", "`", "c", "v" },
init = function()
require("core.utils").load_mappings "whichkey"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "whichkey")
require("which-key").setup(opts)
end,
},
}
local config = require("core.utils").load_config()
if #config.plugins > 0 then
table.insert(default_plugins, { import = config.plugins })
end
require("lazy").setup(default_plugins, config.lazy_nvim)
This is default configuration list. I'm very new to this neovim customisation thing. I need one help regarding typescript configuration @robertshawjmark . If it's okay with you we can connect for that
-- All plugins have lazy=true by default,to load a plugin on startup just lazy=false -- List of all default plugins & their definitions local default_plugins = { "nvim-lua/plenary.nvim", -- nvchad plugins { "NvChad/extensions", branch = "v2.0" }, { "NvChad/base46", branch = "v2.0", build = function() require("base46").load_all_highlights() end, }, { "NvChad/ui", branch = "v2.0", lazy = false, config = function() require "nvchad_ui" end, }, { "NvChad/nvterm", init = function() require("core.utils").load_mappings "nvterm" end, config = function(_, opts) require "base46.term" require("nvterm").setup(opts) end, }, { "NvChad/nvim-colorizer.lua", init = function() require("core.utils").lazy_load "nvim-colorizer.lua" end, config = function(_, opts) require("colorizer").setup(opts) -- execute colorizer as soon as possible vim.defer_fn(function() require("colorizer").attach_to_buffer(0) end, 0) end, }, { "nvim-tree/nvim-web-devicons", opts = function() return { override = require("nvchad_ui.icons").devicons } end, config = function(_, opts) dofile(vim.g.base46_cache .. "devicons") require("nvim-web-devicons").setup(opts) end, }, { "lukas-reineke/indent-blankline.nvim", init = function() require("core.utils").lazy_load "indent-blankline.nvim" end, opts = function() return require("plugins.configs.others").blankline end, config = function(_, opts) require("core.utils").load_mappings "blankline" dofile(vim.g.base46_cache .. "blankline") require("indent_blankline").setup(opts) end, }, { "nvim-treesitter/nvim-treesitter", init = function() require("core.utils").lazy_load "nvim-treesitter" end, cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, build = ":TSUpdate", opts = function() return require "plugins.configs.treesitter" end, config = function(_, opts) dofile(vim.g.base46_cache .. "syntax") require("nvim-treesitter.configs").setup(opts) end, }, -- git stuff { "lewis6991/gitsigns.nvim", ft = { "gitcommit", "diff" }, init = function() -- load gitsigns only when a git file is opened vim.api.nvim_create_autocmd({ "BufRead" }, { group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }), callback = function() vim.fn.system("git -C " .. '"' .. vim.fn.expand "%:p:h" .. '"' .. " rev-parse") if vim.v.shell_error == 0 then vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad" vim.schedule(function() require("lazy").load { plugins = { "gitsigns.nvim" } } end) end end, }) end, opts = function() return require("plugins.configs.others").gitsigns end, config = function(_, opts) dofile(vim.g.base46_cache .. "git") require("gitsigns").setup(opts) end, }, -- lsp stuff { "williamboman/mason.nvim", cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" }, opts = function() return require "plugins.configs.mason" end, config = function(_, opts) dofile(vim.g.base46_cache .. "mason") require("mason").setup(opts) -- custom nvchad cmd to install all mason binaries listed vim.api.nvim_create_user_command("MasonInstallAll", function() vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " ")) end, {}) vim.g.mason_binaries_list = opts.ensure_installed end, }, { "neovim/nvim-lspconfig", init = function() require("core.utils").lazy_load "nvim-lspconfig" end, config = function() require "plugins.configs.lspconfig" end, }, -- load luasnips + cmp related in insert mode only { "hrsh7th/nvim-cmp", event = "InsertEnter", dependencies = { { -- snippet plugin "L3MON4D3/LuaSnip", dependencies = "rafamadriz/friendly-snippets", opts = { history = true, updateevents = "TextChanged,TextChangedI" }, config = function(_, opts) require("plugins.configs.others").luasnip(opts) end, }, -- autopairing of (){}[] etc { "windwp/nvim-autopairs", opts = { fast_wrap = {}, disable_filetype = { "TelescopePrompt", "vim" }, }, config = function(_, opts) require("nvim-autopairs").setup(opts) -- setup cmp for autopairs local cmp_autopairs = require "nvim-autopairs.completion.cmp" require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) end, }, -- cmp sources plugins { "saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lua", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", }, }, opts = function() return require "plugins.configs.cmp" end, config = function(_, opts) require("cmp").setup(opts) end, }, { "numToStr/Comment.nvim", keys = { { "gcc", mode = "n" }, { "gc", mode = "v" }, { "gbc", mode = "n" }, { "gb", mode = "v" }, }, init = function() require("core.utils").load_mappings "comment" end, config = function(_, opts) require("Comment").setup(opts) end, }, -- file managing , picker etc { "nvim-tree/nvim-tree.lua", cmd = { "NvimTreeToggle", "NvimTreeFocus" }, init = function() require("core.utils").load_mappings "nvimtree" end, opts = function() return require "plugins.configs.nvimtree" end, config = function(_, opts) dofile(vim.g.base46_cache .. "nvimtree") require("nvim-tree").setup(opts) vim.g.nvimtree_side = opts.view.side end, }, { "nvim-telescope/telescope.nvim", dependencies = "nvim-treesitter/nvim-treesitter", cmd = "Telescope", init = function() require("core.utils").load_mappings "telescope" end, opts = function() return require "plugins.configs.telescope" end, config = function(_, opts) dofile(vim.g.base46_cache .. "telescope") local telescope = require "telescope" telescope.setup(opts) -- load extensions for _, ext in ipairs(opts.extensions_list) do telescope.load_extension(ext) end end, }, -- Only load whichkey after all the gui { "folke/which-key.nvim", keys = { "<leader>", '"', "'", "`", "c", "v" }, init = function() require("core.utils").load_mappings "whichkey" end, config = function(_, opts) dofile(vim.g.base46_cache .. "whichkey") require("which-key").setup(opts) end, }, } local config = require("core.utils").load_config() if #config.plugins > 0 then table.insert(default_plugins, { import = config.plugins }) end require("lazy").setup(default_plugins, config.lazy_nvim)
This is default configuration list. I'm very new to this neovim customisation thing. I need one help regarding typescript configuration @robertshawjmark . If it's okay with you we can connect for that
Yes no problem.
I had the same problem with my nv-chad setup, try to set lazy = false
, for some reason this plugin doesn't work with lazy loading and idk why, here is my plugins.lua
setup:
{
"windwp/nvim-ts-autotag",
lazy = false,
config = function()
require('nvim-ts-autotag').setup()
end,
},
I tried setting lazy = false
but that did not fix it for me.
@musjj this works for me:
-- custom/plugins.lua
local overrides = require "custom.configs.overrides"
local plugins = {
-- other plugins
{
"windwp/nvim-ts-autotag",
ft = { "typescriptreact", "tsx" }, -- the plugin will load depend on file type (check lazy.nvim docs)
config = function()
require("nvim-ts-autotag").setup()
end,
},
{
"nvim-treesitter/nvim-treesitter",
opts = overrides.treesitter,
},
-- other plugins
}
-- custom/configs/overrides.lua
local M = {}
-- ...
M.treesitter = {
ensure_installed = {
"tsx",
"typescript",
"javascript",
"lua",
"html",
"css",
"markdown",
"markdown_inline",
},
indent = {
enable = true,
-- disable = {
-- "python"
-- },
},
}
-- ...
return M
you don't have to enable autotag
:
-- custom/configs/overrides
M.treesitter = {
autotag = {
enable = true
}
}
@kayuxcodes I can no longer reproduce the issue in a minimal config, but I still can't get it to work on my own config.
In order to complete tags, I have to type <tag></
, before it is completed (normally you only need to type <tag>
).
I have no idea what's interfering. I have a tons of plugins, but I don't have a clue what could possibly be the culprit.
@musjj actually you just need to add this lines to M.plugins
on your custom/plugins.lua
you don't need to re-configure your config.
--- custom/plugins.lua
{
"windwp/nvim-ts-autotag",
ft = { "typescriptreact", "tsx" }, -- the plugin will load depend on file type (check lazy.nvim docs)
config = function()
require("nvim-ts-autotag").setup()
end,
},
try this method and tell me if it works for you
Thanks for the help, but it turned out that the issue was caused by a really specific thing in my config. I had this custom autopair rule:
autopairs.add_rules {
Rule("<", ">"):with_pair(cond.before_regex("[%a:]+")):with_move(function(o) return o.char == ">" end),
}
Disabling this rule fixed the problem. I guess the angle brackets is causing a conflict with this plugin. Unfortunately this rule is also useful in tsx
files for typing generics, so I'll have to figure out a way to concile these two later.
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.
I had the same problem with my nv-chad setup, try to set
lazy = false
, for some reason this plugin doesn't work with lazy loading and idk why, here is myplugins.lua
setup:{ "windwp/nvim-ts-autotag", lazy = false, config = function() require('nvim-ts-autotag').setup() end, },
worked for me, #ThisIsTheWay
Lazy package configuration:
TSConfigInfo upon attachment to a .tsx file:
Issue, .tsx file:
https://github.com/windwp/nvim-ts-autotag/assets/19274062/c2b1cb17-13e4-400c-b8e6-443b73391714