Skip to content

[Deprecation]: "vim.validate is deprecated. Feature will be removed in Nvim 1.0" #16

@leviouwendijk

Description

@leviouwendijk

Context

visimatch.nvim is receiving a deprecation warning about the vim.validate function call.

:checkhealth vim.deprecated result:

- ⚠️ WARNING vim.validate is deprecated. Feature will be removed in Nvim 1.0
  - ADVICE:
    - use vim.validate(name, value, validator, optional_or_msg) instead.
    - stack traceback:
        /Users/leviouwendijk/.local/share/nvim/site/pack/packer/start/visimatch.nvim/lua/visimatch/init.lua:48
        /Users/leviouwendijk/.config/nvim/after/plugin/visimatch.lua:1

Which is in init.lua at line 46:

M.setup = function(opts)
    config = vim.tbl_extend("force", config, opts or {})
    vim.validate({
        hl_group          = { config.hl_group,          "string" },
        chars_lower_limit = { config.chars_lower_limit, "number" },
        lines_upper_limit = { config.lines_upper_limit, "number" },
        strict_spacing    = { config.strict_spacing,    "boolean" },
        buffers           = { config.buffers,           { "string", "function" } },
        case_insensitive  = { config.case_insensitive,  { "boolean", "table" } },
    })
end

Which should use a non-tabled version (example fix):

M.setup = function(opts)
    config = vim.tbl_extend("force", config, opts or {})
    vim.validate('hl_group', config.hl_group, 'string')
    vim.validate('chars_lower_limit', config.chars_lower_limit, 'number')
    vim.validate('lines_upper_limit', config.lines_upper_limit, 'number')
    vim.validate('strict_spacing', config.strict_spacing, 'boolean')
    vim.validate('buffers', config.buffers, function(x)
        return type(x) == 'string' or type(x) == 'function'
    end, 'string|function expected')
    vim.validate('case_insensitive',  config.case_insensitive, function(x)
        return type(x) == 'boolean' or type(x) == 'table'
    end, 'boolean|table expected')
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions