| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- -- doom-modeline.lua
- -- ============================================================================
- -- Doom Emacs-inspired modeline styling and configuration.
- -- Provides enhanced visual styling for the modeline.
- -- ============================================================================
- local doom_modeline = {}
- -- Configuration options
- doom_modeline.config = {
- height = 1, -- Number of lines (currently fixed to 1)
- bar_width = 4, -- Width of the colored bar indicator
- icon_type = "unicode", -- "unicode" or "ascii" (unicode uses special chars)
- show_major_mode_icon = true, -- Show icon for major mode
- show_buffer_encoding = false, -- Show buffer encoding
- show_word_count = false, -- Show word count for text modes
- }
- -- Unicode icons for various states (fallback to ASCII if not supported)
- doom_modeline.icons = {
- modified = "●", -- Buffer modified
- readonly = "", -- Read-only
- saved = "✓", -- Just saved
- lock = "🔒", -- Locked
- -- Major mode icons
- lua = "☾",
- python = "🐍",
- c = "C",
- cpp = "C++",
- javascript = "JS",
- typescript = "TS",
- rust = "🦀",
- go = "Go",
- fundamental = "F",
- -- Status indicators
- error = "✗",
- warning = "⚠",
- info = "ℹ",
- -- Git icons (for future use)
- git_branch = "",
- git_added = "+",
- git_modified = "~",
- git_removed = "-",
- }
- -- ASCII fallbacks
- doom_modeline.icons_ascii = {
- modified = "*",
- readonly = "%%",
- saved = "-",
- lock = "#",
- lua = "Lua",
- python = "Py",
- c = "C",
- cpp = "C++",
- javascript = "JS",
- typescript = "TS",
- rust = "Rs",
- go = "Go",
- fundamental = "F",
- error = "!",
- warning = "?",
- info = "i",
- git_branch = "@",
- git_added = "+",
- git_modified = "~",
- git_removed = "-",
- }
- -- Get icon based on configuration
- function doom_modeline.get_icon(name)
- if doom_modeline.config.icon_type == "ascii" then
- return doom_modeline.icons_ascii[name] or name
- end
- return doom_modeline.icons[name] or doom_modeline.icons_ascii[name] or name
- end
- -- Define doom-modeline faces
- function doom_modeline.setup_faces()
- -- Main modeline face (active window)
- lumacs.set_face("doom-modeline", {
- foreground = "#bbc2cf",
- background = "#21242b",
- })
- -- Inactive modeline
- lumacs.set_face("doom-modeline-inactive", {
- foreground = "#5B6268",
- background = "#1c1f24",
- })
- -- Buffer name (emphasized)
- lumacs.set_face("doom-modeline-buffer-file", {
- foreground = "#51afef",
- weight = "bold",
- })
- -- Modified indicator
- lumacs.set_face("doom-modeline-buffer-modified", {
- foreground = "#da8548",
- weight = "bold",
- })
- -- Major mode
- lumacs.set_face("doom-modeline-buffer-major-mode", {
- foreground = "#51afef",
- weight = "bold",
- })
- -- Minor modes
- lumacs.set_face("doom-modeline-buffer-minor-mode", {
- foreground = "#98be65",
- })
- -- Position info
- lumacs.set_face("doom-modeline-buffer-position", {
- foreground = "#bbc2cf",
- })
- -- Error indicator (for flycheck-like features)
- lumacs.set_face("doom-modeline-error", {
- foreground = "#ff6c6b",
- weight = "bold",
- })
- -- Warning indicator
- lumacs.set_face("doom-modeline-warning", {
- foreground = "#ECBE7B",
- weight = "bold",
- })
- -- Info indicator
- lumacs.set_face("doom-modeline-info", {
- foreground = "#98be65",
- })
- -- Project/workspace
- lumacs.set_face("doom-modeline-project", {
- foreground = "#c678dd",
- weight = "bold",
- })
- -- Bar segment (the colored vertical bar)
- lumacs.set_face("doom-modeline-bar", {
- background = "#51afef",
- })
- lumacs.set_face("doom-modeline-bar-inactive", {
- background = "#3f444a",
- })
- -- Evil/modal state faces (for future modal editing support)
- lumacs.set_face("doom-modeline-evil-normal", {
- foreground = "#21242b",
- background = "#51afef",
- weight = "bold",
- })
- lumacs.set_face("doom-modeline-evil-insert", {
- foreground = "#21242b",
- background = "#98be65",
- weight = "bold",
- })
- lumacs.set_face("doom-modeline-evil-visual", {
- foreground = "#21242b",
- background = "#c678dd",
- weight = "bold",
- })
- lumacs.set_face("doom-modeline-evil-emacs", {
- foreground = "#21242b",
- background = "#c678dd",
- weight = "bold",
- })
- end
- -- Apply doom-modeline styling to standard modeline faces
- function doom_modeline.apply_theme()
- -- Apply doom styling to the standard mode-line faces
- lumacs.set_face("mode-line", {
- foreground = "#bbc2cf",
- background = "#21242b",
- })
- lumacs.set_face("mode-line-inactive", {
- foreground = "#5B6268",
- background = "#1c1f24",
- })
- lumacs.set_face("mode-line-buffer-id", {
- foreground = "#51afef",
- weight = "bold",
- })
- end
- -- Color presets that can be applied
- doom_modeline.presets = {
- doom_one = {
- bar = "#51afef",
- bar_inactive = "#3f444a",
- buffer = "#51afef",
- modified = "#da8548",
- mode = "#c678dd",
- position = "#bbc2cf",
- background = "#21242b",
- foreground = "#bbc2cf",
- },
- nord = {
- bar = "#88c0d0",
- bar_inactive = "#3b4252",
- buffer = "#88c0d0",
- modified = "#ebcb8b",
- mode = "#b48ead",
- position = "#d8dee9",
- background = "#2e3440",
- foreground = "#d8dee9",
- },
- dracula = {
- bar = "#bd93f9",
- bar_inactive = "#44475a",
- buffer = "#ff79c6",
- modified = "#ffb86c",
- mode = "#bd93f9",
- position = "#f8f8f2",
- background = "#282a36",
- foreground = "#f8f8f2",
- },
- gruvbox = {
- bar = "#83a598",
- bar_inactive = "#3c3836",
- buffer = "#83a598",
- modified = "#fe8019",
- mode = "#d3869b",
- position = "#ebdbb2",
- background = "#282828",
- foreground = "#ebdbb2",
- },
- solarized = {
- bar = "#268bd2",
- bar_inactive = "#073642",
- buffer = "#268bd2",
- modified = "#cb4b16",
- mode = "#6c71c4",
- position = "#839496",
- background = "#002b36",
- foreground = "#839496",
- },
- }
- -- Apply a preset color scheme
- function doom_modeline.set_preset(preset_name)
- local preset = doom_modeline.presets[preset_name]
- if not preset then
- editor:message("Unknown preset: " .. preset_name, "warning")
- return
- end
- lumacs.set_face("mode-line", {
- foreground = preset.foreground,
- background = preset.background,
- })
- lumacs.set_face("mode-line-inactive", {
- foreground = preset.foreground,
- background = preset.bar_inactive,
- })
- lumacs.set_face("mode-line-buffer-id", {
- foreground = preset.buffer,
- weight = "bold",
- })
- lumacs.set_face("doom-modeline-buffer-modified", {
- foreground = preset.modified,
- weight = "bold",
- })
- lumacs.set_face("doom-modeline-buffer-major-mode", {
- foreground = preset.mode,
- weight = "bold",
- })
- lumacs.set_face("doom-modeline-buffer-position", {
- foreground = preset.position,
- })
- lumacs.set_face("doom-modeline-bar", {
- background = preset.bar,
- })
- lumacs.set_face("doom-modeline-bar-inactive", {
- background = preset.bar_inactive,
- })
- editor:message("Applied doom-modeline preset: " .. preset_name)
- end
- -- Register commands
- editor:register_command("doom-modeline-preset", "Set doom-modeline color preset", function(args)
- if #args == 0 then
- local presets = {}
- for name, _ in pairs(doom_modeline.presets) do
- table.insert(presets, name)
- end
- table.sort(presets)
- return {success = false, message = "Available presets: " .. table.concat(presets, ", ")}
- end
- doom_modeline.set_preset(args[1])
- return {success = true}
- end, {"dm-preset"}, true, "s")
- -- Setup command to apply all doom-modeline styling
- editor:register_command("doom-modeline-setup", "Enable doom-modeline styling", function(args)
- doom_modeline.setup_faces()
- doom_modeline.apply_theme()
- editor:message("Doom modeline styling applied")
- return {success = true}
- end, {"dm-setup"})
- -- Toggle ASCII/Unicode mode
- editor:register_command("doom-modeline-icons", "Toggle doom-modeline icon style", function(args)
- if #args > 0 then
- doom_modeline.config.icon_type = args[1]
- else
- if doom_modeline.config.icon_type == "unicode" then
- doom_modeline.config.icon_type = "ascii"
- else
- doom_modeline.config.icon_type = "unicode"
- end
- end
- editor:message("Icon type: " .. doom_modeline.config.icon_type)
- return {success = true}
- end, {"dm-icons"}, true, "s")
- -- Store in lumacs namespace
- lumacs.doom_modeline = doom_modeline
- print("[doom-modeline] Package loaded")
- return doom_modeline
|