vim-matchtag icon indicating copy to clipboard operation
vim-matchtag copied to clipboard

Can't get it to work with .svelte files in LazyVim

Open ArturLinnik opened this issue 1 year ago • 3 comments

I don't really know if it's lazyvim's specific issue or this plugin's but when I install it it doesn't work. This is my matchit.lua file:

return {
  -- Add vim-matchtag plugin
  {
    "leafOfTree/vim-matchtag",
    config = function()
      -- Enable by default for specific file types, including .svelte
      vim.g.vim_matchtag_enable_by_default = 1
      vim.g.vim_matchtag_files = "*.html,*.xml,*.js,*.jsx,*.vue,*.svelte"
    end,
    ft = { "html", "xml", "svelte", "javascript", "typescript", "vue" },
  },
}

ArturLinnik avatar Oct 04 '24 06:10 ArturLinnik

hi there, thanks for your report. It didn't work by default on the first file opened because lazyvim loads the plugin after the file is opened.

I've made some changes to fix this. Please update your vim-matchtag to the latest and try.

leafOfTree avatar Oct 10 '24 11:10 leafOfTree

H!. First of all thank you for working in this plugin. I'm sure it will be one of my favourites when we get it to work.

I just updated LazyVim (l+U) but nothing changes. Maybe I don't understand something. The way I'm trying it I open a .svelte file and with the cursor on one of the characters of a <div> tag I press % where I expect it to jump to the closing </div> tag, but instead it does nothing.

When I try this plugin in a .html file it works as expected.

I don't know what can be wrong, maybe I have another plugin that is causing a conflict. Would it be useful if I share my lazyvim's config so you can recreate it in your own workspace? If so, this is my repo with my lazyvim's config: https://github.com/ArturLinnik/lazy-vim-dotfiles

Also, if there is a way I can help contributing to this repo please make me know.

ArturLinnik avatar Oct 10 '24 11:10 ArturLinnik

Hi Artur, Thanks for your recognition! Pull requests are always welcome. Feel free to check open issues https://github.com/leafOfTree/vim-matchtag/issues and see if you want to look at any of them.

For this issue

  • this plugin vim-matchtag only highlights tags.
  • the bundled plugin matchit provides % to jump between tags. You can see the details by :h matchit and :h matchit-newlang. svelte is not supported by default.

I have another plugin https://github.com/leafOfTree/vim-svelte-plugin which provides matchit support. Or you can set b:match_words in your own ftplugin/svelte.vim like https://github.com/leafOfTree/vim-svelte-plugin/blob/2de4e9f55d061e3296917e3621e022542db74faa/ftplugin/svelte.vim#L8

if exists("loaded_matchit")
  let b:match_ignorecase = 1
  let b:match_words = '<:>,' .
        \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
        \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
        \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>,' .
        \ '{#\(if\|each\)[^}]*}:{\:else[^}]*}:{\/\(if\|each\)},' .
        \ '{#await[^}]*}:{\:then[^}]*}:{\/await},'
endif

leafOfTree avatar Oct 14 '24 03:10 leafOfTree