Compare commits

...

25 Commits

Author SHA1 Message Date
Sameer Rahmani 06635d9d8b
Update to noether 1.10 and add the date-unit to wm bar 2024-04-19 20:17:35 +01:00
Sameer Rahmani 3646ee6313
Add the noether modeline for wm mode as well 2024-04-19 19:01:21 +01:00
Sameer Rahmani 916ee2674c
Add support for window manager mode via a nix module 2024-04-19 18:39:42 +01:00
Sameer Rahmani fb3073ca19
Add fg42/lang-server-format to the before save of nix and c-family 2024-04-18 22:25:01 +01:00
Sameer Rahmani d1e00e67d7
Add support for Python 2024-04-18 21:53:51 +01:00
Sameer Rahmani b8e23dcb61
Add support for the C family 2024-04-18 21:35:40 +01:00
Sameer Rahmani 09a545edc1
Add support for Nix lang 2024-04-18 12:45:28 +01:00
Sameer Rahmani 78a89763ba
Add the autocomplete module to the nix side 2024-04-17 15:29:52 +01:00
Sameer Rahmani 79355e6196
Add support noether modeline 2024-04-17 14:43:59 +01:00
Sameer Rahmani 737b3d97aa
Fix the broken macro and replace all-the-icons with nerdicons 2024-04-17 13:42:17 +01:00
Sameer Rahmani 54649939b2
Break up graphic related stuff into graphics module 2024-04-17 12:16:54 +01:00
Sameer Rahmani f0ffe856da
Break up the vertico setup into minibuffer-vertico setup 2024-04-17 11:13:54 +01:00
Sameer Rahmani 71dbe6ef93
Break up the git feature in its own module 2024-04-16 22:34:30 +01:00
Sameer Rahmani 1e62751b69
Break up the nix modules even further 2024-04-16 22:01:42 +01:00
Sameer Rahmani 722a020352
Add the support for org-mode 2024-04-15 22:31:51 +01:00
Sameer Rahmani 4966e99079
Add the modeline module only with 'Emacs' support 2024-04-15 20:58:37 +01:00
Sameer Rahmani 20a162e4a1
Fix the broken conditional on the editor module 2024-04-15 20:34:26 +01:00
Sameer Rahmani 7368622086
Try to add emojify as an optional feature 2024-04-15 20:25:14 +01:00
Sameer Rahmani 906fe2fb8d
Move the minibuffer module to the nix side 2024-04-15 19:29:58 +01:00
Sameer Rahmani c5a478580b
Move over the elisp configuration as the first separated nix module 2024-04-15 19:13:48 +01:00
Sameer Rahmani 92549b9a08
generate the requires list and docstrings via nix and unit module 2024-04-15 18:57:22 +01:00
Sameer Rahmani 74d36d5ae1
Remove the old buildConfig in favor of the new build.el 2024-04-14 21:07:12 +01:00
Sameer Rahmani c9cdb0a83e
Add an Elisp script to convert Nix config to Elisp code 2024-04-14 19:49:21 +01:00
Sameer Rahmani 426c1d2dd1
Create a modular Nix system to build FG42 2024-04-13 22:21:20 +01:00
Sameer Rahmani 1a0f2a31d2
Revise the derivation to break down the config into nix modules 2024-04-12 22:18:03 +01:00
44 changed files with 3242 additions and 204 deletions

View File

@ -253,16 +253,16 @@
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1712846008,
"narHash": "sha256-0739q1QSpprLrlqdmQeSM9ynqmuqHagmRLnyMEy47Xc=",
"ref": "refs/tags/v0.1.8",
"rev": "e53688bcc79e5e3142bb2c912d59965c086dafe4",
"revCount": 49,
"lastModified": 1713553841,
"narHash": "sha256-k0p6s7cbN3cAeOBeTpIaFWbHhma+yNisC7HwAo4aDuA=",
"ref": "refs/tags/v0.1.10",
"rev": "8164261df59f6a31cbbd72b19777b1023aa38448",
"revCount": 52,
"type": "git",
"url": "https://devheroes.codes/lxsameer/noether"
},
"original": {
"ref": "refs/tags/v0.1.8",
"ref": "refs/tags/v0.1.10",
"type": "git",
"url": "https://devheroes.codes/lxsameer/noether"
}

View File

@ -17,7 +17,7 @@
description = "FG42 - Emacs Editor for advance users";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/442d407992384ed9c0e6d352de75b69079904e4e";
inputs.noether.url = "git+https://devheroes.codes/lxsameer/noether?ref=refs/tags/v0.1.8";
inputs.noether.url = "git+https://devheroes.codes/lxsameer/noether?ref=refs/tags/v0.1.10";
inputs.emacs-overlay.url = "github:nix-community/emacs-overlay/0f7f3b39157419f3035a2dad39fbaf8a4ba0448d";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
@ -29,6 +29,16 @@
"x86_64-linux"
];
flake = {
# The home-manager integration. The can use FG42 with home-manager by including
# this module.
hm-module = rec {
fg42 = import ./nix/hm;
default = fg42;
};
};
perSystem = { config, self', inputs', pkgs, system, ... }:
let
test-x = pkgs.writeShellApplication {
@ -39,30 +49,52 @@
${pkgs.xorg.xorgserver.out}/bin/Xephyr -br -ac -noreset -screen 800x600 :1
'';
};
noether = inputs.noether.outputs.packages.${system}.default;
factory = params: pkgs.callPackage ./nix/factory.nix ({ inherit noether; } // params);
default = (factory { });
fg42 = pkgs.callPackage ./nix/fg42 {
inherit nixpkgs;
extraPackages = {
noether = inputs.noether.outputs.packages.${system}.default;
};
};
fg42-wm = pkgs.callPackage ./nix/fg42 {
inherit nixpkgs;
modules = [
./nix/modules/editor
./nix/modules/elisp
./nix/modules/graphics
./nix/modules/noether
./nix/modules/wm
];
extraPackages = {
noether = inputs.noether.outputs.packages.${system}.default;
};
};
run-test-wm = pkgs.writeShellApplication {
name = "run-test-wm";
runtimeInputs = [ fg42-wm ];
text = ''
DISPLAY=:1 ${fg42-wm}/bin/fg42-wm
'';
};
in
{
packages = {
default = default.fg42;
} // (pkgs.lib.optionalAttrs (system == "x86_64-linux") {
# Gtk causes a flickering issue on WM mode
lucid = (factory { emacsParams.toolkit = "lucid"; }).fg42;
gtk3 = (factory { emacsParams.withGTK3 = true; }).fg42;
pgtk = (factory { emacsParams.withPgtk = true; }).fg42;
gtk2 = (factory { emacsParams.withGTK2 = true; }).fg42;
none = (factory { emacsParams.toolkit = "no"; }).fg42;
});
default = fg42;
wm = fg42-wm;
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = [ default.fg42 pkgs.fish test-x default.run-test-wm ];
buildInputs = [ default.fg42 ];
nativeBuildInputs = [ fg42 fg42-wm pkgs.fish test-x run-test-wm ];
buildInputs = [ fg42 fg42-wm ];
};
apps.wm = {
type = "app";
program = "${default.run-test-wm}/bin/run-test-wm";
program = "${run-test-wm}/bin/run-test-wm";
};
apps.x = {
@ -71,7 +103,7 @@
};
apps.default = {
type = "app";
program = "${default.fg42}/bin/fg42";
program = "${fg42}/bin/fg42";
};
};

184
lisp/build.el Normal file
View File

