DEV Community

Eduardo Aranda Hernández
Eduardo Aranda Hernández

Posted on

Vim to neovim migration helper

When migrating your config, it's super boring to check:

  • if values are already defaults
  • is it vim.opt or vim.g ?

So I made this script

local opts = {
    ai = true, -- Auto indent
    autoindent = true, -- Auto indent
    autoread = true, -- Detect changes
        ..... your options here .....   
}

local function checkopts()
    print("Options you can discard because they're default:")
    for k, v in pairs(opts) do
        if vim.opt[k]:get() == v then
            print(k, v)
        end
    end
end
checkopts()
Enter fullscreen mode Exit fullscreen mode

just paste your options and :source % the file

Want to make options permanent?

this would be the same as doing vim.opt.youroption = yourvalue on each value

-- set options
for k, v in pairs(opts) do  
    vim.opt[k] = v
end
Enter fullscreen mode Exit fullscreen mode

Full example:

This also includes globals like colorscheme

Top comments (0)