forked from FG42/FG42
1
0
Fork 0

Refactor the configuration and replace all the cubes with the editor meta cube

This commit is contained in:
Sameer Rahmani 2023-05-31 23:37:58 +01:00
parent 8d67672291
commit 6e5ab5d150
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
15 changed files with 136 additions and 165 deletions

View File

@ -81,7 +81,7 @@ PARAMS:
((string= commad "compile")
(do-command
(native-compile-async fg42/CORE_DIR 'recursively)
(native-compile-async "~/.fg42.v3.el")
(native-compile-async "~/.fg42.el")
(print "Compiling FG42 files ...")
(while (or comp-files-queue

View File

@ -1,29 +1,6 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2020 Sameer Rahmani <lxsameer@gnu.org>
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://gitlab.com/FG42/FG42
;; Version: 3.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:
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2020 Sameer Rahmani <lxsameer@gnu.org>
;; Copyright (c) 2010-2023 Sameer Rahmani <lxsameer@gnu.org>
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://gitlab.com/FG42/FG42
@ -49,49 +26,13 @@
;; (setq debug-on-error t)
(require 'fg42/flags)
(require 'cubes/editor)
(require 'cubes/org)
(require 'cubes/elisp)
(require 'cubes/region-expansion)
(require 'cubes/wm)
(require 'cubes/modeline)
(require 'cubes/autocompletion)
(require 'cubes/golang)
(require 'cubes/project)
(require 'cubes/irc)
(require 'cubes/terminal)
(require 'cubes/java)
(require 'cubes/python)
(require 'cubes/cpp)
(require 'cubes/snippets)
(require 'cubes/git)
(require 'cubes/bookmark)
(require 'cubes/terraform)
(require 'cubes/graph)
(require 'cubes/clojure)
(require 'cubes/fg42)
(defvar global-font-size 12)
(custom-set-faces
'(mini-modeline-mode-line
((((background light))
:background "#aa0000" :height 0.1 :box nil)
(t
:background "#bd93f9" :height 0.1 :box nil))))
(use-flags
(fg42/merge-with-default-flags
wm
python
golang
rcirc
vterm
company
lsp
flycheck
fg42/region-expansion-cube))
@ -106,39 +47,22 @@
:background "#6272a4" :height 0.1 :box nil))))
(fg42/wm-cube :number-of-workspaces 9)
;; Uncomment the following section if need a easy way to control the resolution
;; Change the resolution and monitors to your need
(defvar monitors
'(:hdmi-only
("--output HDMI-1 --primary"
"--output eDP-1 --off")
:hdmi-main
("--output HDMI-1 --primary"
"--output eDP-1 --mode 1920x1080 --left-of HDMI-1")
:edp-only
("--output eDP-1 --mode 1920x1080"
"--output HDMI-1 --off")))
(require 'seq)
(defun monitor-profiles ()
(mapcar
#'car
(seq-partition monitors 2)))
(defun monitor (mon)
(interactive
(list (completing-read
"Monitor Profole: "
(monitor-profiles))))
(let ((cmd (mapconcat (lambda (x) (format "xrandr %s" x))
(plist-get monitors (intern (format "%s" mon)))
" && ")))
(message "Setting monitor profile: %s" cmd)
(async-shell-command cmd "*xrandr*")))
(comment
;; how to run it via elisp
(monitor :hdmi-only))
;; (require 'fg42/x)
;; (setq fg42/monitors
;; '(:hdmi-only
;; ("--output HDMI-1 --primary"
;; "--output eDP-1 --off")
;; :hdmi-main
;; ("--output HDMI-1 --primary"
;; "--output eDP-1 --mode 1920x1080 --left-of HDMI-1")
;; :edp-only
;; ("--output eDP-1 --mode 1920x1080"
;; "--output HDMI-1 --off")))
;; (comment
;; ;; how to run it via elisp or just `M-x monitor'
;; (monitor :hdmi-only))
(use-flags
@ -155,45 +79,12 @@
fg42/region-expansion-cube)))
;; Both are part of the editor cube but we want to override
;; their behavior
(fg42/org-cube)
(fg42/cursor-cube :type 'bar :color "#bd93f9")
(fg42/font-cube :font-name "Fira code" :font-size global-font-size)
(fg42/editor-cube)
;;(fg42/imenu-cube)
(fg42/elisp-cube)
(fg42/region-expansion-cube)
(fg42/graphviz-cube)
(fg42/company-cube)
(fg42/lsp-cube)
(fg42/c++-cube)
(fg42/python-cube)
(fg42/yaml-cube)
(fg42/flycheck-cube)
(fg42/golang-cube)
(fg42/clojure-cube)
(fg42/projectile-cube)
(fg42/vterm-cube)
(fg42/git-cube)
(fg42/alert-cube)
(fg42/bookmark-cube)
(fg42/terraform-cube)
(fg42/java-cube)
(fg42/yasnippet-cube)
;; Themes should be the last cube and anything that wants to manipulate a face
;; has to use either `fg42/before-initializing-theme-hook' or
;; `fg42/after-initializing-theme-hook' hooks.
(fg42/dracula-theme-cube)
(set-face-attribute 'region nil :background "#888")
(fg42/editor
:fg42/cursor-cube '(:type 'bar :color "#bd93f9")
:fg42/font-cube '(:font-name "Fira code" :font-size global-font-size))
(when (file-exists-p "~/.fg42.user.el")
(load "~/.fg42.user.el"))
(provide 'fg42.user)
;;; fg42.user.el ends here
(provide '.fg42)
;;; .fg42.el ends here

View File

@ -27,7 +27,8 @@
(defcube fg42/flycheck-cube
"This cube adds the `flycheck' support to fg42."
(:title "Flycheck cube"
:flag flycheck)
:flag flycheck
:flag-default t)
(fpkg/use flycheck
:defer ()
:init
@ -44,7 +45,8 @@
(defcube fg42/lsp-cube
"LSP cube"
(:title "LSP cube"
:flag lsp)
:flag lsp
:flag-default t)
(fpkg/use lsp-mode
:commands lsp
@ -65,7 +67,8 @@
(defcube fg42/company-cube
"Auto complete using company mode"
(:title "Company cube"
:flag company)
:flag company
:flag-default t)
(fpkg/use company
:bind (:map company-active-map

View File

@ -27,6 +27,7 @@
(require 'fg42/utils)
(require 'fg42/modeline)
(require 'cubes/modeline)
(require 'fg42/themes)
(defflag font-icons
"Enable the support for font icones in FG42." t)
@ -184,7 +185,6 @@ data. The typical example of this would be Lisp or Scheme source code."
(:title "Font Cube"
:no-flag t
:flag-default t)
(let ((font (or (plist-get fg42/font-cube-params :font-name)
"Fira Mono"))
(size (or (plist-get fg42/font-cube-params :font-size)
@ -202,8 +202,6 @@ data. The typical example of this would be Lisp or Scheme source code."
"Replace this with a theme cube"
(:title "Dracula theme"
:no-flag t)
(require 'fg42/themes)
(fpkg/use dracula-theme
:init
@ -216,7 +214,8 @@ data. The typical example of this would be Lisp or Scheme source code."
'(all-the-icons-faicon ((t (:background "#bd93f9"))))
'(font-lock-comment-face ((t (:foreground "#8B9298"))))
'(font-lock-comment-delimiter-face ((t (:foreground "#5B6268")))))
(enable-theme 'dracula))))
(enable-theme 'dracula)
(set-face-attribute 'region nil :background "#888"))))
(defcube fg42/badwolf-theme-cube
"Badwolf theme cube. An Emacs port of Bad Wolf theme for Vim.
@ -326,19 +325,7 @@ https://emacsthemes.com/themes/badwolf-theme.html"
#'fg42/default-modeline)))
;;(fg42/statusbar-cube)
(fg42/modeline-cube)
(fg42/setup-modeline-format mline))
(fg42/emojify-cube)
(fg42/discover-cube)
(fg42/folding-cube)
(fg42/font-cube)
(fg42/pinentry-cube)
(fg42/exec-path-cube)
(fg42/buffer-navigation-cube)
(fg42/window-navigation-cube)
(fg42/selectrum-cube)
(fg42/cursor-cube)
(fg42/hl-cube))
(fg42/setup-modeline-format mline)))
(provide 'cubes/editor)

76
core/cubes/fg42.el Normal file
View File

@ -0,0 +1,76 @@
;;; FG42Cube --- The meta cube for FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2023 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://ziglab.com/FG42/FG42
;; Version: 3.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:
(require 'fg42/cube)
(require 'fg42/utils)
(require 'cubes/editor)
(require 'cubes/org)
(require 'cubes/elisp)
(require 'cubes/region-expansion)
(require 'cubes/wm)
(require 'cubes/modeline)
(require 'cubes/autocompletion)
(require 'cubes/golang)
(require 'cubes/project)
(require 'cubes/irc)
(require 'cubes/terminal)
(require 'cubes/java)
(require 'cubes/python)
(require 'cubes/cpp)
(require 'cubes/snippets)
(require 'cubes/rust)
(require 'cubes/mastodon)
(require 'cubes/git)
(require 'cubes/bookmark)
(require 'cubes/terraform)
(require 'cubes/graph)
(require 'cubes/clojure)
(require 'cubes/scheme)
(require 'cubes/meson)
(require 'cubes/godot3d)
(require 'cubes/meissa)
(require 'cubes/proof)
(require 'cubes/agda)
(require 'cubes/notifications)
(defcube fg42/editor
"A meta cube that contains all the cubes in the system. Calling
This cube is enough to load everything and control what cube to execute
via flags."
(:title "Editor cube"
:flag-default t
:flag fg42-editor-cube)
(mapc
(lambda (cube)
(let ((params (plist-get fg42/editor-params
(intern (concat ":" (symbol-name cube))))))
(eval `(funcall #',cube ,@params))))
fg42/available-cubes))
(provide 'cubes/fg42)
;;; fg42.el ends here

View File

@ -29,7 +29,8 @@
(defcube fg42/golang-cube
"Golang support cube for fg42."
(:title "Golang cube" :flag golang)
(:title "Golang cube" :flag golang
:flag-default t)
(fpkg/use go-mode
:defer t

View File

@ -25,6 +25,7 @@
(require 'fg42/cube)
(require 'fg42/utils)
(defcube fg42/groovy-cube
"Groovy support for FG42."
(:title "Groovy cube"

View File

@ -41,7 +41,7 @@ For more info on check out [[https://codeberg.org/martianh/mastodon.el]]"
(:title "Mastodone Cube"
:flag mastodon
:flag-default t)
:flag-default nil)
(let ((url (or (plist-get fg42/mastodon-cube-params :instance-url)
(error "Instance url is empty set the `:instance-url' key")))

View File

@ -79,7 +79,15 @@
(setq fg42/modeline-setter #'fg42/mini-modeline-setter))
:defer nil
:config
(add-hook 'fg42-after-init-hook #'mini-modeline-mode)))
(add-hook 'fg42-after-init-hook #'mini-modeline-mode)
(add-hook 'fg42/after-initializing-theme-hook
(lambda ()
(custom-set-faces
'(mini-modeline-mode-line
((((background light))
:background "#aa0000" :height 0.1 :box nil)
(t
:background "#bd93f9" :height 0.1 :box nil))))))))
(defcube fg42/statusbar-cube
@ -89,7 +97,7 @@ valuable information."
(:title "Status bar cube"
:flag status-bar
:group modeline
:flag-default t)
:flag-default nil)
(fg42/all-the-icons-cube)

View File

@ -69,7 +69,8 @@ interactive `pyvenv-workon' function before `lsp'"
(defcube fg42/python-cube-pyls
"Python language server using pyls"
(:title "Python lang server via pyls"
:flag python-pyls)
:flag python-pyls
:flag-default nil)
(when-flag lsp
(with-eval-after-load "lsp"
@ -85,7 +86,8 @@ interactive `pyvenv-workon' function before `lsp'"
(defcube fg42/python-cube-pyright
"Python language server using pyright."
(:title "Python lang server via pyright"
:flag python-pyright)
:flag python-pyright
:flag-default t)
(fpkg/use lsp-pyright
:ensure t
@ -112,7 +114,8 @@ interactive `pyvenv-workon' function before `lsp'"
(defcube fg42/python-cube
"Python support cube."
(:title "Python cube"
:flag python)
:flag python
:flag-default t)
(fpkg/use pyvenv
:defer t

View File

@ -30,7 +30,7 @@
(defvar fg42/after-cubes-setup-hook nil
"A hook that will be run after all the active cubes got setup.
This hook is dedicated for the codes that needs to do stuff based on other cubes
This hook is dedicated for the codes that need to do stuff based on other cubes
presence. With this hook we eliminate the need for cube ordering.
It will be called in the `fg42-config' and the proper way to use
@ -88,7 +88,7 @@ it is to use `fg42/after-cubes' macro.")
;; * Hooks
;; This hook can be used by others to run code just before running that
;; code body
;; cube's body
(defvar ,pre-init-hook nil
,(format "The hook that runs befor the '%s' cube initialization." cube-name))
@ -98,7 +98,6 @@ it is to use `fg42/after-cubes' macro.")
(defvar ,post-init-hook nil
,(format "The hook that runs after the '%s' cube initialization." cube-name))
;; TODO: Move language server related hooks to lang-server
;; TODO: Provide a way to let different parts of the
;; codebase to create cube hooks

View File

View File

@ -37,9 +37,9 @@
(defmacro fg42/setup-theme (&rest body)
"Run the BODY inside the FG42 theme setup context."
`(progn
;; TODO: This is a bad practice. Find a better solution
(run-hooks 'fg42/before-initializing-theme-hook)
,@body
(run-hooks 'fg42/after-initializing-theme-hook)))
,@body))
(provide 'fg42/themes)

View File

@ -60,5 +60,6 @@
(load bootstrap-file nil 'nomessage)
(fpkg/install-and-load-use-package)))
(provide 'fpkg/core)
;;; core.el ends here

View File

@ -38,7 +38,7 @@
(getenv "HOME")))
;; Load the custom ization file. In FG42 it is different than
;; Load the customization file. In FG42 it is different than
;; the default `user-init-file'
(if (file-exists-p custom-file)
(load custom-file))
@ -50,6 +50,7 @@
(run-hooks 'fg42/after-cubes-setup-hook)
(run-hooks 'fg42-after-init-hook)
(run-hooks 'fg42/after-initializing-theme-hook)
(provide 'fg42-config)
;;; fg42-config.el ends here