diff --git a/.gitignore b/.gitignore index 696bac3..cebb3f8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ lazy-lock.json .luarc.json .neoconf.json lazyvim.json -debug/ \ No newline at end of file +.colorscheme +debug/ diff --git a/lua/config/keybinds.lua b/lua/config/keybinds.lua index f521f3e..c40e2c8 100644 --- a/lua/config/keybinds.lua +++ b/lua/config/keybinds.lua @@ -9,6 +9,19 @@ vim.api.nvim_create_user_command("Q", function() vim.cmd.qall() end, { force = true }) +-- ------------------------------ Auto-Commands -------------------------------- +-- Autosave Colorscheme +vim.api.nvim_create_autocmd("ColorScheme", { + desc = "Store colorscheme name", + callback = function() + print("colorscheme:", vim.g.colors_name) + vim.fn.writefile( + { vim.g.colors_name }, + vim.fn.stdpath("config") .. "/.colorscheme" + ) + end, +}) + -- --------------------------------- Keymaps ----------------------------------- local wk = require("which-key") wk.add({ diff --git a/lua/config/style.lua b/lua/config/style.lua index 4d92637..100340a 100644 --- a/lua/config/style.lua +++ b/lua/config/style.lua @@ -2,14 +2,20 @@ -- ---------------------------------- Style ------------------------------------ -- ----------------------------------------------------------------------------- --- Get the kitty theme -if os.getenv("KITTY_THEME") then - KITTY_THEME = os.getenv("KITTY_THEME") +-- Restore Colorscheme +if vim.fn.filereadable(vim.fn.stdpath("config") .. "/.colorscheme") == 1 then + -- Load the stored colorscheme + STORED_THEME = vim.fn.readfile(vim.fn.stdpath("config") .. "/.colorscheme")[1] +else + -- Get the kitty theme + if os.getenv("KITTY_THEME") then + KITTY_THEME = os.getenv("KITTY_THEME") + end end -- Apply the colorscheme -vim.cmd.colorscheme(KITTY_THEME or "catppuccin-frappe") +vim.cmd.colorscheme(STORED_THEME or KITTY_THEME or "catppuccin-frappe") -- Set GUI font vim.opt.guifont = "Iosevka:#e-subpixelantialias:h12" -vim.g.have_nerd_font = true \ No newline at end of file +vim.g.have_nerd_font = true