Add support noether modeline
This commit is contained in:
parent
737b3d97aa
commit
79355e6196
|
@ -27,6 +27,7 @@ let
|
||||||
./git
|
./git
|
||||||
./minibuffer-vertico
|
./minibuffer-vertico
|
||||||
./graphics
|
./graphics
|
||||||
|
./noether
|
||||||
];
|
];
|
||||||
|
|
||||||
pkgsModule = { config, ... }: {
|
pkgsModule = { config, ... }: {
|
||||||
|
|
|
@ -72,7 +72,10 @@ in
|
||||||
dicts
|
dicts
|
||||||
]);
|
]);
|
||||||
|
|
||||||
fg42.font = lib.mkDefault '''("Fira Mono" 11)'';
|
fg42.font = {
|
||||||
|
name = lib.mkDefault "Fira Mono";
|
||||||
|
size = 11;
|
||||||
|
};
|
||||||
fg42.requires = [ drv.pname ];
|
fg42.requires = [ drv.pname ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,17 +37,16 @@
|
||||||
;; (require 'fg42/langs/nix)
|
;; (require 'fg42/langs/nix)
|
||||||
|
|
||||||
;; (require 'fg42/wm)
|
;; (require 'fg42/wm)
|
||||||
(require 'fg42/organize)
|
(require 'fg42/organize))
|
||||||
;;(require 'fg42/modeline)
|
|
||||||
)
|
|
||||||
|
|
||||||
(require 'server)
|
(require 'server)
|
||||||
(require 'fg42/utils)
|
(require 'fg42/utils)
|
||||||
|
|
||||||
(defun fg42/setup-font ()
|
(defun fg42/setup-font ()
|
||||||
"Set the default font of `FG42' to FONT-NAME and FONT-SIZE."
|
"Set the default font of `FG42' to FONT-NAME and FONT-SIZE."
|
||||||
(let ((name (car fg42/font))
|
(let ((name (fg42/config-get font-name))
|
||||||
(size (cadr fg42/font)))
|
(size (fg42/config-get font-size)))
|
||||||
|
|
||||||
(add-to-list 'default-frame-alist
|
(add-to-list 'default-frame-alist
|
||||||
(cons 'font (format "%s-%d" name size)))
|
(cons 'font (format "%s-%d" name size)))
|
||||||
|
|
||||||
|
@ -203,7 +202,7 @@ contextual information."
|
||||||
;; In the following section we're setting some default behavior of FG42.
|
;; In the following section we're setting some default behavior of FG42.
|
||||||
;; Most of these configuration are opiniated and I think most of people
|
;; Most of these configuration are opiniated and I think most of people
|
||||||
;; shared the same opinion or don't care at all.
|
;; shared the same opinion or don't care at all.
|
||||||
;;(fg42/setup-font)
|
(fg42/setup-font)
|
||||||
(add-hook 'fg42/after-init-hook
|
(add-hook 'fg42/after-init-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(set-default 'cursor-type 'bar)
|
(set-default 'cursor-type 'bar)
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
# Fg42 - Emacs Editor for advance users
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, version 2.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# This is the home manager module that exposes FG42. It differs
|
||||||
|
# from FG42 modules that are structurally the same but used in
|
||||||
|
# different context
|
||||||
|
|
||||||
|
# A list of default FG42 modules to build FG42 with.
|
||||||
|
{ lib, config, pkgs, makeFG42Drv, extraPackages, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.fg42.noether;
|
||||||
|
|
||||||
|
deps =
|
||||||
|
(with pkgs.emacsPackages; [
|
||||||
|
posframe
|
||||||
|
extraPackages.noether
|
||||||
|
]);
|
||||||
|
|
||||||
|
drv = makeFG42Drv {
|
||||||
|
pname = "noether";
|
||||||
|
version = config.fg42.version;
|
||||||
|
buildInputs = deps;
|
||||||
|
src = ./.;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
../graphics
|
||||||
|
];
|
||||||
|
|
||||||
|
options.fg42.noether.enable = mkAndEnableOption "noether";
|
||||||
|
options.fg42.noether.modeline.enable = mkAndEnableOption "noether-modeline";
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
fg42.elispPackages = [ drv ] ++ deps;
|
||||||
|
|
||||||
|
fg42.requires = [ drv.pname ];
|
||||||
|
fg42.vars = [
|
||||||
|
(lib.defVar "noether" cfg.enable "Whether or not enable Noether mode.")
|
||||||
|
(lib.defVar "noether-modeline" cfg.modeline.enable "Whether or not enable Noether's modeline.")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
;;
|
||||||
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
;; URL: https://devheroes.codes/FG42/FG42
|
||||||
|
;; Version: 4.0.0
|
||||||
|
;;
|
||||||
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
;;
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
;;
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
;;
|
||||||
|
;;; Commentary:
|
||||||
|
;;; Code:
|
||||||
|
(eval-when-compile
|
||||||
|
(require 'fpkg)
|
||||||
|
(require 'fg42/config))
|
||||||
|
|
||||||
|
(require 'noether)
|
||||||
|
(require 'noether-units)
|
||||||
|
(require 'projectile)
|
||||||
|
|
||||||
|
(with-config "graphics"
|
||||||
|
(require 'nerd-icons)
|
||||||
|
|
||||||
|
(defvar fg42/-mode-icon)
|
||||||
|
|
||||||
|
(defun fg42/-update-mode-icon ()
|
||||||
|
"Set the current buffer name to the watched var."
|
||||||
|
(setq fg42/-mode-icon major-mode))
|
||||||
|
|
||||||
|
(defun fg42/-format-mode-icon (_ v _ _)
|
||||||
|
"Format the icon V."
|
||||||
|
(format " %s " (nerd-icons-icon-for-mode v)))
|
||||||
|
|
||||||
|
|
||||||
|
(noether-defunit fg42/mode-icon
|
||||||
|
"Draws an icon for the current major mode."
|
||||||
|
:label ""
|
||||||
|
:len 3
|
||||||
|
:init (lambda ()
|
||||||
|
(add-hook 'post-command-hook #'fg42/-update-mode-icon))
|
||||||
|
|
||||||
|
:deinit (lambda ()
|
||||||
|
(remove-hook 'post-command-hook #'fg42/-update-mode-icon))
|
||||||
|
|
||||||
|
:var 'fg42/-mode-icon
|
||||||
|
:fn #'fg42/-format-mode-icon))
|
||||||
|
|
||||||
|
;; ============================================================================
|
||||||
|
;; Exwm input mode
|
||||||
|
;; ============================================================================
|
||||||
|
(defvar fg42/-exwm-input-mode nil)
|
||||||
|
|
||||||
|
(defun fg42/-set-exwm-input-mode ()
|
||||||
|
"Set the EXWM input mode for the current buffer."
|
||||||
|
(setq fg42/-exwm-input-mode (format "%s" exwm--input-mode)))
|
||||||
|
|
||||||
|
|
||||||
|
(defun fg42/-format-exwm-input-mode (_ v _ _)
|
||||||
|
"Just return the input mode name V."
|
||||||
|
(if (=string v "line")
|
||||||
|
(propertize "L" 'font-lock-face `(:foreground ,(get-base16-color-or :base07 "eeeeec")))
|
||||||
|
(propertize "C" 'font-lock-face `(:foreground ,(get-base16-color-or :base0A "eeeeec")))))
|
||||||
|
|
||||||
|
|
||||||
|
(noether-defunit fg42/exwm-input-mode-unit
|
||||||
|
"Show the input mode of EXWM for the current buffer."
|
||||||
|
:label "I:"
|
||||||
|
:len 4
|
||||||
|
:init (lambda ()
|
||||||
|
(when (featurep 'exwm)
|
||||||
|
(add-hook 'noether-on-buffer-change-hook #'fg42/-set-exwm-input-mode)))
|
||||||
|
:deinit (lambda ()
|
||||||
|
(when (featurep 'exwm)
|
||||||
|
(remove-hook 'noether-on-buffer-change-hook #'fg42/-set-exwm-input-mode)))
|
||||||
|
:var 'fg42/-exwm-input-mode
|
||||||
|
:fn #'fg42/-format-exwm-input-mode)
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'fg42/modeline/units)
|
||||||
|
;;; units.el ends here
|
|
@ -0,0 +1,122 @@
|
||||||
|
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
;;
|
||||||
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
;; URL: https://devheroes.codes/FG42/FG42
|
||||||
|
;; Version: 4.0.0
|
||||||
|
;;
|
||||||
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
;;
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
;;
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
;;
|
||||||
|
;;; Commentary:
|
||||||
|
;;; Code:
|
||||||
|
(eval-when-compile
|
||||||
|
(require 'fpkg)
|
||||||
|
(require 'fg42/config))
|
||||||
|
|
||||||
|
|
||||||
|
(require 'fg42/modeline/units)
|
||||||
|
|
||||||
|
|
||||||
|
(defun fg42/--bottom-right (info)
|
||||||
|
"Keep the modeline at bottom right by using the data from INFO."
|
||||||
|
(cons -1 -2))
|
||||||
|
|
||||||
|
(defun fg42/--bottom-right-padded (info)
|
||||||
|
"Keep the modeline at bottom right by using the data from INFO."
|
||||||
|
(cons -70 -2))
|
||||||
|
|
||||||
|
|
||||||
|
(defun fg42/adjust-modeline (view)
|
||||||
|
"Adjust the VIEW after parent frame resize."
|
||||||
|
(noether-show view))
|
||||||
|
|
||||||
|
|
||||||
|
(noether-defview fg42/modeline
|
||||||
|
"A simple and minimalist mode-line like status bar"
|
||||||
|
:managed? t
|
||||||
|
:binding (kbd "C-c 0")
|
||||||
|
:buffer "*modeline*"
|
||||||
|
:visible? t
|
||||||
|
:timeout 0
|
||||||
|
:on-parent-resize #'fg42/adjust-modeline
|
||||||
|
:frame
|
||||||
|
(list
|
||||||
|
:right-fringe 5
|
||||||
|
:poshandler #'fg42/--bottom-right
|
||||||
|
:border-width 0
|
||||||
|
:font (format "%s %s" (fg42/config-get font-name) (- (fg42/config-get font-size) 1))
|
||||||
|
:border-color "#bd93f9")
|
||||||
|
|
||||||
|
:units
|
||||||
|
(if-config "graphics"
|
||||||
|
;; Then
|
||||||
|
(progn
|
||||||
|
(require 'nerd-icons)
|
||||||
|
(list
|
||||||
|
(buffer-name-unit
|
||||||
|
:label (format "%s " (nerd-icons-codicon "nf-cod-layers"))
|
||||||
|
:len 20)
|
||||||
|
(projectile-project-unit
|
||||||
|
:label (format "%s " (nerd-icons-octicon "nf-oct-project"))
|
||||||
|
:len 20)
|
||||||
|
(git-branch-unit
|
||||||
|
:label (format "%s " (nerd-icons-devicon "nf-dev-git_branch"))
|
||||||
|
:len 20)
|
||||||
|
(fg42/mode-icon)
|
||||||
|
(line-unit :label (format "%s " (nerd-icons-codicon "nf-cod-location")))
|
||||||
|
(time-unit :label (format " %s " (nerd-icons-mdicon "nf-md-clock_time_three")))))
|
||||||
|
;; Else
|
||||||
|
(progn
|
||||||
|
(list
|
||||||
|
(buffer-name-unit
|
||||||
|
:label "B: "
|
||||||
|
:len 20)
|
||||||
|
(projectile-project-unit
|
||||||
|
:label "P: "
|
||||||
|
:len 20)
|
||||||
|
(git-branch-unit
|
||||||
|
:label "G: "
|
||||||
|
:len 20)
|
||||||
|
(line-unit :label "L: ")
|
||||||
|
(time-unit :label "T: ")))))
|
||||||
|
|
||||||
|
|
||||||
|
(noether-defview fg42/minimal-exwm
|
||||||
|
"A super simple bar containing the line number and column number that
|
||||||
|
Appears on the center of the current window."
|
||||||
|
:managed? t
|
||||||
|
:buffer "*exwm-status*"
|
||||||
|
:binding (kbd "C-c 1")
|
||||||
|
:separator " | "
|
||||||
|
|
||||||
|
:timeout 10
|
||||||
|
:frame
|
||||||
|
(list
|
||||||
|
:poshandler #'fg42/--bottom-right-padded
|
||||||
|
:border-width 0
|
||||||
|
:border-color "#bd93f9")
|
||||||
|
|
||||||
|
:units
|
||||||
|
(list
|
||||||
|
(fg42/exwm-input-mode-unit :label (format "%s " (nerd-icons-faicon "nf-fa-linux")))
|
||||||
|
(buffer-name-unit
|
||||||
|
:label (format "%s " (nerd-icons-codicon "nf-cod-layers"))
|
||||||
|
:len 30)
|
||||||
|
|
||||||
|
(time-unit :label (format "%s " (nerd-icons-mdicon "nf-md-clock_time_three")))))
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'fg42/modeline/views)
|
||||||
|
;;; views.el ends here
|
|
@ -0,0 +1,89 @@
|
||||||
|
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
;;
|
||||||
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
;; URL: https://devheroes.codes/FG42/FG42
|
||||||
|
;; Version: 4.0.0
|
||||||
|
;;
|
||||||
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
;;
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
;;
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
;;
|
||||||
|
;;; Commentary:
|
||||||
|
;;; Code:
|
||||||
|
(eval-when-compile
|
||||||
|
(require 'fpkg)
|
||||||
|
(require 'fg42/config)
|
||||||
|
(require 'fg42/utils))
|
||||||
|
|
||||||
|
(defvar fg42/noether-views nil
|
||||||
|
"A list of Noether views to use for modeline.")
|
||||||
|
|
||||||
|
(defvar fg42/modeline-active-face nil
|
||||||
|
"Override the active modeline face via this var.")
|
||||||
|
|
||||||
|
(defvar fg42/modeline-inactive-face nil
|
||||||
|
"Override the inactive modeline face via this var.")
|
||||||
|
|
||||||
|
(defface fg42/-disabled-modeline-active-border
|
||||||
|
'((t
|
||||||
|
:background "#bd93f9" :height 0.1 :box nil))
|
||||||
|
"A new face for modeline in active state."
|
||||||
|
:group 'fg42)
|
||||||
|
|
||||||
|
|
||||||
|
(defface fg42/-disabled-modeline-dective-border
|
||||||
|
'((t
|
||||||
|
:background "#44475a" :height 0.1 :box nil))
|
||||||
|
"A new face for modeline in active state."
|
||||||
|
:group 'fg42)
|
||||||
|
|
||||||
|
|
||||||
|
(use! noether
|
||||||
|
"Smart mode line is a pretty simple yet fantastic alternative
|
||||||
|
to Emacs modeline."
|
||||||
|
:if (display-graphic-p)
|
||||||
|
;;:after projectile
|
||||||
|
:commands noether-global-mode
|
||||||
|
:hook (emacs-startup . noether-global-mode)
|
||||||
|
:config
|
||||||
|
(require 'noether-views)
|
||||||
|
(require 'fg42/modeline/views)
|
||||||
|
|
||||||
|
(with-config "noether-modeline"
|
||||||
|
(let ((active-border (get-base16-color-or :base0A "#bd93f9"))
|
||||||
|
(inactive-border (get-base16-color-or :base03 "#44475a")))
|
||||||
|
(set-face-attribute 'fg42/-disabled-modeline-active-border nil :background active-border)
|
||||||
|
(set-face-attribute 'fg42/-disabled-modeline-dective-border nil :background inactive-border))
|
||||||
|
|
||||||
|
;; Disable the default modeline
|
||||||
|
(setq-default mode-line-format "")
|
||||||
|
(let ((face-remaps (default-value 'face-remapping-alist)))
|
||||||
|
(setf (alist-get 'mode-line face-remaps)
|
||||||
|
(if fg42/modeline-active-face fg42/modeline-active-face 'fg42/-disabled-modeline-active-border)
|
||||||
|
(alist-get 'mode-line-inactive face-remaps)
|
||||||
|
(if fg42/modeline-inactive-face fg42/modeline-inactive-face 'fg42/-disabled-modeline-dective-border)
|
||||||
|
(default-value 'face-remapping-alist) face-remaps))
|
||||||
|
|
||||||
|
(add-to-list 'fg42/noether-views fg42/modeline))
|
||||||
|
|
||||||
|
;; Setup modelines
|
||||||
|
(when-not-wm
|
||||||
|
(setq-default noether-views fg42/noether-views))
|
||||||
|
|
||||||
|
(when-wm
|
||||||
|
(setq-default noether-views nil)))
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'fg42/noether)
|
||||||
|
;;; noether.el ends here
|
|
@ -44,6 +44,7 @@ in
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = pkgs.emacs29.override ({
|
default = pkgs.emacs29.override ({
|
||||||
withTreeSitter = true;
|
withTreeSitter = true;
|
||||||
|
toolkit = "no";
|
||||||
});
|
});
|
||||||
description = "What Emacs package to use.";
|
description = "What Emacs package to use.";
|
||||||
};
|
};
|
||||||
|
@ -82,8 +83,18 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
fg42.font = mkOption {
|
fg42.font = mkOption {
|
||||||
type = types.uniq types.str;
|
type = types.submodule {
|
||||||
example = "fg42.font = ''(cons \"Fira Code\" 10) '';";
|
options = {
|
||||||
|
name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
size = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
example = ''fg42.font = {name = "Fira Mono"; size = 10; };'';
|
||||||
description = "The default font for FG42";
|
description = "The default font for FG42";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -171,8 +182,11 @@ in
|
||||||
fg42.elispPackages = [ drv ];
|
fg42.elispPackages = [ drv ];
|
||||||
fg42.theme = lib.mkDefault "base16-eighties";
|
fg42.theme = lib.mkDefault "base16-eighties";
|
||||||
fg42.theme-package-name = lib.mkDefault "base16-theme";
|
fg42.theme-package-name = lib.mkDefault "base16-theme";
|
||||||
|
|
||||||
fg42.vars = [
|
fg42.vars = [
|
||||||
(lib.defVar "theme" cfg.theme "The default font for FG42")
|
(lib.defVar "font-name" cfg.font.name "The default font for FG42")
|
||||||
|
(lib.defVar "font-size" cfg.font.size "The default font size for FG42")
|
||||||
|
(lib.defVar "theme" cfg.theme "The default theme for FG42")
|
||||||
(lib.defVar "theme-package-name" cfg.theme-package-name ''
|
(lib.defVar "theme-package-name" cfg.theme-package-name ''
|
||||||
The theme package name to use with FG42. The package should be added to `elispPackages` already.
|
The theme package name to use with FG42. The package should be added to `elispPackages` already.
|
||||||
'')
|
'')
|
||||||
|
|
Loading…
Reference in New Issue