I want to know if I can use the popup option for my completeopt in the running version of vim/neovim. The example is just for clarity, I'm looking for a solution that is generic.

I know I can check exists("&completeopt"), or check if a value already is set within it (&completeopt ~=# 'popup').

What I don't know is how to check for valid values within an option like completeopt, guioptions, etc. if that option is not already set with that value.

I can't find any answer or help under :h exists, or any of the other vi.stackexchange or stackoverflow answers using search terms "check valid values for option". I have read the suggestions on this webpage about graceful option degrading

I'm aware I could use a try ... catch block, but would rather avoid that extra code and incompatibility with vim < 7 (for the purposes of completeness)

For this specific example, I could use v:version > 802, but I'm interested in an approach targeted to a specific feature, so that I can re-use it for other options and so that it works for neovim.

Edit: Reading the online docs for version 8.2, I see it specifies the compile-requirement of textprop, so I assume I could do has('textprop'). However, I would still very much like to know if there is a more generic way to do it, to make doing the same for other options easier and more robust (in case of incorrect/missing documentation, or compile-invariant options)

Edit 2: textprop is present in versions prior to those that introduced popup, so doesn't work.

  • 2
    I am not aware of a generic feature check for valid option values. Best would probably to check the version/patch that introduced this feature. – Christian Brabandt May 14 at 5:40
  • Thank you, coming from you I'm sure I won't get any better answer. Do you know of a way to easily find the patch that introduced a specific feature? – BlueDrink9 May 15 at 0:21
  • 3
    git log --grep completeopt shows this has been added at vim 8.1.1880 – Christian Brabandt May 15 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.