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

quickfix theme not applied until list is opened again or an item is added #3

Open
fent opened this issue May 27, 2023 · 8 comments
Open

Comments

@fent
Copy link

fent commented May 27, 2023

Hi, nice plugin!

When I first open the quickfix window after populating it with some items, the styling and the column alignments aren't there. But after I close it and re-open it, or if I add an item to the list, the style and lining up gets applied.

I'm using telescope's live grep to add items to quickfix btw.

This is my config using lazy.nvim

  {
    "arsham/listish.nvim",
    dependencies = {
      "arsham/arshlib.nvim",
    },
    ft = "qf",
    config = true,
    keys = {
      { "<leader>qq", desc = "Add current position to quicklist" },
      { "<leader>qn", desc = "Add current position with note to quicklist" },
      { "<leader>qo", desc = "Open quicklist" },
      { "<leader>ww", desc = "Add current position to location list" },
      { "<leader>wn", desc = "Add current position with note to location list" },
      { "<leader>wo", desc = "Open location list" },
      { "<leader>qd", desc = "Clear quicklist" },
      { "<leader>qc", desc = "Close quicklist" },
      { "<leader>wd", desc = "Clear location list" },
      { "<leader>wc", desc = "Close location list" },
      { "<leader>cc", desc = "Close both quicklist and location list" },
    },
  },
@arsham
Copy link
Owner

arsham commented May 28, 2023

Hi, thanks!

I'm afraid I can't replicate this behaviour. I haven't setup telescope on my setup, however I can look into the problem if you provide a minimal config that would produce this bug.

@fent
Copy link
Author

fent commented Jul 19, 2023

to reproduce

  • save the following as repro.lua
-- 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",
  -- add any other plugins here
  {
    "arsham/listish.nvim",
    dependencies = {
      "arsham/arshlib.nvim",
      -- "nvim-treesitter/nvim-treesitter-textobjects",
    },
    ft = "qf",
    opts = true,
  },
  {
    "nvim-telescope/telescope.nvim",
    dependencies = { "nvim-lua/plenary.nvim" },
    keys = {
      { "<C-p>", "<cmd>lua require('telescope.builtin').live_grep()<cr>" },
    },
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
  • run nvim -u repro.lua
  • press <ctrl-p> to open telescope search
  • type something that shows some results
  • press <ctrl-q> to add results to qflist
  • see that the qflist is not styled

this only happens when the qflist is lazy loaded with ft = "qf" in its lazy.nvim spec. if that's removed, then the qflist is styled on first load

sorry it took a while to reply >_<

@arsham
Copy link
Owner

arsham commented Aug 16, 2023

Thank you for the code. I'm not sure what is happening with this setup, but I managed to make this work.

-- Instead of opts = true add the config
-- opts = true,
ft = "qf",
config = function(_, opts)
  require("listish").config(opts)
  vim.fn.setqflist(vim.fn.getqflist())
end,

@fent
Copy link
Author

fent commented Aug 22, 2023

ah strange. maybe it's not called in the config?

@arsham
Copy link
Owner

arsham commented Aug 22, 2023

It is not supposed to be called in the config. The snippet above is just a hack, to repopulate the list only once when the plugin is lazy loaded.

@fent
Copy link
Author

fent commented Aug 23, 2023

how about, in the config, if the qflist is open, then repopulate the list?

@arsham
Copy link
Owner

arsham commented Aug 23, 2023

I'm not sure if I'm following. Can you elaborate please?

@fent
Copy link
Author

fent commented Aug 23, 2023

the snippet above is a fix for when the plugin is lazy loaded when the qf first opens. if that happens, the fix could be placed inside of the plugin, when it loads. since it's only needed if the plugin is lazy loaded, one way to check this is if the qflist is open when the plugin loads, assume it was lazy loaded, and apply the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants