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

[Feature Request] Automatically detect installed themes #21

Open
baroldgene opened this issue Aug 18, 2024 · 7 comments
Open

[Feature Request] Automatically detect installed themes #21

baroldgene opened this issue Aug 18, 2024 · 7 comments

Comments

@baroldgene
Copy link

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.

@Razkaroth
Copy link

Razkaroth commented Aug 22, 2024

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).

@zaldih
Copy link
Owner

zaldih commented Aug 22, 2024

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.

@Razkaroth
Copy link

@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

@Razkaroth
Copy link

@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?

@zaldih
Copy link
Owner

zaldih commented Aug 25, 2024

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 :)

@baroldgene
Copy link
Author

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.

@Razkaroth
Copy link

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

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

3 participants