chrisbra / matchit

The matchit plugin from Vim
61 stars 9 forks source link

Supporting `syn-keepend` semantics #35

Closed ddickstein closed 1 year ago

ddickstein commented 1 year ago

OCaml's definition of b:match_words has a bug in the following scenario:

1 let x =
2   let module Foo = struct
3     let a = 0
4     let b = 1
5   end
6   in
7   Foo.a
8 ;;

The correct pairing here would be let on line 1 is paired with the ;; on line 8, the let on line 2 is paired with the in on line 6, and the struct on line 2 is paired with the end on line 5. Matchit incorrectly pairs the let on line 3 with the ;; on line 8 and the let on line 4 with the in on line 6. If it supported syn-keepend semantics, we would be able to say that let should not match across an unmatched end.

chrisbra commented 1 year ago

Unfortunately, there is no way to query the syn-keepend syntax properties, thus there is no way for matchit to guess the proper jump point.

ddickstein commented 1 year ago

Is this a limitation of searchpair?

chrisbra commented 1 year ago

not only searchpair() . There is no API to query information about what parts of a buffer belong to what syntax group, except for querying each column separately to what syntax item it belongs to.

ddickstein commented 1 year ago

Yeah, I don't think matchit should be leveraging syntax groups. What I mean is, is there some functionality that is missing in the API to have keepend-like pair navigation, and if not, should/could that be something that searchpair provided? What would the "necessary and sufficient" need to be here for this to work? I'd like to request it from Bram.