Commit Graph
18 Commits
Author SHA1 Message Date
Martin YzeiriandAlex Pláte dd490967d3 Add Matchit PHP patterns 2023-06-12 10:39:45 +03:00
Martin YzeiriandAlex Pláte 391202877a Extract tagNamePattern to an argument
Providing a custom tagNamePattern makes it easier to interop with
languages like PHP.
2023-06-12 10:39:45 +03:00
Martin YzeiriandAlex Pláte c48acd8fb7 Simplify JavaScript PSI checks
The less than/greater than operators are the only binary expressions in
the JS patterns, so the extra PSI checks are redundant.
2023-06-12 10:39:45 +03:00
Martin YzeiriandAlex Pláte c8428258fe Switch to linkedMapOf
mapOf happens to give us LinkedHashMaps, but we'll use the explicit
constructor since insertion order matters for PatternsTables.
2023-06-12 10:39:45 +03:00
Martin YzeiriandAlex Pláte bcf10a0b8e Matchit: Ignore JS comparison operators
In files that mix HTML and JavaScript, arrow functions or forms like (x > y)
conflict with the brackets on HTML tags. We can ignore those JS elements
using PSI checks like we do for some Ruby keywords.
2023-04-26 11:14:06 +03:00
Martin YzeiriandAlex Pláte 546137c0f5 Matchit: Correct HTML regex
A final closing > is required on the search pair, otherwise tags with a
shared prefix in their names will conflict.
2023-04-26 11:14:06 +03:00
Martin YzeiriandAlex Pláte 92bc691e1f Matchit: Improve comment handling
Since the cursor can come before the start of the matching pair, we need
to check the PSI element at the first match offset, not the caret offset,
when deciding if we need to skip comments.

This fix makes the special isHtmlAttribute check unnecessary. If the caret
is in an HTML attribute, the first match offset will point to the start
of the tag.
2023-04-26 11:14:06 +03:00
Martin YzeiriandAlex Pláte d834d0fdd9 Move a unit test 2023-04-26 11:14:06 +03:00
Martin YzeiriandAlex Pláte bb67584cba Matchit: Add more Rider file types 2023-01-04 08:56:41 +02:00
Martin YzeiriandAlex Pláte 28ba36dddb Matchit: Support cshtml files
Enables HTML jumps in Razor (.cshtml) templates.
2022-12-29 07:51:59 +02:00
Martin YzeiriandAlex Pláte 8ab3664992 Matchit: Add CMake Patterns 2022-04-07 11:55:31 +03:00
Martin YzeiriandAlex Pláte 03e6101747 Matchit: Add GNU Make Patterns 2022-04-07 11:55:31 +03:00
Martin YzeiriandAlex Pláte 9f47995c10 Matchit: Add C patterns 2022-04-07 11:55:31 +03:00
Martin YzeiriandAlex Pláte d58f36ea1a Matchit: Enhance pattern creation
The new LanguagePatterns class lets us easily configure the patterns for
a language in a similar way to the original plugin. Most language
features can be configured by passing strings to the alternate
constructor. And the overloaded + operator makes combining patterns easy.

findMatchingPair() was refactored to work with the new class.

In addition, the concept of prefixes was removed. The cursor should jump
if it's anywhere inside or before an extended pair (excluding the
default pairs). Instead of appending a prefix to each regex, we simply
check in findMatchingPair() what the closest pair to the cursor is. The
original plugin behaves the same way.

We prefer matches containing the cursor over matches after the cursor.
If the cursor in inside multiple patterns, we pick the smaller one. And
a default pair after the cursor is preferred over any extended pairs
after the cursor.
2022-04-07 11:55:31 +03:00
Martin YzeiriandAlex Pláte 442970a986 Matchit: Refactor parsePatternAtOffset()
The ending offset of the initial match isn't enough information for some
language features. For example, if the cursor is on "i" in the "else if"
of a Makefile, the previous implementation would jump to the "else" on a
reverse jump instead of treating "else if" as a single structure.

parsePatternAtOffset() needs to return both the match start and end for
us to correctly handle such a distinction.
2022-04-07 11:55:31 +03:00
Martin YzeiriandAlex Pláte fcc6c8a3c5 Matchit: Simplify findClosingPair() and findOpeningPair()
findClosingPair() always moves forward and findOpeningPair() always
moves backwards. That fact lets us simplify both implementations.

Using a stack of Pairs to track the match starts and ends is unnecessary 
since we know ahead of time whether the jump needs to go to the start or
end of the target pair.

findOpeningPair() can be further simplified since it doesn't need to
check the isInOpPending flag -- the distinction between operator pending
mode and regular jumps only matters when moving forward in the buffer.
2022-04-07 11:55:31 +03:00
Martin YzeiriandAlex Pláte 1dbd4b4391 Matchit: Use setOf for sets 2022-04-07 11:55:31 +03:00
Martin YzeiriandAlex Pláte c524c92062 Emulate matchit.vim 2021-10-07 10:21:19 +03:00