Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Disabling default options does not work #566

Closed
3 tasks done
Ram-Z opened this issue Apr 11, 2023 · 4 comments · Fixed by #588
Closed
3 tasks done

bug: Disabling default options does not work #566

Ram-Z opened this issue Apr 11, 2023 · 4 comments · Fixed by #588
Labels
bug Something isn't working

Comments

@Ram-Z
Copy link

Ram-Z commented Apr 11, 2023

Did you check docs and existing issues?

  • I have read all the LazyVim docs
  • I have searched the existing issues of LazyVim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.9.0-dev-920+gc9b0fe1f41

Operating system/version

Arch Linux

Describe the bug

Trying to disable the default options following the docs does not work. They are still loaded.

Loading the options seems to happen within init, whereas merging opts happens in setup after the default options.lua has already been loaded. lazyvim.config.init is called from plugins/core.lua.

Disabling autocmds and keymaps the same way works. Modifying defaults.options in lua/lazyvim/config/init.lua works as expected.

Steps To Reproduce

  1. Disable options using this plugin in lua/plugins/disable-options.lua
    return {
      {
        "LazyVim/LazyVim",
        opts = {
          defaults = {
            autocmds = false,  -- works
            options = false,  -- does not work
            keymaps = false,  -- works
          },
        },
      },
    }
  2. run nvim -V1 --headless -c "verbose set splitbelow? | q"
      splitbelow
    	Last set from ~/.local/share/nvim/lazy/LazyVim/lua/lazyvim/config/options.lua line 38%
    

Expected Behavior

When setting defaults.options = false, the default options should not be loaded.

Repro

Run with nvim -u repro.lua --headless -V1 -c "verbose set splitbelow? | q", first run is a bit verbose, but will end printing that splitbelow was set and where. Second run only prints the setting.

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "LazyVim/LazyVim",
    -- import lazyvim.plugins.core.lua which calls lazyvim.config.init
    import = "lazyvim.plugins",
    -- setting default to false is ignored
    opts = {
      defaults = {
        options = false,
      },
    },
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
@Ram-Z Ram-Z added the bug Something isn't working label Apr 11, 2023
@folke folke closed this as completed in 02c5e8d Apr 16, 2023
@folke
Copy link
Collaborator

folke commented Apr 16, 2023

You're right. Its not possible to disable options this way. I've updated the docs and added a work-around: https://www.lazyvim.org/configuration#default-settings

@dpetka2001
Copy link
Contributor

dpetka2001 commented Apr 16, 2023

@folke You're mentioning that to disable default options we should add package.loaded["lazyvim.config.options"] = true to our init.lua. Do you maybe mean to set it to false? Or am I misunderstanding the use of package.loaded()?

@folke
Copy link
Collaborator

folke commented Apr 16, 2023

setting it to anything that isn't nil will work

@Ram-Z
Copy link
Author

Ram-Z commented Apr 18, 2023

Thanks for the workaround, works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants