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

Create color slots for day and night #8

Open
podratz opened this issue Nov 2, 2023 · 5 comments
Open

Create color slots for day and night #8

podratz opened this issue Nov 2, 2023 · 5 comments

Comments

@podratz
Copy link

podratz commented Nov 2, 2023

I use f-person/auto-dark-mode.nvim plugin to automatically infer from the system's colorscheme.
I'd appreciate if raddari/last-color could remember two colorschemes separately in customisable slots.

@raddari
Copy link
Owner

raddari commented Nov 3, 2023

Hello, thank you for the suggestion!
I'm a little busy over the next few days, but I'll think about what you wrote over the weekend and get back to you Monday :)

@raddari
Copy link
Owner

raddari commented Nov 7, 2023

Based on your suggestion and from what I've read about the plugin, does something like this sound right to you?

local last_color = require('last-color')

return {
  "f-person/auto-dark-mode.nvim",
  config = {
    set_dark_mode = function()
      -- last-color will now write to `<cache_dir>/last-color.dark` for any subsequent `colorscheme` commands
      last_color.context('dark')
      -- last-color will now read from `<cache_dir>/last-color.dark`
      vim.cmd.colorscheme(last_color.recall())
    end,
    set_light_mode = function()
      -- last-color will now write to `<cache_dir>/last-color.light` for any subsequent `colorscheme` commands
      last_color.context('light')
      -- last-color will now read from `<cache_dir>/last-color.light`
      vim.cmd.colorscheme(last_color.recall())
    end,
  },
}

So effectively the user is able to call context() (or whatever name I end up calling it) to change which file colorscheme reads to and writes from. I haven't actually checked how feasible this is, but I just wanted to make sure I understand your request!

@podratz
Copy link
Author

podratz commented Nov 8, 2023

Yes I think that'd be a nice interface for it!

@raddari
Copy link
Owner

raddari commented Nov 10, 2023

Can you confirm #9 works as you would like? The syntax has changed slightly from my original post:

return {
  'f-person/auto-dark-mode.nvim',
  config = {
    set_dark_mode = function()
      local last_color = require('last-color')
      last_color.slot('dark')
      vim.cmd.colorscheme(last_color.recall())
    end,
    set_light_mode = function()
      local last_color = require('last-color')
      last_color.slot('light')
      vim.cmd.colorscheme(last_color.recall())
    end,
  },
}

@podratz
Copy link
Author

podratz commented Nov 14, 2023

Just seeing that now! Will get back to you shortly when I tried it.

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