Commit Graph
9 Commits
Author SHA1 Message Date
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