| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- -- Theme configuration for Lumacs
- -- This file demonstrates how to configure and switch themes from Lua
- -- Theme switching functions
- function switch_to_theme(theme_name)
- local success, message = editor:execute_command("set-theme", {theme_name})
- if not success then
- editor:message("Failed to switch theme: " .. message) -- Corrected message call
- end
- end
- -- Specific theme switchers
- function switch_to_everforest()
- switch_to_theme("everforest-dark")
- end
- function switch_to_default()
- switch_to_theme("default")
- end
- function switch_to_dracula()
- switch_to_theme("dracula")
- end
- function switch_to_solarized()
- switch_to_theme("solarized-dark")
- end
- function switch_to_nord()
- switch_to_theme("nord")
- end
- function switch_to_gruvbox_light()
- switch_to_theme("gruvbox-light")
- end
- -- Enhanced theme listing
- function list_themes()
- local success, message = editor:execute_command("list-available-themes") -- Corrected command name
- if success then
- editor:message(message) -- Corrected message call
- else
- editor:message("Failed to list themes: " .. message) -- Corrected message call
- end
- end
- -- Theme management utilities (create_theme and get_current_theme are now largely obsolete
- -- as themes are defined in separate files and active_theme is exposed directly)
- -- function create_theme(name, config)
- -- message("Custom theme creation is now done by creating a new Lua file in lua/themes/")
- -- end
- -- function get_current_theme()
- -- local active_theme_obj = editor.theme_manager.active_theme
- -- if active_theme_obj then
- -- editor:message("Current theme: " .. active_theme_obj:name())
- -- else
- -- editor:message("No active theme.")
- -- end
- -- end
- -- Register theme management commands (these are mostly retained for M-x interaction)
- editor:register_command("list-available-themes", "List all available themes with descriptions", function(args)
- local themes = editor.theme_manager:theme_names()
- if #themes == 0 then
- return {success = true, message = "No themes available"}
- end
-
- -- NOTE: Descriptions are hardcoded here for display purposes.
- -- A more robust solution might store descriptions within the Theme object itself.
- local descriptions = {
- ["default"] = "Default light theme with comprehensive styling and clear contrast",
- ["everforest-dark"] = "Everforest dark theme - comfortable green-tinted dark theme with rich typography",
- ["dracula"] = "Dracula theme - popular dark theme with vibrant purple accents and modern fonts",
- ["solarized-dark"] = "Solarized Dark - precision colors for machines and people",
- ["nord"] = "Nord - arctic, north-bluish clean and elegant theme",
- ["gruvbox-light"] = "Gruvbox Light - retro groove warm light theme",
- ["catppuccin-mocha"] = "Catppuccin Mocha - warm, cozy dark theme with pastel colors and excellent readability",
- ["tokyo-night"] = "Tokyo Night - modern dark theme inspired by the neon lights of Tokyo",
- ["ayu-dark"] = "Ayu Dark - minimal dark theme with excellent contrast and clean typography"
- }
-
- local result = "Available themes:\n"
- local current_theme = editor.theme_manager:active_theme()
- local current_name = current_theme and current_theme:name() or "none"
-
- for i, name in ipairs(themes) do
- local indicator = (name == current_name) and " (current)" or ""
- local desc = descriptions[name] or "No description available"
- result = result .. " " .. name .. indicator .. " - " .. desc .. "\n"
- end
-
- return {success = true, message = result}
- end)
- editor:register_command("set-random-theme", "Switch to a random theme", function(args)
- local themes = editor.theme_manager:theme_names()
- if #themes == 0 then
- return {success = false, message = "No themes available"}
- end
-
- math.randomseed(os.time())
- local random_index = math.random(1, #themes)
- local random_theme = themes[random_index]
-
- local success, message = editor:execute_command("set-theme", {random_theme})
- if success then
- return {success = true, message = "Switched to random theme: " .. random_theme}
- else
- return {success = false, message = "Failed to switch theme: " .. message}
- end
- end)
- editor:register_command("cycle-themes", "Cycle through available themes", function(args)
- local themes = editor.theme_manager:theme_names()
- if #themes <= 1 then
- return {success = false, message = "Need at least 2 themes to cycle"}
- end
-
- local current_theme = editor.theme_manager:active_theme()
- local current_name = current_theme and current_theme:name() or ""
-
- -- Find current theme index
- local current_index = 1
- for i, name in ipairs(themes) do
- if name == current_name then
- current_index = i
- break
- end
- end
-
- -- Switch to next theme (wrap around)
- local next_index = (current_index % #themes) + 1
- local next_theme = themes[next_index]
-
- local success, message = editor:execute_command("set-theme", {next_theme})
- if success then
- return {success = true, message = "Cycled to theme: " .. next_theme}
- else
- return {success = false, message = "Failed to cycle theme: " .. message}
- end
- end)
- -- Key bindings for theme management
- editor:bind_key("C-x t e", switch_to_everforest, "Switch to Everforest theme")
- editor:bind_key("C-x t d", switch_to_default, "Switch to default theme")
- editor:bind_key("C-x t v", switch_to_dracula, "Switch to Dracula theme")
- editor:bind_key("C-x t s", switch_to_solarized, "Switch to Solarized Dark theme")
- editor:bind_key("C-x t n", switch_to_nord, "Switch to Nord theme")
- editor:bind_key("C-x t g", switch_to_gruvbox_light, "Switch to Gruvbox Light theme")
- editor:bind_key("C-x t l", list_themes, "List all themes")
- editor:bind_key("C-x t r", function() editor:execute_command("set-random-theme") end, "Switch to random theme")
- editor:bind_key("C-x t c", function() editor:execute_command("cycle-themes") end, "Cycle through themes")
- print("Enhanced theme configuration loaded - try C-x t for theme commands or M-x set-theme")
- -- Set initial theme after all themes are loaded
- switch_to_theme("everforest-dark")
|