3

vim-apathy advertises the many possibilities of :h include-search.

However, if the programming language under consideration (here GAP), does not have include expressions but the interpreter always loads a standard library from a library path and other packages with other means, are these languages excluded from this functionality?

Is it possible to explicitly add files, e.g. in an ftplugin, to the include search, so they are searched when one presses [i?

I was looking for something like

setlocal includedefaults+=$LIB/*.gd,$LIB/*.gi

or a vim function which can customize the include file list.

A plugin or NeoVim only solution would be good enough as well.

1 Answer 1

1

Include search is done in the current and included files.

If your language doesn't let you explicitly include a file, then all Vim can do is search in the current file, which makes using include search rather pointless. That feature is simply not fit for your specific use case.

If you know where those packages are stored, then you might have more luck with :help tags and something like Universal Ctags, if it supports your language.


Now, the documentation mentions LoadPackage(), which can be considered like an "include":

" very raw, adjust to taste
setlocal include=LoadPackage

This might work if you set :help 'path' and :help 'includeexpr' properly, to a list of default directories for the former, and to a function that returns a searchable path for the latter.

5
  • Thanks for your answer. 1) I agree that without includes include-searches are more or less pointless. That is the reason for my question. 2) I am already using ctags as described here and is helpful. I was wondering whether I could use the other mappings of include-search as well. 3) When writing a GAP package, you define required packages in a PackageInfo.g at the root of the project not in each file.
    – Hotschke
    Commented Dec 20, 2023 at 10:13
  • I think you can forget all about include-search for that language.
    – romainl
    Commented Dec 20, 2023 at 10:15
  • I will go with “forget about include-search for GAP”. IMHO, vim include mechanism could be extended to support also those languages. On a fresh system, there is no ctags and has to be configured similar to LSPs (does not exist for GAP either) and low-tech solutions can still help you to get around.
    – Hotschke
    Commented Dec 20, 2023 at 10:32
  • No include mechanism == no include search. But one could probably advocate a simpler "path search", I guess.
    – romainl
    Commented Dec 20, 2023 at 14:20
  • I read the doc more carefully. We can fake the include by using the 'include' option but it will only provide one entry per match and you need as many as you have file to search in you standard library. It doesn't seems a fit to me anymore. Commented Dec 20, 2023 at 16:57

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.