@ -0,0 +1,184 @@
;;; 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:
;; This is the builder script that takes the config.json from the input
;; (typically provided by Nix). And generates appropriate Elisp file
;; for the main FG42 Elsip code to load and use.
;;
;; Please note that this file runs with Emacs and not FG42.
;;; Code:
(require 'loaddefs-gen)
(when (not (json-available-p))
(error "Error: libjasson support is missing"))
(defvar file-header " ;;; 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:
;; This is the builder script that takes the config.json from the input
;; (typically provided by Nix). And generates appropriate Elisp file
;; for the main FG42 Elsip code to load and use.
;;
;; Please note that this file runs with Emacs and not FG42.
;;; Code:
;; ============================================================================
;; This file is auto generated by FG42. Don't modify it.
;; ============================================================================
;; Since it is deprecated we can easily avoide other packages to use it
(provide 'cl)
(require 'fg42/pre)
")
(defvar file-footer "
(require 'fg42)
(provide 'fg42_init)
;; fg42_init.el ends here
")
(defvar keys-to-skip '("docstrings" "mimeTypes"))
;; Elisp's hashtables are not functional so I have to store the
;; state like this, Ewwwwww!
(defvar vars ()
"Storage for the vars and const forms.")
(defvar requires ()
"Storage for the require forms.")
(defvar build-output (cadr command-line-args-left))
;;; Build related stuff
(defmacro with-json (var &rest body)
"Read the json file from cli arguments, user VAR run the BODY on it."
(declare (indent defun))
`(let ((input-file (car command-line-args-left)))
(message "[build.el]: Reading the input file: %s" input-file)
(with-temp-buffer
(insert-file-contents input-file)
(let ((,var (json-parse-buffer)))
,@body))))
(defun replace-in-string (what with s)
"Replace WHAT in string S with WITH."
(replace-regexp-in-string (regexp-quote what) with s nil 'literal))
(defun generate-compile-time-requires (elisp-pkgs)
"Generate a list of `require' forms of ELISP-PKGS for compile time."
(when (> (length elisp-pkgs) 0)
(add-to-list
'requires
`(eval-when-compile
,@(mapcar (lambda (pkg) `(require ',(intern (replace-in-string "fg42-" "fg42/" pkg)))) elisp-pkgs)))))
(defun generate-generic-vars (k v doc &optional const)
"Generate a list of vars for K and value V with docstring DOC.
Generate a constant if CONST is non-nil."
(add-to-list 'vars `(,(if const 'defconst 'defvar)
,(intern (format "fg42/config/%s" k)) ,v ,doc)))
(defun fg42-config-key-handler (config)
"Generate a lambda to process key/value pairs in CONFIG."
(lambda (k v)
"Handle the FG42 config K and its value V."
(cond
((string= k "requires")
(generate-compile-time-requires v))
((member k keys-to-skip)
(message "[build.el]: Skipping %s..." k))
((and (string= k "vars") (> (length v) 0))
(mapc (lambda (x)
(generate-generic-vars (gethash "name" x)
(gethash "defaultValue" x)
(gethash "docstring" x)))
v))
((and (string= k "consts") (> (length v) 0))
(mapc (lambda (x)
(generate-generic-vars (gethash "name" x)
(gethash "defaultValue" x)
(gethash "docstring" x)
t))
v)))))
(defun fg42-handler (config)
"Handle the CONFIG for FG42.
CONFIG maps to the collective `config' value of Nix modules."
(maphash (fg42-config-key-handler config) config))
(defun handle-conifg-for (k v)
"Find the handler of K and its value V to it."
(funcall (intern (format "%s-handler" k)) v))
(defun handle-top-level (k v)
"Handle the key K and value V form the top level of the JSON data."
(when (not (string= k "fg42"))
(error "Don't know how to handle '%s'" k))
(handle-conifg-for k v))
(with-json j
;; TODO: To make it scale, may be let Nix modules
;; plug into this script. There is a security
;; rist though
(maphash #'handle-top-level j)
(with-temp-file build-output
(insert file-header)
(insert ";; Vars ======")
(mapc (lambda (x) (print x (current-buffer))) vars)
(insert ";; Requires ======")
(mapc (lambda (x) (print x (current-buffer))) requires)
(insert file-footer))
(message "[build.el]: Done!"))
(provide 'build)
;;; build.el ends here

62
nix/fg42/default.nix Normal file
View File

@ -0,0 +1,62 @@
# 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
{ pkgs
, nixpkgs
, lib ? pkgs.lib
, modules ? null
, extraModules ? [ ]
, extraPackages ? { }
}:
let
fg42Modules =
if modules != null
then modules
else
import ../modules {
inherit pkgs lib;
};
pkgsModule = { config, ... }: {
config = {
_module.args.baseModules = modules;
_module.args.pkgs = lib.mkDefault pkgs;
_module.check = true;
};
};
utils = pkgs.callPackage ./utils.nix { };
final = lib.evalModules {
# The unit module is mandatory and the bare min
# config that is necessary
modules = [ ../modules/unit ] ++ fg42Modules ++ extraModules ++ [ pkgsModule ];
specialArgs = {
inherit utils;
inherit (utils) makeFG42Drv;
inherit extraPackages;
lib = nixpkgs.lib.extend (import ./lib.nix { inherit pkgs; });
};
};
in
pkgs.callPackage ./derivation.nix {
inherit (final) config options;
inherit utils;
maintainers = import ../maintainers.nix;
}

View File

@ -14,129 +14,84 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ lib
, config
, stdenv
, elispPkgs
, srcDir
, emacsPackagesFor
, ourPackages
, direnv
, makeFontsConf
, nix
, nixpkgs-fmt
, nil
, # nix lsp server
# python deps
python311
, python3Packages
, # This is a set of system tools required for FG42
# to work.
pyright
, emacs
, ripgrep
, git
, texinfo
, vazir-fonts
, fira-code
, nerdfonts
, fira-mono
, noto-fonts
, gcc
, ltex-ls
, bash
, tree-sitter
, fd
, aspellWithDicts
, supportWM ? true
, utils
, emacsPackagesFor
, makeFontsConf
, xorg
, slock
, supportPython ? true
, supportVerilog ? true
, svls
, verilator
,
, maintainers
, writeTextFile
, writeShellApplication
, ...
}:
with builtins;
let
version = "4.0.0";
getPkg = epkgs: pkg:
if hasAttr pkg epkgs then getAttr pkg epkgs else getAttr pkg ourPackages;
cfg = config.fg42;
emacs = cfg.emacs;
version = cfg.version;
emacsBundle = (emacsPackagesFor emacs).withPackages (epkgs:
(map (x: getPkg epkgs x) elispPkgs)
++ [ epkgs.treesit-grammars.with-all-grammars ]);
emacsBundle = (emacsPackagesFor emacs).withPackages (_: cfg.elispPackages);
maintainers = import ./maintainers.nix;
dicts = aspellWithDicts (dicts: with dicts; [ en en-computers en-science ]);
runtimeBins = [
ripgrep
git
tree-sitter
direnv
nix
nil
dicts
fd
nixpkgs-fmt
]
++ (lib.optional (!stdenv.buildPlatform.isRiscV) [
# Not supported on Risc-V
ltex-ls
])
++ (lib.optional supportPython [
python311
# Python deps
python311
pyright
python3Packages.black
python3Packages.pylint
python3Packages.flake8
]) ++ (lib.optional supportVerilog [ svls ])
++ (lib.optional (supportVerilog && stdenv.isLinux) [
# SystemC is required by verilator that at the
# moment is only available on Linux
verilator
]) ++ (lib.optional (supportWM && stdenv.isLinux) [
# Window manager supports works on Linux only
xorg.xhost
slock
]);
paths = map (x: "${x}/bin/") (lib.lists.flatten runtimeBins);
paths = map (x: "${x}/bin/") cfg.paths;
pathsStr = lib.strings.concatStrings (lib.strings.intersperse ":" paths);
mimes = import ./mimes.nix;
fontsConf = makeFontsConf {
fontDirectories = [
vazir-fonts
fira-code
nerdfonts
fira-mono
noto-fonts
];
mimeTypes = builtins.concatStringsSep ";" cfg.mimeTypes;
fontsConf = makeFontsConf { fontDirectories = cfg.fonts; };
# Whatever that needs to be in the PATH is considered a runtime
# dependency.
# Fonts are obviously runtime dependency as well
runtimeDependencies = cfg.paths ++ cfg.fonts ++ cfg.elispPackages;
configFile = writeTextFile {
name = "config.json";
text = (toJSON {
fg42 = {
inherit (cfg) vars consts requires;
};
});
executable = false;
};
in
stdenv.mkDerivation (final: rec {
stdenv.mkDerivation rec {
inherit version;
pname = "fg42";
src = srcDir;
outputs = [ "out" ];
pname = builtins.trace ">>> ${configFile}" "FG42";
src = ../../.;
buildPhase = ''
runHook preBuild
LISPDIR=$out/share/fg42/
STARTUP_FILE=$LISPDIR/lisp/fg42_init.el
mkdir -p $out/bin
mkdir -p $out/share/applications/
install -d $LISPDIR
cp -rv ${src}/lisp/ $LISPDIR
mkdir -p $LISPDIR/lisp
cp -rv ${src}/lisp/build.el $LISPDIR/lisp
cp -rv ${src}/share $out/
cp -rv ${src}/snippets $LISPDIR/snippets
cp "${fontsConf}" $LISPDIR/fonts.conf
cp "${configFile}" $LISPDIR/config.json
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
chmod 755 $LISPDIR -R
emacs --batch -l $LISPDIR/lisp/build.el $LISPDIR/config.json $STARTUP_FILE
#emacs -Q --batch -l package --eval "(package-generate-autoloads \"fg42_init" \"$LISPDIR\")"
emacs --batch -l loaddefs-gen -f loaddefs-generate-batch $LISPDIR/lisp/ $LISPDIR/lisp/ ${emacsBundle}
cat >> $out/share/applications/FG42.desktop << EOF
[Desktop Entry]
@ -144,7 +99,7 @@ stdenv.mkDerivation (final: rec {
Name=FG42
GenericName=FG42
Comment=The nix base Emacs bundle for advance users
MimeType=${mimes.mimeTypes}
MimeType=${mimeTypes}
Type=Application
Terminal=false
Categories=Development;TextEditor;
@ -154,38 +109,43 @@ stdenv.mkDerivation (final: rec {
Version=${version}
EOF
runHook preBuild
cat >> $out/share/runtime_deps << EOF
${lib.strings.concatLines runtimeDependencies}
${emacsBundle}
EOF
cd $LISPDIR
emacs -L . --batch -f batch-byte-compile *.el
#compile stuff
cd -
cat >> $out/bin/fg42 << EOF
#!${stdenv.shell}
export FG42_HOME=${placeholder "out"}/share/fg42/
export FG42_EMACSD=~/.fg42/v4/emacs.d
export FG42_USE_NIX=true;
export PATH=${pathsStr}:$PATH
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
export STARTUP_FILE=$LISPDIR/lisp/fg42_init.el
LIBRARY_PATH="\$(${stdenv.cc}/bin/cc -print-file-name=libgccjit.so):\$LIBRARY_PATH" \
FG42_WM=fales ${emacsBundle}/bin/emacs \
--name FG42 \
-q --no-splash --title FG42 \
-l \$FG42_HOME/lisp/fg42/init.el "\$@"
-l "$STARTUP_FILE" "\$@"
EOF
chmod +x $out/bin/fg42
LISPDIR=$out/share/fg42/lisp/
mkdir -p $LISPDIR
#emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$LISPDIR\")"
runHook postBuild
cat >> $out/bin/fg42-wm << EOF
#!${stdenv.shell}
export FG42_HOME=${placeholder "out"}/share/fg42/
export FG42_EMACSD=~/.fg42/v4/emacs.d
export FG42_USE_NIX=true;
export PATH=${pathsStr}:\$PATH
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
export STARTUP_FILE=$LISPDIR/lisp/fg42_init.el
# Disable access control for the current user.
${xorg.xhost}/bin/xhost +SI:localuser:\$USER
@ -208,32 +168,15 @@ stdenv.mkDerivation (final: rec {
LIBRARY_PATH="\$(${stdenv.cc}/bin/cc -print-file-name=libgccjit.so):\$LIBRARY_PATH" \
FG42_WM=true ${emacsBundle}/bin/emacs \
--name FG42 \
-q --no-splash --title FG42 \
-l \$FG42_HOME/lisp/fg42/init.el "\$@"
-q --no-splash --title FG42 \
-l $STARTUP_FILE "\$@"
EOF
chmod +x $out/bin/fg42-wm
cat >> $out/share/runtiem_deps << EOF
${vazir-fonts}
${fira-code}
${fira-mono}
${nerdfonts}
${noto-fonts}
${lib.strings.concatLines paths}
EOF
runHook postBuild
'';
installPhase = ''
runHook preInstall
#LISPDIR=$out/share/fg42/lisp/
#emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$LISPDIR\")"
runHook postInstall
'';
buildInputs = [ emacs emacsBundle git texinfo gcc bash ];
addEmacsNativeLoadPath = true;
@ -243,7 +186,7 @@ stdenv.mkDerivation (final: rec {
platforms = emacs.meta.platforms;
homepage = "https://fg42.org/";
maintainers = [ maintainers.lxsameer ];
description = "The mighty editor for the emacsians";
description = "The mighty editor for the Emacsians";
longDescription = ''
FG42 is a framework to create and editor and window manager based on GNU/Emacs.
It has a pre-defined setup as well which can be installed out of the box. But the
@ -253,5 +196,4 @@ stdenv.mkDerivation (final: rec {
'';
license = lib.licenses.gpl3Plus;
};
})
}

63
nix/fg42/lib.nix Normal file
View File

@ -0,0 +1,63 @@
# 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/>.
{ pkgs, ... }:
final: prev:
rec {
/*
Create a value to be accessable on the Elisp side as a variable.
*/
defVar = name: defaultValue: docstring: {
inherit name defaultValue docstring;
};
/*
Create a value to be accessable on the Elisp side as a constant.
*/
defConst = defVar;
/* Creates an Option attribute set for a boolean value option i.e an
option to be toggled on or off. The option is enabled by default:
Example:
mkAndEnableOption "foo"
=> { _type = "option"; default = true; description = "Whether to enable foo."; example = true; type = { ... }; }
*/
mkAndEnableOption = name: prev.mkOption {
default = true;
example = true;
description = "Whether to enable ${name}.";
type = prev.types.bool;
};
makeFG42Drv = { pname, version, ... }@args:
(pkgs.emacsPackages.trivialBuild args).overrideAttrs (old: {
pname = "fg42-${pname}";
installPhase = ''
runHook preInstall
LISPDIR=$out/share/emacs/
install -d $LISPDIR
cp -rv lisp/ $LISPDIR/site-lisp
emacs --batch -l package --eval "(package-generate-autoloads \"${args.pname}\" \"$LISPDIR/site-lisp\")"
runHook postInstall
'';
});
}

38
nix/fg42/utils.nix Normal file
View File

@ -0,0 +1,38 @@
# 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/>.
{ emacsPackages, writeTextFile, ... }:
{
makeDesktopFile = { };
makeFG42Drv = { pname, version, ... }@args:
(emacsPackages.trivialBuild args).overrideAttrs (old: {
pname = "fg42-${pname}";
installPhase = ''
runHook preInstall
LISPDIR=$out/share/emacs/
install -d $LISPDIR
cp -rv lisp/ $LISPDIR/site-lisp
emacs --batch -l package --eval "(package-generate-autoloads \"${args.pname}\" \"$LISPDIR/site-lisp\")"
runHook postInstall
'';
});
}

71
nix/hm/default.nix Normal file
View File

@ -0,0 +1,71 @@
# 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
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.fg42;
defaultModules = pkgs.callPackage ../modules { };
in
{
meta.maintainers = [ (import ../maintainers.nix { }).lxsameer ];
options = {
enable = mkEnableOption "FG42";
extraModules = mkOption {
type = types.listOf types.submodule;
default = cfg.defaultModules ++ cfg.extraModules;
defaultText = literalExpression "[]";
example = literalExpression ''
extraModules = [
./any-fg42-module-youwant.nix
];
'';
};
modules = mkOption {
type = types.listOf types.deferredModule;
default = cfg.defaultModules ++ cfg.extraModules;
defaultText = literalExpression "[]";
example = literalExpression ''
modules = [
./any-fg42-module-youwant.nix
];
'';
};
finalPackage = mkOption {
type = types.package;
visible = false;
readOnly = true;
description = ''
The Emacs package including any overrides and extra packages.
'';
};
config = mkIf cfg.enable {
home.packages = [ cfg.finalPackage ];
programs.fg42.finalPackage = pkgs.callPackage ../fg42 {
modules = cfg.modules ++ cfg.extraModules;
};
};
};
}

View File

@ -0,0 +1,51 @@
# 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, ... }:
with lib;
let
cfg = config.fg42.auto-complete;
deps =
(with pkgs.emacsPackages; [
company
company-box
]);
drv = makeFG42Drv {
pname = "autocomplete";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
options.fg42.auto-complete.enable = mkAndEnableOption "auto-complete";
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.requires = [ drv.pname ];
fg42.vars = [
(defVar "auto-complete" cfg.enable "Auto completion for FG42.")
];
};
}

View File

@ -0,0 +1,73 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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))
(use! company
"Company is a modular text completion framework for GNU Emacs."
:hook (emacs-startup . global-company-mode)
:bind (:map company-active-map
("M-n" . company-select-next)
("M-p" . company-select-previous)
("TAB" . company-complete-common-or-cycle)
("M-d" . company-show-doc-buffer))
:init
;; Use Company for completion
(setq company-show-numbers t)
(setq company-idle-delay 0)
(setq company-tooltip-limit 20)
(setq company-echo-delay 0)
(setq company-tooltip-align-annotations t)
(setq company-dabbrev-downcase nil)
:config
(setq-default company-backends
'((company-capf :with company-yasnippet :separate)
(company-keywords :separate)
company-files))
(bind-key [remap completion-at-point] #'company-complete company-mode-map))
(use! company-box
"A company front-end with icons."
:after company
:hook (company-mode . company-box-mode))
;;;###autoload
(defun fg42/autocomplete ()
"Initialize FG42's auto complete.
This function is meant to be used with hooks."
;; Why? because if we end up with more auto completion alternatives
;; to company mode, then we can setup them here rather than walking
;; around fixing downstream modules.
(interactive)
(company-mode t))
(provide 'fg42/autocomplete)
;;; autocomplete.el ends here

View File

@ -0,0 +1,52 @@
# 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, ... }:
with lib;
let
cfg = config.fg42.c-family;
deps =
(with pkgs.emacsPackages; [
eldoc-cmake
ninja-mode
]);
drv = makeFG42Drv {
pname = "c-family";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
options.fg42.c-family.enable = mkAndEnableOption "c-family";
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.paths = (with pkgs;[
cmake-language-server
]);
fg42.requires = [ drv.pname ];
};
}

View File

@ -0,0 +1,96 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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))
(defvar fg42/clangd-args
(list
(format "-j=%s" (- (num-processors) 2))
"--clang-tidy"
"--header-insertion=iwyu"
"--pch-storage=memory"
"--background-index"
"--cross-file-rename"
"--completion-style=detailed")
"Arguments to pass to clangd.")
(use! cmake-ts-mode
"Enable cmake-ts-mode instead of the non-TS version."
:mode ("\\(?:CMakeLists\\.txt\\|\\.cmake\\)\\'" . cmake-ts-mode)
:hook
(cmake-ts-mode . fg42/autocomplete)
(cmake-ts-mode . fg42/ensure-lang-server)
(before-save . fg42/lang-server-format))
(use! eldoc-cmake
"ElDoc and cmake integration"
:hook (cmake-ts-mode . eldoc-cmake-enable))
(use! ninja-mode
"This cube enables Ninja integration with FG42. For more info checkout:
https://github.com/ninja-build/ninja/blob/master/misc/ninja-mode.el")
(defun fg42/c_cpp_ls (_)
"Return the proper lang server fo C/C++.
By default it will return `clangd' or `ccls' depends on what you have
installed. If you set `CPP_LS' env variable, then the value of that
var will be used instead. You can use `add-advice' to change the
return value of this function as well."
(let ((ls (getenv "CPP_LS")))
(if (null ls)
(eglot-alternatives `(("clangd" ,@fg42/clangd-args) ("ccls")))
(split-string ls " "))))
;;;###autoload
(defun fg42/c-ts-mode-setup ()
"A hook handler to setup cpp related configurations."
(message "[FG42][C/C++]: Make sure to setup clangd to fit your needs. For more info: https://clangd.llvm.org/config")
(fg42/ensure-lang-server)
(when (and (boundp 'eglot-managed-p) (eglot-managed-p))
(add-to-list 'eglot-server-programs
`(c++-ts-mode . ,#'fg42/c_cpp_ls))))
(use! c-ts-mode
"C++ setup. We're using treesitter version of c++ mode."
:init
;; Remap the standard C/C++ modes
(add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode))
(add-to-list 'major-mode-remap-alist '(c++-mode . c++-ts-mode))
(add-to-list 'major-mode-remap-alist '(c-or-c++-mode . c-or-c++-ts-mode))
:hook
(c++-ts-mode . fg42/autocomplete)
(c++-ts-mode . fg42/c-ts-mode-setup)
(c++-ts-mode . flyspell-prog-mode)
(before-save . fg42/lang-server-format))
(provide 'fg42/c-family)
;;; c-family.el ends here

38
nix/modules/default.nix Normal file
View File

@ -0,0 +1,38 @@
# 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.
{ pkgs, lib }:
let
modules = [
./editor
./elisp
./git
./minibuffer-vertico
./graphics
./noether
./autocomplete
./language-server
./nix
./c-family
./python
];
in
modules

View File

@ -0,0 +1,84 @@
# 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, ... }:
let
cfg = config.fg42;
deps =
(with pkgs.emacsPackages; [
origami
which-key
projectile
projectile-ripgrep
pkg-info
expand-region
direnv
helpful
envrc
pinentry
discover
exec-path-from-shell
avy
ace-window
yasnippet
yasnippet-snippets
flycheck
org
org-super-agenda
rainbow-delimiters
org-ql
org-modern
base16-theme
]);
drv = makeFG42Drv {
pname = "editor";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
dicts = pkgs.aspellWithDicts (dicts: with dicts; [ en en-computers en-science ]);
in
{
config = {
fg42.elispPackages = [ drv ] ++ deps;
fg42.fonts = (with pkgs;[
vazir-fonts
fira-mono
]);
fg42.paths = (with pkgs;[
ripgrep
dicts
direnv
]);
fg42.font = {
name = lib.mkDefault "Fira Mono";
size = 11;
};
fg42.requires = [ drv.pname ];
};
}

View File

@ -0,0 +1,300 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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)
;; We build this file via the main FG42's Nix derivation. It
;; contains the final Nix configuration of FG42.
(require 'fg42/config)
;; ;; Language support
;; (require 'fg42/autocomplete)
;; (require 'fg42/langs/langs)
;; (require 'fg42/eglot)
;; (require 'fg42/langs/cpp)
;; (require 'fg42/langs/verilog)
;; (require 'fg42/langs/python)
;; (require 'fg42/langs/elisp)
;; (require 'fg42/langs/nix)
;; (require 'fg42/wm)
(require 'fg42/organize))
(require 'server)
(require 'fg42/utils)
(defun fg42/setup-font ()
"Set the default font of `FG42' to FONT-NAME and FONT-SIZE."
(let ((name (fg42/config-get font-name))
(size (fg42/config-get font-size)))
(add-to-list 'default-frame-alist
(cons 'font (format "%s-%d" name size)))
(set-face-attribute 'default t :font name)))
(use! origami
"A text folding minor mode for Emacs."
:bind
(("C-c TAB" . origami-toggle-node))
:config
(global-origami-mode t))
(use! which-key
"which-key is a minor mode for Emacs that displays the key bindings following
your currently entered incomplete command (a prefix) in a popup. For example,
after enabling the minor mode if you enter ~C-x~ and wait for the default of
1 second the minibuffer will expand with all of the available key bindings
that follow ~C-x~ (or as many as space allows given your settings).
This includes prefixes like ~C-x 8~ which are shown in a different face."
:config
(which-key-setup-side-window-bottom)
(which-key-mode))
(use! projectile
"Projectile is a project interaction library for Emacs. Its goal is to provide
a nice set of features operating on a project level without introducing
external dependencies."
:hook (emacs-startup . projectile-mode)
:config
;; We don't want the auto discovery on startup
(setq projectile-auto-discover nil)
(setq projectile-enable-caching t)
:bind (:map projectile-mode-map
("s-p" . projectile-command-map)
("C-c p" . projectile-command-map)))
(use! projectile-ripgrep
"Use ripgrep with projectile"
:after projectile)
(use! pkg-info
"`pkg-info' integration.")
(use! expand-region
"Expand region increases the selected region by semantic units.
Just keep pressing the key until it selects what you want."
:bind ("C-=" . er/expand-region))
(use! helpful
"Helpful is an alternative to the built-in Emacs help that provides much more
contextual information."
:bind
(("C-h f" . helpful-callable)
("C-h v" . helpful-variable)
("C-h k" . helpful-key)
("C-h x" . helpful-command)
("C-c C-d" . helpful-at-point)))
(use! envrc
"Activate direnv whenever encounter a `.envrc' file"
:config
(envrc-global-mode))
(use! pinentry
"Pinentry cube with setup the =pinentry= program to be used within FG42."
:commands pinentry-start
:init
(setq epa-pinentry-mode 'loopback))
(use! imenu-list
"his Emacs minor-mode creates an automatically updated buffer
called `Ilist' that is populated with the current buffer's imenu entries.
The `Ilist' buffer is typically shown as a sidebar (Emacs vertically splits the window)."
:bind (("C-'" . imenu-list-smart-toggle)))
(use! discover
"Adds support for the discover.el `https://github.com/mickeynp/discover.el'.")
(use! exec-path-from-shell
"This package fixes the =exec-path-from-shell= issue on MacOS."
:config
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize)))
(use! hl-line
"Highlights the current line."
:hook (emacs-startup . global-hl-line-mode))
(use! avy
"This cube controls the different aspect of buffer navigation"
:bind ("M-1" . avy-goto-word-1))
(use! ace-window
"This cube controls the different aspect of buffer navigation"
:bind ("C-<tab>" . ace-window))
(when-not-wm
(use! flyspell
"Spell checking on the fly"
:commands (flyspell-mode flyspell-prog-mode)
:init
(setq-default ispell-program-name "aspell")
(setq-default ispell-extra-args '("--sug-mode=ultra"
"--lang=en_US"
"--camel-case")))
(use! savehist
"Persist history over Emacs restarts. Vertico sorts by history position."
:init
(savehist-mode))
(use! display-line-numbers
"The builtin replacement of linum. It's is pretty fast."
:config
(global-display-line-numbers-mode 1)))
(use! yasnippet
"A Snippet is a template system for Emacs. "
:config
(let* ((snippet-home
(path-join
(file-name-directory
(locate-library "yasnippet-snippets")) "snippets"))
(local-snippet (path-join (file-name-directory
(locate-library "fg42")) "../snippets"))
(user-snippets (path-join fg42/config-dir "snippets")))
(setq yas-snippet-dirs `(,user-snippets ,local-snippet ,snippet-home))
(yas-global-mode 1)))
(use! yasnippet-snippets
"Yasnippet's snippets."
:after yasnippet)
(use! flycheck
"Flycheck is a modern on-the-fly syntax checking extension for GNU Emacs."
:config (global-flycheck-mode))
(use! rainbow-delimiters
"It is a rainbow parentheses like mode which highlights delimiters such as
parentheses, brackets or braces according to their depth."
;; Enable rainbow-delimiters for programming
:hook (prog-mode . rainbow-delimiters-mode))
(use! direnv
"Direnv integration for FG42."
:config
(direnv-mode))
(defun fg42/setup-editor ()
"Setup the overall functionality 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
;; shared the same opinion or don't care at all.
(fg42/setup-font)
(add-hook 'fg42/after-init-hook
(lambda ()
(set-default 'cursor-type 'bar)
(set-cursor-color "#eeeeec")))
;; Remove splash screen
(setq inhibit-splash-screen t)
;; scratch should be scratch
(setq initial-scratch-message nil)
;; Don't allow tab as indent
(setq-default indent-tabs-mode nil)
;; Default indent width
(setq tab-width 2)
;; Share the clipboard with X applications
(setq x-select-enable-clipboard t)
;; Automatically removed excess backups of the file
(setq delete-old-versions t)
;; Emacs 28 and newer: Hide commands in M-x which do not work in the current
;; mode. Vertico commands are hidden in normal buffers. This setting is
;; useful beyond Vertico.
(setq read-extended-command-predicate #'command-completion-default-include-p)
;; Support opening new minibuffers from inside existing minibuffers.
(setq enable-recursive-minibuffers t)
(setq tooltip-use-echo-area t)
(setq x-gtk-use-system-tooltips nil)
;; Global configurations
(tool-bar-mode -1)
(tooltip-mode nil)
(menu-bar-mode -1)
(when (display-graphic-p)
;; Smoother scrolling
(pixel-scroll-precision-mode)
(scroll-bar-mode -1))
(defalias 'yes-or-no-p 'y-or-n-p)
;; It only applies to toolkit=no
(set-mouse-color (get-base16-color-or :base07 "#eeeeec"))
;; Switch from `dabbrev-expand' to `hippie-expand'
(global-set-key [remap dabbrev-expand] 'hippie-expand)
(column-number-mode t)
(show-paren-mode t)
(electric-pair-mode 1)
;; Rectangular select
(cua-selection-mode t)
;; Yank the region on type
(delete-selection-mode 1)
;; Deletel extra trailing white spaces on save
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; With this section we will have two emacs server running
;; this way we can interact with the wm via emacsclient as well
(when (not (server-running-p))
(when-wm
(setq server-name "fg42-wm"))
(server-start)
(require 'org-protocol))
(when-wm
;; Activating the WM mode
(exwm-enable)
(exwm-systemtray-enable)
(exwm-randr-enable))
(message "[FG42]: Use `fg42-help' to get help."))
(add-hook 'fg42/after-user-config-init-hook #'fg42/setup-editor)
(provide 'fg42/editor)
;;; editor.el ends here

View File

@ -24,6 +24,7 @@
(eval-when-compile
(require 'fpkg))
(defvar fg42/org-super-agenda-groups nil)
(defvar fg42/org-home "~/.orgs"
@ -153,5 +154,5 @@ For more info on ~org-mode~ check out `https://orgmode.org/'"
(org-agenda-finalize . org-modern-mode)))
(provide 'fg42/org)
;;; org.el ends here
(provide 'fg42/organize)
;;; organize.el ends here

View File

@ -0,0 +1,43 @@
# 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, ... }:
let
deps = (with pkgs.emacsPackages; [
eros
paredit
]);
drv = makeFG42Drv {
pname = "elisp";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
imports = [
../language-server
];
fg42.elispPackages = [ drv ] ++ deps;
fg42.requires = [ drv.pname ];
}

View File

@ -0,0 +1,46 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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))
(use! eros
"Evaluation Result OverlayS for Emacs Lisp."
:commands eros-mode)
(use! paredit
"Minor mode for editing parentheses."
:commands enable-paredit-mode)
(use! elisp-mode
"Elisp mode."
:hook
(emacs-lisp-mode . enable-paredit-mode)
(emacs-lisp-mode . fg42/lang-server-format)
(emacs-lisp-mode . eros-mode))
(provide 'fg42/elisp)
;;; elisp.el ends here

View File

@ -0,0 +1,53 @@
# 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, ... }:
with lib;
let
cfg = config.fg42.git;
deps =
(with pkgs.emacsPackages; [
magit
forge
diff-hl
]);
drv = makeFG42Drv {
pname = "git";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
options.fg42.git.enable = mkAndEnableOption "git";
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.paths = (with pkgs;[
git
]);
fg42.requires = [ drv.pname ];
};
}

View File

@ -0,0 +1,69 @@
# 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, ... }:
with lib;
let
cfg = config.fg42.graphics;
deps =
(with pkgs.emacsPackages; [
svg-tag-mode
nerd-icons
nerd-icons-completion
] ++ lib.optionals (cfg.emojify) [
emojify
]);
drv = makeFG42Drv {
pname = "graphics";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
emojifyDocString = "Whether or not to use the `emojify' package.";
in
{
options = (with lib; {
fg42.graphics.enable = mkAndEnableOption "graphics";
fg42.graphics.emojify = mkOption
{
type = types.bool;
default = false;
description = emojifyDocString;
};
});
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.fonts =
(with pkgs;[
(nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; })
]);
fg42.requires = [ drv.pname ];
fg42.vars = [
(lib.defVar "graphics" cfg.enable "Graphics/icons support for FG42")
(lib.defVar "emojify" cfg.emojify emojifyDocString)
];
};
}

View File

@ -22,17 +22,15 @@
;;; Commentary:
;;; Code:
(eval-when-compile
(require 'fpkg))
(require 'fpkg)
(require 'fg42/config))
(use! emojify
(use-with-config! emojify
"Adds support for emojis to `FG42'"
:if (display-graphic-p)
:hook (emacs-startup . global-emojify-mode))
(use! all-the-icons
"A utility package to collect various Icon Fonts and propertize them within
Emacs."
:if (display-graphic-p))
(use! nerd-icons
"A utility package to collect various Icon Fonts and propertize them within

View File

@ -0,0 +1,63 @@
# 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, ... }:
with lib;
let
cfg = config.fg42.language-server;
deps =
(with pkgs.emacsPackages; [
eglot
# For eldoc rendering of markdown
markdown-mode
eldoc-box
]);
drv = makeFG42Drv {
pname = "language-server";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
options.fg42.language-server.enable = mkAndEnableOption "language-server";
options.fg42.language-server.backends = mkOption {
type = types.attrsOf types.anything;
default = { };
description = ''
A map from major modes to either :lsp or :eglot.
'';
};
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.requires = [ drv.pname ];
fg42.vars = [
(defVar "language-server" cfg.enable "Is language server feature enabled.")
];
};
}

View File

@ -0,0 +1,76 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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))
;; Language Servers and friends
(use! eglot
"Eglot is a minimalistic yet powerful LSP replacement
shipped with Emacs."
:commands eglot-ensure)
(use! eldoc-box
"View eldoc stuff in a frame."
:commands eldoc-box-hover-mode
:hook (eldoc-mode . eldoc-box-hover-mode))
(use! markdown-mode
"Renders markdown in Emacs."
:init (setq markdown-command "multimarkdown"))
;;;###autoload
(defun fg42/ensure-lang-server ()
"Setup the appropriate language server for the current buffer.
This function is supposed to be run using a hook.
For example:
(add-hook 'foo-mode-hook #'fg42/enruse-lang-server)
or via `use!' `:hook'."
(interactive)
;; TODO: Configure LSP here as an alternative here by looking at
;; the configs in `fg42/config'
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t)
(eglot-ensure))
;;;###autoload
(defun fg42/lang-server-format ()
"Format the current buffer using the current language server.
This function is supposed to be run as a hook handler."
(interactive)
(cond
((and (functionp 'eglot-managed-p) (eglot-managed-p))
(eglot-format-buffer))))
(provide 'fg42/language-server)
;;; language-server.el ends here

View File

@ -0,0 +1,51 @@
# 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, ... }:
with lib;
let
cfg = config.fg42.minibuffer.vertico;
deps =
(with pkgs.emacsPackages; [
vertico
orderless
ctrlf
consult
marginalia
]);
drv = makeFG42Drv {
pname = "minibuffer-vertico";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
options.fg42.minibuffer.vertico.enable = mkAndEnableOption "vertico";
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.requires = [ drv.pname ];
};
}

View File

@ -22,7 +22,9 @@
;;; Commentary:
;;; Code:
(eval-when-compile
(require 'fpkg))
(require 'fpkg)
(require 'fg42/config))
(use! vertico
"Vertico provides a performant and minimalistic vertical completion UI
@ -36,6 +38,7 @@
(require 'vertico-indexed)
(require 'vertico-quick)
(require 'vertico-repeat)
(vertico-mode)
(vertico-multiform-mode)
;; Configure the display per command.
@ -201,14 +204,14 @@ match all of the components in any order."
:bind (("M-g e" . consult-compile-error)))
(use! nerd-icons-completion
"Nerd icons in marginalia"
:after marginalia
:config
(nerd-icons-completion-mode)
(add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup))
(with-config "graphics"
(use! nerd-icons-completion
"Nerd icons in marginalia"
:after marginalia
:config
(nerd-icons-completion-mode)
(add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)))
(provide 'fg42/minibuffer)
;;; minibuffer.el ends here
(provide 'fg42/minibuffer-vertico)
;;; minibuffer-vertico.el ends here

View File

@ -0,0 +1,59 @@
# 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, ... }:
with lib;
let
cfg = config.fg42.nix;
deps =
(with pkgs.emacsPackages; [
nix-mode
rainbow-delimiters
]);
drv = makeFG42Drv {
pname = "nix";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
imports = [
../language-server
];
options.fg42.nix.enable = mkAndEnableOption "nix";
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.paths = (with pkgs;[
nix
nixpkgs-fmt
# LSP for Nix
nil
]);
fg42.requires = [ "${drv.pname}-support" ];
};
}

View File

@ -0,0 +1,65 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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))
(use! nix-mode
"Nix language support for Emacs."
:mode ("\\.nix\\'" "\\.nix.in\\'")
:hook
(nix-mode . fg42/ensure-lang-server)
(nix-mode . fg42/autocomplete)
(nix-mode . flyspell-prog-mode)
:config
(with-eval-after-load 'eglot
;; Force nil to use nixpkgs-fmt for formatting
(let ((nil-lsp '(nix-mode . ("nil"
:initializationOptions
(:formatting (:command ["nixpkgs-fmt"]))))))
(add-to-list 'eglot-server-programs nil-lsp)
(add-hook 'before-save-hook #'fg42/lang-server-format))))
(use! nix-drv-mode
"Highlight the drv files."
:ensure nix-mode
:mode "\\.drv\\'")
(use! nix-shell
"Basic integration with Nix shells"
:ensure nix-mode
:commands (nix-shell-unpack nix-shell-configure nix-shell-build))
(use! nix-repl
"Basic integration with Nix repl"
:ensure nix-mode
:commands (nix-repl))
(provide 'fg42/nix-support)
;;; nix-support.el ends here

View File

@ -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.")
];
};
}

View File

@ -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

View File

@ -0,0 +1,120 @@
;;; 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 -1))
(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")))))
;; 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: ")))))
(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 0")
:separator ""
:timeout 10
:on-parent-resize #'fg42/adjust-modeline
:frame
(list
:poshandler #'fg42/--bottom-right-padded
:border-width 0
:font (format "%s %s" (fg42/config-get font-name) (fg42/config-get font-size))
:border-color "#bd93f9")
:units
(list
(buffer-name-unit
:label (format "%s " (nerd-icons-codicon "nf-cod-layers"))
:len 30)
(fg42/exwm-input-mode-unit :label (format "%s " (nerd-icons-faicon "nf-fa-linux")))
(date-unit :label (format "%s " (nerd-icons-codicon "nf-cod-calendar")))
(time-unit :label (format " %s " (nerd-icons-mdicon "nf-md-clock_time_three")))))
(provide 'fg42/modeline/views)
;;; views.el ends here

View File

@ -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 (list fg42/minimal-exwm))))
(provide 'fg42/noether)
;;; noether.el ends here

View File

@ -0,0 +1,63 @@
# 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, ... }:
with lib;
let
cfg = config.fg42.python-support;
deps =
(with pkgs.emacsPackages; [
poetry
python-black
]);
drv = makeFG42Drv {
pname = "python-support";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
py = pkgs.python3.withPackages (p: [
p.ipython
p.black
p.pep8
p.flake8
p.mypy
p.isort
]);
tools = (with pkgs;[
py
pyright
]);
in
{
options.fg42.python-support.enable = mkAndEnableOption "python-support";
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.paths = tools;
fg42.requires = [ drv.pname ];
};
}

View File

@ -0,0 +1,60 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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))
(use! python-black
"This cube reformats python code using black formatter tool."
:commands (python-black-on-save-mode
python-black-buffer
python-black-region
python-black-statement)
:hook (python-ts-mode . python-black-on-save-mode))
(use! poetry
"Poetry support for FG42. To use it, just use `M-x poetry'."
:config
(setq poetry-tracking-strategy 'switch-buffer)
:hook (python-mode . poetry-tracking-mode))
(use! python-ts-mode
"Python setup. We're using treesitter version of python mode."
:init
;; Remap the standard python mode
(add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode))
:config
(setq python-indent-guess-indent-offset-verbose nil)
:hook
(python-ts-mode . fg42/ensure-lang-server)
(python-ts-mode . fg42/autocomplete)
(python-ts-mode . flyspell-prog-mode))
(provide 'fg42/python-support)
;;; python-support.el ends here

View File

@ -0,0 +1,201 @@
# 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, ... }:
with lib;
let
cfg = config.fg42;
deps = (with pkgs.emacsPackages; [
treesit-grammars.with-all-grammars
]);
drv = makeFG42Drv {
pname = "unit";
version = config.fg42.version;
src = ./.;
};
in
{
options = {
fg42.version = mkOption {
type = types.str;
visible = true;
readOnly = true;
description = "FG42's version.";
};
fg42.emacs = mkOption {
type = types.package;
default = pkgs.emacs29.override ({
withTreeSitter = true;
toolkit = "no";
});
description = "What Emacs package to use.";
};
fg42.elispPackages = mkOption {
type = types.listOf types.package;
default = [ ];
description = ''
A list of Emacs packages that should be included in FG42
'';
};
fg42.paths = mkOption {
type = types.listOf types.package;
default = [ ];
description = ''
A list of packages that should be added to FG42's PATH
'';
};
fg42.mimeTypes = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
A list of mineType strings that FG42 should handle via
desktop file.
'';
};
fg42.fonts = mkOption {
type = types.listOf types.package;
default = [ ];
description = ''
A list of font packages that should be included in FG42
'';
};
fg42.font = mkOption {
type = types.submodule {
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";
};
fg42.theme = mkOption {
type = types.str;
description = "The theme name to use with FG42.";
};
fg42.theme-package-name = mkOption
{
type = types.str;
description = ''
The theme package name to use with FG42. The package should be added
to `elispPackages` already
'';
};
fg42.requires = mkOption {
type = types.listOf types.str;
description = ''
A list of Emacs packages to preload in compile time.
In general you want your entry point module in this list
to setup your autoloads, hooks, and everything.
'';
};
fg42.vars = mkOption {
type = types.listOf
(types.submodule {
options = {
name = mkOption {
type = types.str;
};
defaultValue = mkOption {
type = types.anything;
};
docstring = mkOption {
type = types.str;
};
};
});
default = [ ];
description = ''
Any element in this list will translate to an Elisp variable and will
be available to the Elisp code via the `fg42/config` interface.
'';
};
fg42.consts = mkOption {
type = types.listOf
(types.submodule {
options = {
name = mkOption {
type = types.str;
};
defaultValue = mkOption {
type = types.anything;
};
docstring = mkOption {
type = types.str;
};
};
});
default = [ ];
description = ''
Any element in this list will translate to an Elisp const and will
be available to the Elisp code via the `fg42/config` interface.
'';
};
fg42.modeline = mkOption {
type = types.enum [ "emacs" "noether" ];
default = "emacs";
description = ''
What modeline mode to ues. Options are "emacs" for a normal modeline and
"noether" to disable Emacs's modeline and replace it by the noether mode.
'';
};
};
config = {
fg42.version = import ../../version.nix { };
fg42.elispPackages = [ drv ] ++ deps;
fg42.theme = lib.mkDefault "base16-eighties";
fg42.theme-package-name = lib.mkDefault "base16-theme";
fg42.vars = [
(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 ''
The theme package name to use with FG42. The package should be added to `elispPackages` already.
'')
];
};
}

View File

@ -0,0 +1,133 @@
;;; 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 'fg42/utils)
(require 'fg42/pre)
(defvar package-archives)
(defvar use-package-ensure-function))
(defun defer-garbage-collection ()
"Disable garbage collection."
(setq gc-cons-threshold fg42/-gc-cons-threshold))
(defun restore-garbage-collection ()
"Restore garbage collection to it's default value."
(run-at-time
1 nil (lambda () (setq gc-cons-threshold most-positive-fixnum))))
(defun fg42/-startup-optimization ()
"Optimized FG42 startup."
;; by setting gc threshold to the largest number
;; Emacs can understand we are basically disabling it :).
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.6)
;; after initilization phase restore cons threshold to normal
(add-hook 'emacs-startup-hook
(lambda ()
(setq gc-cons-threshold fg42/-gc-cons-threshold ; 16mb
gc-cons-percentage 0.1)))
;; disable gc when we are in minibuffer using the same method we
;; use for initilization time
(add-hook 'minibuffer-setup-hook #'defer-garbage-collection)
;; just enable gc when exiting minibuffer
(add-hook 'minibuffer-exit-hook #'restore-garbage-collection)
;; we dont need Emacs to check every file type and look for file
;; handlers when we are initializing so we backup the original
;; value and set it to nil
(setq --file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
;; after initialization we can restore that file-name-handler-alist
;; to original value.
(add-hook 'emacs-startup-hook
(lambda ()
(setq file-name-handler-alist
--file-name-handler-alist)))
;; initial mode for emacs can be fundamental mode we have nothing to lose
(setq initial-major-mode 'fundamental-mode))
(defun fg42/initialize ()
"Initialize FG42 after the Emacs window is rendered by loading the user init file."
;; (fg42/-startup-optimization)
(run-hooks 'fg42/before-user-config-init-hook)
(require 'fg42/themes)
(when (file-exists-p user-init-file)
(load user-init-file))
(run-hooks 'fg42/after-user-config-init-hook)
(fg42/setup-theme!)
;; (fg42/setup-editor)
(add-hook 'emacs-startup-hook
(lambda ()
(run-hooks 'fg42/after-init-hook)
(run-hooks 'fg42/ui-hook)
(setq fg42/initialized t))))
(defun fg42/main ()
"The entry point of FG42."
(when (string= (getenv "FG42_DEBUG") "1")
(setq debug-on-error t
fg42/debug? t))
;; We don't use any Emacs package manager, so
;; prevent package.el to install anything at startup
(setq package-enable-at-startup nil
package-archives nil
use-package-ensure-function 'ignore
;; Setup the path for the custom.el file, We don't want
;; to touch user's Emacs configuration.
custom-file (path-join fg42/config-dir "custom.el")
;; Change the config dir to `~/.config/fg42/' by default
;; again, we don't want to temper with user's Emacs
user-emacs-directory fg42/config-dir
user-init-file
(or (getenv "FG42_CONFIG_FILE")
(path-join fg42/config-dir "fg42.el")))
;; Load the customization file. In FG42 it is different than
;; the default `user-init-file'
(if (file-exists-p custom-file)
(load custom-file))
;; From point forward we can use normal Elisp stuff without
;; interfering with user's Emacs configuration
(fg42/initialize))
(fg42/main)
(provide 'fg42)
;;; fg42.el ends here

View File

@ -0,0 +1,58 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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:
(defmacro fg42/config-get (key)
"Return the value for KEY or raise an error."
(let ((sym (intern (format "fg42/config/%s" key))))
(if (boundp sym)
`,sym
`(error "Can't find config '%s'" ,key))))
(defmacro fg42/config-get-or (key &optional default)
"Return the value for KEY or DEFAULT."
(let ((sym (intern (format "fg42/config/%s" key))))
(if (boundp sym)
`,sym
`,default)))
(defmacro with-config (name &rest body)
"Run the BODY only if the config NAME is set to t."
(declare (indent defun))
(if (string= (format "%s" (eval `(fg42/config-get-or ,name ""))) "t")
`(progn
,@body)
nil))
(defmacro if-config (name then else)
"Eval THEN if the config NAME was t, otherwise ELSE."
(declare (indent defun))
(if (string= (eval `(fg42/config-get-or ,name "")) "t")
`,then
`,else))
(provide 'fg42/config)
;;; config.el ends here

View File

@ -0,0 +1,66 @@
;;; 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:
;; ============================================================================
;; Basic inital configuration for FG42's operations
;; ============================================================================
(require 'fg42/utils)
(defgroup fg42 nil
"Customize your FG42 instance via this group of configurations."
:group :editor)
(defvar fg42/disabled-features nil
"List of features to disable.")
(defvar fg42/after-init-hook nil
"The hook tha runs when FG42 finished running the user configuration.")
(defvar fg42/debug? nil
"It is t If FG42 is running in debug mode and nil otherwise.")
(defvar fg42/-gc-cons-threshold 16777216
"Value of GC threshold of FG42.")
(defvar fg42/initialized nil
"A variable that indicates whether FG42 is passed initialization.")
(defconst fg42/cache-dir (or (getenv "FG42_CACHE_DIR")
(path-join (or (getenv "XDG_CACHE_HOME") "~/.cache")
"fg42")))
(defconst fg42/config-dir (or (getenv "FG42_CONFIG_DIR")
(path-join (or (getenv "XDG_CONFIG_HOME") "~/.config")
"fg42")))
(defvar fg42/before-user-config-init-hook nil
"A hook that runs before loading user's configuration.")
(defvar fg42/after-user-config-init-hook nil
"A hook that runs after loading user's configuration.")
(provide 'fg42/pre)
;;; pre.el ends here

View File

@ -0,0 +1,59 @@
;;; Themes --- Theme library of FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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:
;; Cubes are the building blocks of any `FG42' editor. Each `cube' is a
;; unit which defines different abilities in a deterministic and idempotent
;; way. Cubes are composable and a composition of cubes creates an editor.
;;
;;; Code:
(eval-when-compile
(require 'fpkg)
(require 'fg42/config))
(require 'fg42/utils)
(defvar fg42/ui-hook ()
"A hook that cubes can use via :ui-hook property.
It executes way before the rest of the cubes.")
(defvar fg42/before-initializing-theme-hook ()
"The hook to plug any configuration to before initialize event of themes.")
(defvar fg42/after-initializing-theme-hook ()
"The hook to plug any configuration to after initialize event of themes.")
(defmacro fg42/setup-theme! ()
"Grab the them provided by `fg42/theme' and load it.
Load the theme via `use!' and pass the BODY to the `use!' macroro.
If the theme name and the theme package name are different the package
name can be set via `fg42/theme-package'."
`(use! ,(intern (fg42/config-get-or theme-package-name (fg42/config-get theme)))
"Setting up the ,pkg package."
:config
(progn
(load-theme ',(intern (fg42/config-get theme)) t))))
(provide 'fg42/themes)
;;; themes.el ends here

View File

@ -0,0 +1,161 @@
;;; Utils --- Utils library of FG42 -*- 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:
;; `System' is just a state monad which holds the state of the editor.
;; Each system has to have a `start' function to start the setup process.
;;
;;; Code:
(require 'cl-lib)
(autoload 'seq-partition "seq")
(autoload 'cl-reduce "cl-seq")
(defun buffer-mode (buffer-or-string)
"Return the major mode associated with a the given BUFFER-OR-STRING."
(with-current-buffer buffer-or-string
major-mode))
(defun ->buffer (buffer-name data &optional fn)
"Insert the given DATA into the given buffer provided by BUFFER-NAME.
It will create a the buffer if it doesn't exist. It will call the given FN
at the end in context of the buffer. This function accepts only one argument
with is the buffer."
(let ((buf (get-buffer-create buffer-name)))
(with-current-buffer buf
(insert data)
(when fn
(funcall fn buf)))))
(defun ->str (&rest args)
"Convert the given ARGS into string."
(funcall #'pp-to-string args))
(defmacro inspect-expression (&rest body)
"Pretty prints the result of the given BODY."
`(pp-display-expression ,@body (get-buffer-create fg42/inspect-buffer)))
(defun inspect-data-append (data)
"Append the given DATA to the inspection buffer with padding."
;; TODO: Move 'fg42/inspect-buffer' to the somewhere propriate
;; possiblly the system.
(->buffer
"fg42/inspect-buffer"
(format
"\n;; START ======================================================\n%s%s"
(pp-to-string data)
";; END.\n")))
(defun apply-face (face-symbol text)
"Apply the given FACE-SYMBOL to the given TEXT."
(put-text-property 0 (length text) 'face face-symbol text))
(defmacro comment (&rest _body)
"A macro similar to Clojure's comment macro that ignore the BODY."
(declare (indent 0))
`nil)
(defmacro debug-message (&rest params)
"Print out the given PARAMS only if debug mode is on."
(if debug-on-error
`(message ,@params)
nil))
(defmacro deprecated (msg &rest form)
"Mark the given FORM as deprecated with the given MSG."
(declare (indent 0))
`(progn
(warn (format "[DEPRECATED]: %s" ,msg))
,@form))
(defun path-join (&rest paths)
"Join the given PATHS."
(apply #'concat
(append
(mapcar #'file-name-as-directory (butlast paths))
(last paths))))
(defmacro -> (x &optional form &rest more)
"Thread the expr through the forms FORM and rest of form in MORE.
Insert X as the second item in the first form, making a list of
it if it is not a list already. If there are more forms, insert
the first form as the second item in second form, etc."
(declare (debug (form &rest [&or symbolp (sexp &rest form)])))
(cond
((null form) x)
((null more) (if (listp form)
`(,(car form) ,x ,@(cdr form))
(list form x)))
(:else `(-> (-> ,x ,form) ,@more))))
(defmacro ->> (x &optional form &rest more)
"Thread the expr through the forms FORM and the rest at MORE.
Insert X as the last item in the first form, making a list of
it if it is not a list already. If there are more forms, insert
the first form as the
last item in second form, etc."
(declare (debug ->))
(cond
((null form) x)
((null more) (if (listp form)
`(,@form ,x)
(list form x)))
(:else `(->> (->> ,x ,form) ,@more))))
(defmacro when-wm (&rest body)
"Run the BODY only if in wm mode."
(if (string= (getenv "FG42_WM") "true")
`(progn ,@body)
nil))
(defmacro when-not-wm (&rest body)
"Run the BODY only if not in the wm mode."
(if (not (string= (getenv "FG42_WM") "true"))
`(progn ,@body)
nil))
(defun get-base16-color-or (color-name default)
"Return the color for COLOR-NAME if a base16 theme is loade otherwise DEFAULT."
(let* ((theme (car custom-enabled-themes))
(theme-sym (intern (format "%s-theme-colors" theme))))
(if (boundp theme-sym)
(or (eval `(plist-get ,theme-sym ,color-name)) default)
default)))
(provide 'fg42/utils)
;;; utils.el ends here

View File

@ -0,0 +1,78 @@
;;; fpkg --- a simple package manager for FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; Keywords: lisp fg42 IDE package manager
;; Version: 1.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:
;;
;; Simple package manager for FG42
;;
;;; Code:
(require 'map)
(eval-when-compile
(require 'fg42/config))
(defvar package-names ())
(eval-when-compile
(defvar fg42/disabled-features '())
(require 'use-package))
(defun inject-params (args)
"Inject required `use-package' params to ARGS if the key is missing."
;; (if (member :defer args)
;; (append '(:ensure nil) args)
(append args '(:ensure nil)))
(defmacro fpkg/use (pkg &rest details)
"Install the given package DETAILS PKG via `use-package' and straight."
(declare (indent defun))
(if (and (listp details) (< 0 (length details)))
(let ((p (inject-params details)))
`(use-package ,pkg ,@p))
`(use-package ,pkg :defer t :ensure nil)))
(defmacro use! (pkg docs &rest details)
"Loading the given package DETAILS PKG via `use-package'.
DOCS is the documentation of the package."
(declare (indent defun) (doc-string 2))
(when (not (stringp docs))
(error "Missing docstring for '%s' package" pkg))
(let ((disabled (member pkg fg42/disabled-features)))
(when (null disabled)
`(use-package ,pkg ,@details))))
(defmacro use-with-config! (name docs &rest details)
"A wrapper around `use!' that only activates if a config NAME is set.
It passes NAME, DOCS, and DETAILS to `use!' only if a config with the
same NAME is set to t."
(declare (indent defun) (doc-string 2))
`(with-config ,name
(use! ,name ,docs ,@details)))
(provide 'fpkg)
;;; fpkg.el ends here

View File

@ -13,44 +13,39 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ lib
, stdenv
, emacs29
, callPackage
, writeShellApplication
, noether
, emacsParams ? { }
, fg42Params ? { }
}:
# 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, ... }:
with lib;
let
lemacs = emacs29.override ({
withTreeSitter = true;
} // emacsParams);
cfg = config.fg42.wm;
elispDepsFile = ../lisp/fg42/deps.el;
deps =
(with pkgs.emacsPackages; [
exwm
]);
elispPkgs = callPackage ./deps.nix {
inherit elispDepsFile;
};
ourPackages = {
noether-mode = noether;
};
fg42 = callPackage ./fg42.nix ({
inherit elispPkgs ourPackages;
srcDir = ../.;
emacs = lemacs;
} // fg42Params);
run-test-wm = writeShellApplication {
name = "run-test-wm";
runtimeInputs = [ fg42 ];
text = ''
DISPLAY=:1 ${fg42}/bin/fg42-wm
'';
drv = makeFG42Drv {
pname = "wm";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{ inherit fg42 run-test-wm; }
{
options.fg42.wm.enable = mkAndEnableOption "wm";
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.paths = (with pkgs;[
dunst
]);
fg42.requires = [ drv.pname ];
};
}

View File

@ -0,0 +1,174 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; 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))
(defvar workspace-configuration
(list 0 "HDMI-1"
1 "HDMI-1"
2 "HDMI-1"
3 "HDMI-1"
4 "HDMI-1"
5 "HDMI-1"
6 "HDMI-1"
7 "HDMI-1"
8 "HDMI-1"
9 "HDMI-1")
"Workspace configuration for EXWM. (default 10 screens on HDMI-1).")
;; TODO: Document this
;; (add-hook 'exwm-randr-screen-change-hook
;; (lambda ()
;; (start-process-shell-command
;; "xrandr" nil "xrandr --output HDMI-1 --above eDP-1 --mode 1920x1080")))
(when-wm
(use! exwm-randr
"EXWM plugin to interact with xrandr."
:commands exwm-randr-enable
:config
(setq exwm-randr-workspace-output-plist workspace-configuration))
(use! exwm-systemtray
"Enables systemtray on EXWM"
:commands exwm-systemtray-enable)
;; (use! mini-frame
;; "Place minibuffer at the top of the current frame on `read-from-minibuffer'."
;; :hook (emacs-startup . mini-frame-mode)
;; :custom
;; (mini-frame-show-parameters
;; '((top . 10)
;; (width . 0.5)
;; (left . 0.5)
;; (height . 15))))
(use! exwm
"Emacs X Widnow manager."
:commands exwm-enable
:config
(require 'exwm-config)
(exwm-config-ido)
;; Set the initial number of workspaces (they can also be created later).
(setq exwm-workspace-number 10)
;; All buffers created in EXWM mode are named "*EXWM*". You may want to
;; change it in `exwm-update-class-hook' and `exwm-update-title-hook', which
;; are run when a new X window class name or title is available. Here's
;; some advice on this topic:
;; + Always use `exwm-workspace-rename-buffer` to avoid naming conflict.
;; + For applications with multiple windows (e.g. GIMP), the class names of
;; all windows are probably the same. Using window titles for them makes
;; more sense.
;; In the following example, we use class names for all windows except for
;; Java applications and GIMP.
(add-hook 'exwm-update-class-hook
(lambda ()
(unless (or (string-prefix-p "sun-awt-X11-" exwm-instance-name)
(string= "gimp" exwm-instance-name))
(exwm-workspace-rename-buffer exwm-class-name))))
(add-hook 'exwm-update-title-hook
(lambda ()
(when (or (not exwm-instance-name)
(string-prefix-p "sun-awt-X11-" exwm-instance-name)
(string= "gimp" exwm-instance-name))
(exwm-workspace-rename-buffer exwm-title))))
;; Global keybindings can be defined with `exwm-input-global-keys'.
;; Here are a few examples:
(setq exwm-input-global-keys
`(
;; Bind "s-r" to exit char-mode and fullscreen mode.
([?\s-r] . exwm-reset)
([?\s-g] . keyboard-quit)
([8388640] . other-window)
;; Bind "s-w" to switch workspace interactively.
([?\s-w] . exwm-workspace-switch)
;; Bind "s-0" to "s-9" to switch to a workspace by its index.
,@(mapcar (lambda (i)
`(,(kbd (format "s-%d" i)) .
(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
(number-sequence 0 9))
;; Bind "s-&" to launch applications ('M-&' also works if the output
;; buffer does not bother you).
([?\s-d] . (lambda (command)
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command)))
;; Bind "s-<f2>" to "slock", a simple X display locker.
([s-f2] . (lambda ()
(interactive)
(start-process "" nil "slock")))))
;; To add a key binding only available in line-mode, simply define it in
;; `exwm-mode-map'. The following example shortens 'C-c q' to 'C-q'.
(define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key)
(push ?\C-c exwm-input-prefix-keys)
;; You can hide the minibuffer and echo area when they're not used, by
;; uncommenting the following line.
;;(setq exwm-workspace-minibuffer-position 'bottom)
;; The following example demonstrates how to use simulation keys to mimic
;; the behavior of Emacs. The value of `exwm-input-simulation-keys` is a
;; list of cons cells (SRC . DEST), where SRC is the key sequence you press
;; and DEST is what EXWM actually sends to application. Note that both SRC
;; and DEST should be key sequences (vector or string).
(setq exwm-input-simulation-keys
`(
;; movement
(,(kbd "C-b") . left)
(,(kbd "M-b") . ,(kbd "C-<left>"))
(,(kbd "C-f") . right)
(,(kbd "M-f") . ,(kbd "C-<right>"))
(,(kbd "C-p") . up)
(,(kbd "C-n") . down)
(,(kbd "C-a") . home)
(,(kbd "C-e") . end)
(,(kbd "M-v") . prior)
(,(kbd "C-v") . next)
(,(kbd "C-d") . delete)
;;(,(kbs "C-k") . [S-end delete])
;; navigation
(,(kbd "C-c b") . ,(kbd "M-<left>"))
(,(kbd "C-c f") . ,(kbd "M-<right>"))
(,(kbd "C-c w") . ,(kbd "C-w"))
(,(kbd "C-w") . ,(kbd "C-x"))
(,(kbd "M-w") . ,(kbd "C-c"))
(,(kbd "C-y") . ,(kbd "C-v"))
;; search
(,(kbd "C-s") . ,(kbd "C-f"))))))
(provide 'fg42/wm)
;;; wm.el ends here

20
nix/version.nix Normal file
View File

@ -0,0 +1,20 @@
# 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
_: "4.0.0"