windwp / nvim-ts-autotag

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

Conflict with coq_nvim, "Not allowed to change text or change window" #100

Closed alexteal closed 1 year ago

alexteal commented 1 year ago

When using Coq.nvim alongside nvim-ts-autotag you'll run into an issue where nvim-ts-autotag is trying to paste text into the buffer while the cursor is still in an unmodifiable window. If you're familiar with Coq, that window is the little autocorrect window that shows snippets. Not sure how to fix right now, but I've got an eye on it and will update if I figure out a fix.

E5108: Error executing lua: vim/_editor.lua:0: nvim_exec2(): Vim(normal):E565: Not allowed to change text or change window
stack traceback:
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        ...r/start/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:333: in function 'close_tag'
        ...r/start/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:538: in function <...r/start/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:535>

Min steps to reproduce:

in your init.lua, plug these two plugins. I'm assuming that other plugins aren't causing the interaction, and only these plugins are enough to reproduce.

require('packer').startup(function(use)
    -- code completion using coq
    use { 'ms-jpq/coq_nvim', branch = 'coq' }
    use { 'ms-jpq/coq.artifacts', branch = 'artifacts' }

    -- syntax highlighting
    use { 'nvim-treesitter/nvim-treesitter', run = ":TSUpdate" ,
        requires = {
            'windwp/nvim-ts-autotag',
        },
        config = function()
        require('nvim-treesitter.configs').setup {
          highlight = {
              enable = true,
          },
          autotag = {
              enable = true,
          },
        }
        end,
    }
end)

Then, at the end of your init.lua, or preferably in another included file,

vim.g.coq_settings = {
  auto_start = 'shut-up',
  keymap = {
      recommended = false,
  },
  clients = {
      tabnine = {
          enabled = true,
      },
  },
}

Let me know if anyone else has run into this issue, because with my current config I'm running into so many edge cases of different close-tag plugins not working that I just can't really work on xml/html/jsx comfortably. That's my own fault, but still it'd be nice if anyone has suggestions or similar issues.

alexteal commented 1 year ago

quick fix https://github.com/windwp/nvim-ts-autotag/pull/101