andymass / vim-matchup

vim match-up: even better % :facepunch: navigate and highlight matching words :facepunch: modern matchit and matchparen. Supports both vim and neovim + tree-sitter.
https://www.vim.org/scripts/script.php?script_id=5624
MIT License
1.69k stars 71 forks source link

Javascript/ES6: Tagged Template Literals support #58

Open thekaganugur opened 5 years ago

thekaganugur commented 5 years ago

`

should work the same way ( In the second line

// These are equivalent:
fn`some string here`
fn(['some string here'])

MDN Doc on Tagged Template Literal

andymass commented 5 years ago

Does the fn part matter at all? Are you suggesting that % should move between the two backticks?

thekaganugur commented 5 years ago

Yes

davidsierradz commented 5 years ago

Is this working? I have in my after/ftplugin/javascript.vim:

set matchpairs+=`:`
"set matchpairs? -> matchpairs=(:),{:},[:],<:>,`:`

inside a javascript file:

`foo`

`bar`

The first foo backtick doesnt work, the second foo backtick goes to the first foo backtick, the first bar backtick goes to the second foo backtick and the second bar backtick goes to the first bar backtick:

+---+
|   |
v   |
`foo`
    ^
    |
+---+
|
`bar`
^   |
|   |
+---+

Thanks

andymass commented 5 years ago

No, it's not currently supported. Unfortunately, it's difficult to accomplish, since there's no way to tell what is the start and what is the end. I think it would either need to rely on syntax highlighting, or count backticks on a single line.

Can tagged template literals span lines?

davidsierradz commented 5 years ago

Can tagged template literals span lines?

Yeah, all template literals, not only tagged ones.

I think if the implementation is difficult and/or performance is impacted, then this is not worth it (a nice to have at least)

ashnur commented 5 years ago

No, it's not currently supported. Unfortunately, it's difficult to accomplish, since there's no way to tell what is the start and what is the end.

Why? If the index of ` is even, it's the start, if it's odd it's the end. Only thing important is to not confuse ``` with `` or `