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

Setting a global option used by a plugin doesn't seem to work #107

Closed
farzadmf opened this issue Dec 22, 2022 · 14 comments · Fixed by #96
Closed

Setting a global option used by a plugin doesn't seem to work #107

farzadmf opened this issue Dec 22, 2022 · 14 comments · Fixed by #96
Labels
bug Something isn't working

Comments

@farzadmf
Copy link

Describe the bug
I'm using the vim-ctrlspace, and it requires setting a global option for its mapping

I'm doing something like this (the file is in my plugins folder):

return {
  'vim-ctrlspace/vim-ctrlspace',
  url = 'https://github.com/vim-ctrlspace/vim-ctrlspace',
  config = function()
    vim.g.CtrlSpaceDefaultMappingKey = '<C-space> '
  end,
}

What should happen after this is: when I press <C-space>, the vim-ctrlspace "menu" should appear, but it doesn't seem to work, and pressing <C-space> doesn't do anything.

It's worth noting that doing the exact same setup with Packer seems to be fine (the only difference being that I would require the files in the plugins folder manually)

Which version of Neovim are you using?
0.8.1

To Reproduce

  1. Set up lazy.nvim according to the README (require('lazy').setup('plugins'))
  2. Create the lua/plugins/my-plugin.lua file with the content I mentioned above
  3. Open neovim, you see the plugin being installed
  4. Close and re-open neovim
  5. Press <C-Space>, and nothing happens

Expected Behavior
Similar to Packer, I expect the setup to work with Lazy as well.

@farzadmf farzadmf added the bug Something isn't working label Dec 22, 2022
@folke
Copy link
Owner

folke commented Dec 22, 2022

Is this an option that needs to be set before loading the plugin?

@max397574
Copy link
Contributor

since the commit with which the issue was closed you should be able to put it into the init function and it should work

@folke
Copy link
Owner

folke commented Dec 22, 2022

right, wanted to mention that :)

But yes, that's the solution!

@farzadmf
Copy link
Author

Sorry for the late reply

you should be able to put it into the init function and it should work

I'm doing this, but still pressing <C-space> doesn't work

return {
  'vim-ctrlspace/vim-ctrlspace',
  url = 'https://github.com/vim-ctrlspace/vim-ctrlspace',
  init = function()
    vim.g.CtrlSpaceDefaultMappingKey = '<C-space> '
  end,
}

@craigmac
Copy link
Contributor

Try vim.g.CtrlSpaceDefaultMappingKey = '<C-space>' ? You have an extra space at the end there, either that or you need to translate the space into a termcode

@farzadmf
Copy link
Author

@craigmac , this is actually what they mention in their docs

Note the trailing space at the end of the mapping. Neovim doesn't mind it, but it makes vim-ctrlspace's "is the mapping left at default" check fail so it won't change the mapping to .

And I'm wondering why it works with packer but not with lazy

@folke
Copy link
Owner

folke commented Dec 22, 2022

There's nothing I'm doing with that. Did you update lazy? Since I did fix loading order to make sure init() runs before loading a plugin. Without that it would not work.

@farzadmf
Copy link
Author

I did I think, I did :Lazy update, and even I did try "resetting" things (removing the whole stdpath('data') directory, and I see lazy being on the latest commit, but not sure what's wrong :(

@farzadmf
Copy link
Author

One other difference I see with packer (not sure if it's important or not) is that cloning vim-ctrlspace takes much longer with packer than lazy. Or, maybe it's not just the cloning, but basically when I do PackerSync, it takes forever for vim-ctrlspace to reach 100%, but with lazy, it's much faster.

As I said, not sure if it matters or not, just mentioning the differences

@folke
Copy link
Owner

folke commented Dec 22, 2022

I'm using partial clones instead of shallow clones. That might make a difference.

@farzadmf
Copy link
Author

@folke , I just noticed something; when I do :Lazy show, it shows vim-ctrlspace as Installed (and not Loaded)

If I do Lazy load vim-ctrlspace, things are fine. Any way I can tell Lazy to actually load that guy?

@max397574
Copy link
Contributor

lazy=false in config

@folke
Copy link
Owner

folke commented Dec 22, 2022

right! It's because of the init. I should probably change that. init implies lazy-loading, but probably should not if it does not have a config() as well

Add lazy=false for now

@folke
Copy link
Owner

folke commented Dec 22, 2022

I'll change it so init no longer impies lazy-loading. For vim plugins this doesn't make sense

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