listish.nvim icon indicating copy to clipboard operation
listish.nvim copied to clipboard

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

Open fent opened this issue 2 years ago • 8 comments

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" },
    },
  },

fent avatar May 27 '23 21:05 fent

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.

arsham avatar May 28 '23 11:05 arsham

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 >_<

fent avatar Jul 19 '23 08:07 fent

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,

arsham avatar Aug 16 '23 19:08 arsham

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

fent avatar Aug 22 '23 04:08 fent

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.

arsham avatar Aug 22 '23 21:08 arsham

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

fent avatar Aug 23 '23 06:08 fent

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

arsham avatar Aug 23 '23 06:08 arsham

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

fent avatar Aug 23 '23 06:08 fent