lazy-loadingneovimcolor-scheme

What is the proper way to enable a built-in colorscheme using the lazy plugin manager in neovim?


I'm trying to get more familiar with the lazy plugin manual and going through lazy's README. I have a very basic init.lua config that I'm using:

vim.cmd('colorscheme desert')
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
        "folke/which-key.nvim",
}, {})

Note I used vim.cmd to load the "desert" colorscheme. But this doesn't feel like the proper way to load a built-in color scheme. The README says:

Colorscheme plugins can be configured with lazy=true. The plugin will automagically load when doing `colorscheme foobar`.

But this is pretty cryptic and does not make it clear to me how what the recommended method is for enabling a built-in color theme is.


Solution

  • This is the proper way of doing things. Lazy is a package manager therefore only responsible for loading packages it downloads.

    If you want to set some vim settings unrelated to packages lazy is responsible for initiating then you can simply do what you do.