Skip to content

chore: replace deprecated vim.validate({}) form#7

Merged
dimtion merged 1 commit into
dimtion:mainfrom
MarkSverdlov:fix-vim-validate
Apr 25, 2026
Merged

chore: replace deprecated vim.validate({}) form#7
dimtion merged 1 commit into
dimtion:mainfrom
MarkSverdlov:fix-vim-validate

Conversation

@MarkSverdlov
Copy link
Copy Markdown
Contributor

Hello,
:checkhealth raises warning due to the old form of vim.validate. See https://neovim.io/doc/user/lua/#vim.validate() for details.
I changed the form to the recommended one.
Seems to work fine.

@dimtion
Copy link
Copy Markdown
Owner

dimtion commented Apr 19, 2026

Thank you for the PR!

I ran the test suite against it, it looks like older versions of nvim are expecting the older validation syntax. Could you maybe create a polyfill (a local function) that would either call the new syntax or the old syntax based on the version of nvim?

I gave you more rights to run the tests you should be able to trigger them upon PR updates.

@dimtion dimtion added the enhancement New feature or request label Apr 19, 2026
@MarkSverdlov MarkSverdlov force-pushed the fix-vim-validate branch 3 times, most recently from 9e08b45 to 30ad3c4 Compare April 20, 2026 08:22
@MarkSverdlov
Copy link
Copy Markdown
Contributor Author

Hi, I added a polyfill function that checks the version using the vim.fn.has("nvim-0.11") api and it passes the test. I don't know lua well, and I'd like your advice if perhaps something like:

-- Validate arguments using a compatibility wrapper for vim.validate.
-- Falls back to the legacy signature on older Neovim versions.
if vim.fn.has("nvim-0.11") == 1 then
  validate = function(name, value, validator, optional, message)
    return vim.validate(name, value, validator, optional, message)
  end
else
  validate = function(name, value, validator, optional, message)
    return vim.validate({ [name] = { value, validator, optional, message } })
  end
end

Would be better as the plugin will check version only once (supposedly) instead on every call?

@dimtion
Copy link
Copy Markdown
Owner

dimtion commented Apr 22, 2026

It would be better, however, since the validate function is called only a handful of time, and is not on the plugin hot path, the difference is probably imperceptible.

If you want to do that improvement go ahead! Else I'm ok to merge that PR as is.

@MarkSverdlov MarkSverdlov force-pushed the fix-vim-validate branch 3 times, most recently from 50ee449 to a85eff4 Compare April 22, 2026 05:49
@MarkSverdlov
Copy link
Copy Markdown
Contributor Author

done

The table form of vim.validate is deprecated since Neovim 0.11
and will be removed in 1.0
We add a polyfill to ensure backward compatibility with Neovim versions prior to 0.11.
@dimtion dimtion merged commit b4775ba into dimtion:main Apr 25, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants