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

Opening files from alpha and ignoring quickfix seems to cause issues #76

Closed
Irubataru opened this issue Aug 1, 2022 · 11 comments · May be fixed by #171
Closed

Opening files from alpha and ignoring quickfix seems to cause issues #76

Irubataru opened this issue Aug 1, 2022 · 11 comments · May be fixed by #171
Labels
bug Something isn't working

Comments

@Irubataru
Copy link

Irubataru commented Aug 1, 2022

I am having an issue combining alpha, diffview.nvim, and cokeline and I am trying to figure out what the problem is and I think I might have gotten to the bottom of how it goes wrong (but not why). Specifically this minimal configuration gives an error in combination:

return packer.startup(function(use)
  use({
    'noib3/nvim-cokeline',
    requires = 'kyazdani42/nvim-web-devicons',
    config = function()
      require('cokeline').setup({
        show_if_buffers_are_at_least = 2,
        buffers = {
          filter_valid = function(buffer)
            return buffer.type ~= "quickfix"
          end,
        new_buffers_position = 'next',
      }})
    end
  })

  use {
    'goolord/alpha-nvim',
    config = function ()
        require'alpha'.setup(require'alpha.themes.dashboard'.config)
    end
  }

  use({
    "sindrets/diffview.nvim",
    requires = "nvim-lua/plenary.nvim",
  })
end)

If I take this config, opens a git repo, runst :DiffviewOpen and then navigate to a new item to open (or just open anything with e.g. :e) I get the following error message from cokeline

E5108: Error executing lua ...pack/packer/start/nvim-cokeline/lua/cokeline/buffers.lua:269: attempt to compare nil with number
stack traceback:
        ...pack/packer/start/nvim-cokeline/lua/cokeline/buffers.lua:269: in function <...pack/packer/start/nvim-cokeline/lua/cokeline/buffers.lua:254>
        [C]: in function 'sort'
        ...pack/packer/start/nvim-cokeline/lua/cokeline/buffers.lua:316: in function 'get_valid_buffers'
        ...pack/packer/start/nvim-cokeline/lua/cokeline/buffers.lua:333: in function 'get_visible'
        ...te/pack/packer/start/nvim-cokeline/lua/cokeline/init.lua:54: in function <...te/pack/packer/start/nvim-cokeline/lua/cokeline/init.lua:53>

I can see it's a fairly convoluted example, but I don't see any part of this I'd want to remove from my workflow. It doesn't appear if I show quickfix buffers in cokeline, and it doesn't appear if cokeline is shown with only 1 buffer. If I do this with alpha cokeline doesn't appear after running :DiffviewOpen, but if I do this without alpha it doesn't appear because cokeline opens. I thought maybe I could reproduce it by setting show_if_buffers_are_at_least = 3, but that does not give the error. I was also able to get the error by opening a file with telescope from alpha, but I didn't make an MWE from that.

@willothy willothy added this to the Release: 0.4.0 milestone Jun 29, 2023
@willothy willothy added the bug Something isn't working label Jul 1, 2023
@willothy
Copy link
Owner

willothy commented Jul 1, 2023

Can't repro with a minimal config. Is this still an issue?

@willothy willothy removed this from the Release: 0.4.0 milestone Jul 2, 2023
@Irubataru
Copy link
Author

Yes, it is still an issue. Weird you can't reproduce it with the minimal config, cause I still can.

Here is a recording of the issue: https://asciinema.org/a/hlWi62JWLLyEYih6psKhgim97

My neovim version is NVIM v0.10.0-dev-591+g42f9573e5d

@willothy
Copy link
Owner

willothy commented Jul 3, 2023

If you're using this minimal config, you're still using the old version owned by @ noib3 which may not be updated. The bug still occurs there, but can't repro on the main branch here.

Make sure you're using willothy/nvim-cokeline. If it's still occurring on v0.4.0, feel free to reopen this.

@willothy willothy closed this as completed Jul 3, 2023
@Irubataru
Copy link
Author

I didn't realize the repo owneship had moved. I think the old points to the new, but I changed it to willothy/nvim-cokeline and I get the same behaviour. I tested a bit more and it seems to be the new_buffers_position = "next", config that fails, if I set it to last then it works fine. So I'll just do that :)

This is the new (full) minimal init.lua I use to test by the way.

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  -- bootstrap lazy.nvim
  -- stylua: ignore
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)

require("lazy").setup({
  {
    "willothy/nvim-cokeline",
    config = function()
      require("cokeline").setup({
        show_if_buffers_are_at_least = 2,
        buffers = {
          new_buffers_position = "next",
        },
      })
    end,
  },
  {
    "goolord/alpha-nvim",
    config = function()
      require("alpha").setup(require("alpha.themes.dashboard").config)
    end,
  },
  {
    "sindrets/diffview.nvim",
    dependencies = { "nvim-lua/plenary.nvim" },
  },
})

@willothy
Copy link
Owner

willothy commented Jul 4, 2023

Hmm, that's odd, my bad! I'll leave this open and do some more testing as soon as I can.

@willothy willothy reopened this Jul 4, 2023
@willothy
Copy link
Owner

Are you still able to repro this? I've just tried the minimal init again and still haven't been able to.

@Irubataru
Copy link
Author

Hmmm, I am still able to. I really wonder what I am doing different. To run a minimal setup I put them in a separate folder and run neovim with the following script

#!/bin/env bash

XDG_CONFIG_HOME="$HOME/Tests/neovim/cokeline/config" \
XDG_DATA_HOME="$HOME/Tests/neovim/cokeline/data" \
nvim "$@"

I empty data between tests, and config only contains the init.lua file above.

And it seems to me to run a minimal config. I then (similar to the screencast)

  1. Navigate to a git repo with some changes
  2. Run the above neovim script
  3. Call :DiffviewOpen
  4. Select the next element in the list

But I have found a workaround, so I am happy to close this, it's just if the error is symptomatic for something else.

@willothy
Copy link
Owner

Oh, I got it! Thanks, I must've not been following the same steps before. I'll try to get this fixed sometime this week.

@willothy
Copy link
Owner

Should be fixed :)

@Irubataru
Copy link
Author

It works! Thank you :)

@willothy
Copy link
Owner

Awesome!

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.

2 participants