windwp / nvim-ts-autotag

Use treesitter to auto close and auto rename html tag
MIT License
1.63k stars 87 forks source link

Freezes UI when closing Telescope with large ts file selected #99

Closed joshuali925 closed 1 year ago

joshuali925 commented 1 year ago

Hi, thanks for your work. I'm recently seeing an issue with nvim-ts-autotag and telescope since upgraded to 0.9 (not sure if it happened before nvim 0.9), creating the issue here first but let me know if I should also ask telescope.nvim repo.

  1. add minimal reproduction config
NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/build/neovim-stable/nvim-build/share/nvim"

Run :checkhealth for more info
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    { "windwp/nvim-ts-autotag", ft = { "html", "javascript", "javascriptreact", "typescriptreact" }, config = true },
    { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
    {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        opts = { ensure_installed = { "typescript", "tsx" } },
        config = function(_, opts) require("nvim-treesitter.configs").setup(opts) end,
    },
    {
        "williamboman/mason.nvim",
        build = ":MasonUpdate",
        dependencies = { "williamboman/mason-lspconfig.nvim", "neovim/nvim-lspconfig" },
        config = function()
            require("mason").setup()
            require("mason-lspconfig").setup({ ensure_installed = { "tsserver" } })
            require("lspconfig").tsserver.setup({})
        end,
    },
})

vim.cmd.colorscheme("habamax")
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
vim.keymap.set("n", "q", require("telescope.builtin").buffers)
{
  "lazy.nvim": { "branch": "main", "commit": "57cce98dfdb2f2dd05a0567d89811e6d0505e13b" },
  "mason-lspconfig.nvim": { "branch": "main", "commit": "a8d5db8f227b9b236d1c54a9c6234bc033825ce7" },
  "mason.nvim": { "branch": "main", "commit": "e5bb23fa9ee2a2047368b05f262de6b2152d7a27" },
  "nvim-lspconfig": { "branch": "master", "commit": "10fa01d553ce10646350461ac5ddc71f189e9d1a" },
  "nvim-treesitter": { "branch": "master", "commit": "a82501244a75b3d59cdc42496e5ad841f31e4d6d" },
  "nvim-ts-autotag": { "branch": "main", "commit": "b525525b6aba20763e19011a73454845170850d7" },
  "plenary.nvim": { "branch": "master", "commit": "9ac3e9541bbabd9d73663d757e4fe48a675bb054" },
  "telescope.nvim": { "branch": "master", "commit": "6258d50b09f9ae087317e392efe7c05a7323492d" }
}
  1. open nvim once and wait for bootstrap, then quit nvim
  2. run nvim test.js +'norm! iURLSearchParams'
  3. press gd and wait for lsp's go to definition
  4. press <CR> in quickfix to open the definition file mason/packages/typescript-language-server/node_modules/typescript/lib/lib.dom.d.ts
  5. press q for telescope buffers
  6. type lib to select the definition file
  7. press <CR> or <ESC>
  8. UI freezes

This happens on linux/mac, and UI will not freeze if nvim-ts-autotag plugin is removed. I'm not sure how to debug unresponsive UI and I haven't looked into code yet, but this doesn't happen if telescope is in normal mode when it closes. As a workaround we can force telescope to exit at normal mode, but it doesn't fix the real issue.

require("telescope").setup({
    defaults = {
        mappings = {
            i = {
                ["<Esc>"] = function(opts)
                    vim.cmd.stopinsert()
                    vim.schedule(function() actions.close(opts) end)
                end,
                ["<CR>"] = function(opts)
                    vim.cmd.stopinsert()
                    vim.schedule(function() actions.select_default(opts) end)
                end,
            },
        }
    }
})
windwp commented 1 year ago

autotag plugin is working when you leave insert mode or type >. i think it should be a bug about nvim-treesitter. you should remove autotag and test first

joshuali925 commented 1 year ago

yes i agree, it works if autotag is removed and treesitter is causing problems. but telescope prompt filetype is TelescopePrompt, should autotag plugin be disabled there?

windwp commented 1 year ago

my plug-in not working on telescopeprompt

joshuali925 commented 1 year ago

thanks, there might be something else in my system causing the issue on treesitter and autotag. will update if i have more information