windwp / nvim-ts-autotag

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

Breaks Luasnip for triggers ending in '>' #102

Closed ribru17 closed 1 year ago

ribru17 commented 1 year ago

See this issue. This plugin causes Luasnip snippets to not autoexpand when their trigger ends in the > character.

windwp commented 1 year ago

you should choose 1 or write your own mapping function to combine both plugin

yioneko commented 1 year ago

Same issue here. I make a dirty hack to avoid '>' key mapping.

ribru17 commented 1 year ago

To anyone facing this issue, add this after setting up your Luasnip:

local ls = require('luasnip')
local autotag = require('nvim-ts-autotag.internal')
vim.keymap.set('i', '>', function()
  local row, col = unpack(vim.api.nvim_win_get_cursor(0))
  vim.api.nvim_buf_set_text(0, row - 1, col, row - 1, col, { '>' })
  autotag.close_tag()
  vim.api.nvim_win_set_cursor(0, { row, col + 1 })
  ls.expand_auto()
end, { remap = false })