2

Here's an excerpt from a file where aoe(file) should be treated like an import:

  ["Cyclone" 37 {"Move +0" "Attack +0, aoe(aoes/tri-melee.rkt)" "Consume Air: Instead, Attack +1, aoe(aoes/ring1-melee.rkt)"}]

I have an include setting to find "aoe" files (and other files) that works:

let &l:include = '\v(import-monsters "\zs[^"]*\ze"|aoe\(\zs[^)]*\ze\))'

However, it only finds the first file on the line (:checkpath! includes aoes/tri-melee.rkt but not aoes/ring1-melee.rkt). If I split the line between the two aoe() bits, both are found.


  1. Is this the usual function of include? It's not documented as only processing the first match in a line, as far as I can tell, though :help include-search strongly hints that this is the case.
  2. Is there a way to check for includes more than once on a line? I could imagine using a more permissive pattern like aoes(.*) and then using includeexpr to extract multiple matches, but I don't think includeexpr is supposed to return a list (nor can I find documentation for what happens if it does).

1 Answer 1

2

Is this the usual function of include?

Yes, the search for includes a) is done in one pass only, and b) only searches for one filename on each line.

Is there a way to check for includes more than once on a line?

AFAIK no.

FWIW, it is not even possible to have both a define and an include match on the same line.

but I don't think includeexpr is supposed to return a list (nor can I find documentation for what happens if it does).

The job of includeexpr is to extrapolate a more usable filename from the filename found by include.


Reference: https://github.com/vim/vim/blob/master/src/search.c#L3325, https://github.com/vim/vim/blob/master/src/findfile.c#L1888, and too much time wasted battling this.

3
  • Sad, but thanks. "Too much time": I guess I can search, but it sounds like you might have had some discussions with Bram or vim-dev about tweaking these options to catch all matches on a line?
    – D. Ben Knoble
    Commented Jul 7, 2023 at 14:46
  • Some denial-heavy discussions, but mostly informal and a lot of trial and error. ATM neither include nor define can be tweaked to match several times or together on the same line. I didn't go as far as sending a patch, though, because I can barely read C. Maybe you will have more luck.
    – romainl
    Commented Jul 7, 2023 at 15:22
  • Got it, thanks.
    – D. Ben Knoble
    Commented Jul 7, 2023 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.