zaldih/themery.nvim

[Feature Request] Automatically detect installed themes

baroldgene opened this issue · 7 comments

This is a great plugin. One thing I find mildly annoying is that (unless I'm missing something) I have to define my themes in other files to install them, then list them again in Themery. While I appreciate the ability to customize what shows up in the picker, it would be convenient to have Themery automatically detect installed themes so that I only have to define them once.

Ideally this could allow some sort of filter to exclude some installed themes from the picker.

You can do this:

return {
  {
    "zaldih/themery.nvim",
    command = "Themery",
    config = function()
      local available_colorschemes = vim.fn.getcompletion("", "color")
      local colorschemes = {}
      for _, colorscheme in ipairs(available_colorschemes) do
        table.insert(colorschemes, colorscheme)
      end

      require("themery").setup({
        themes = colorschemes,
      })
    end,
    lazy = false,
    priority = 900,
  },
  {
    "bradcush/nvim-base16",
    name = "nvim-base16",
    lazy = false,
    priority = 1000,
  },
  {
    "catppuccin/nvim",
    name = "catppuccin",
    lazy = false,
    priority = 1000,
  },
  {
    "srcery-colors/srcery-vim",
    name = "srcery",
    lazy = false,
    priority = 1000,
  },
 -- More themes here
}

Note that the priority of Themery must be lower than that of the colorschemes (if using lazy idk what parameter to adjust in other plugin managers, but this is the general idea).

Thank you for your comment!

I understand and it's true that it can be frustrating when you have a lot of colorscheme. To be honest, I don't really know how to handle this, how to get the themes installed manually? There are ways to get them all, but these would also include the default ones (which are many and may be irrelevant).

Another future option that I think will be key to this is that I plan to incorporate an integrated theme manager to install and uninstall themes through. That way you could have a record of which ones are relevant, along with the default settings that each one needs.

In the meantime, the option proposed by @Razkaroth seems very clever!

pd: Come to think of it, you could keep a list of the default themes and subtract them from all the colourscheme you get and display them. I'll think about it.

@zaldih Yep, that would be an option, it could do what Lazy and Mason do: set a keymap to do something on the currently hovered theme. Like adding them to some lists like favorite or hidden themes, persist that list and do the subtraction thing you just mentioned.

Alternatively, if a function like the one I described on #24 is exposed, I could make a keymap snippet to (optionally) use telescope as a fuzzy picker. That would simplify the change process. That snippet can be added to the README.md

@zaldih I can get some work done on this one during the week.

I think a opts.loadInstalled to decide between running or not the snippet. Then merge that result with the user provided table. Then substract an opts.blacklist table with the names of unwanted themes.

What do you think?

It sounds like a very good idea. I like it!

However, I think you're going to have a difficult right now as the codebase needs a big refactor (I'm planning on it).

But if you still think you can deal with it and play, go ahead :)

For what it's worth I think that in order to filter the default themes you could just add a blacklist (as described) and have the value of it default to the system level themes. This way the user could edit that if they actually want those to show up for some reason but they'd be hidden by default.

Ok, then I'll wait for the refactor to work on this.