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: config = true not working on steelsojka/pears.nvim #208

Closed
3 tasks done
ricbermo opened this issue Dec 28, 2022 · 9 comments · Fixed by #197
Closed
3 tasks done

bug: config = true not working on steelsojka/pears.nvim #208

ricbermo opened this issue Dec 28, 2022 · 9 comments · Fixed by #197
Labels
bug Something isn't working

Comments

@ricbermo
Copy link

Did you check docs and existing issues?

  • I have read all the lazy docs
  • I have searched the existing issues of lazy
  • I have searched the exsiting issues of the plugin I have a problem with

Neovim version (nvim -v)

0.8.0

Operating system/version

13.0.1

Describe the bug

image

just like the title says, config = true not working on steelsojka/pears.nvim

image

but using config = function() require("pears").setup() end is.

More details:
Uploading image.png…

Steps To Reproduce

Just change the config property from config = function() require("pears").setup() end to config = true

Expected Behavior

config = true should work just like like the rest. I have Comments and surround working just fine.
image

Repro

-- 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",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
  {
    "steelsojka/pears.nvim",
    event = "InsertEnter",
    config = true,
  },

}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@ricbermo ricbermo added the bug Something isn't working label Dec 28, 2022
@ricbermo
Copy link
Author

ricbermo commented Dec 28, 2022

The issue may be here. pairsaccepts a callback as the argument where most of the other plugins accept a table?

require "pears".setup(function(conf)
  conf.pair("{", "}")
  conf.expand_on_enter(false)
end)

@max397574
Copy link
Contributor

yes
afaik config=true calls the setup function with an empty table
so ig you should just use the long form of the configuration for this plugin

@ricbermo
Copy link
Author

yeah. IDK if I should leave the issue open. I mean, maybe, the configproperty can be tweaked to pass down whatever is set. ATM, it accepts a boolean or a table. I may be wrong, tho.

@folke
Copy link
Owner

folke commented Dec 28, 2022

as @max397574 said, you can use config() as a function, but I will change it so true means nil, which is probably better

@ryuheechul
Copy link

Would changing it to nil rather than {} cause other setup functions expecting a table (most of lua first plugins) to not work well? Or could this be a false assumption?

@folke
Copy link
Owner

folke commented Dec 28, 2022

Most plugins work with an optional opts table. So this can be nil.
If you have a plugin that doesn't you can still do config = {}

@ryuheechul
Copy link

Just confirmed this works very well 👍🏼

Most plugins work with an optional opts table. So this can be nil. If you have a plugin that doesn't you can still do config = {}

After updating lazy.nvim, m4xshen/autoclose.nvim started emitting error and fixed it by this change.

- config = true,
+ config = {},

@max397574
Copy link
Contributor

you could just get an error when some plugins don't have a opts = opts or {} line or sth similar
but most plugins should have that

@folke
Copy link
Owner

folke commented Jan 8, 2023

Just a heads up, options that are passed to a plugin setup are now always a table, so to make pears work, you need to use a config() function instead

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.

4 participants