2021-05-02 22:47:01 +01:00
|
|
|
;;; EditorCubes --- The common cubes for FG42 -*- lexical-binding: t; -*-
|
2021-03-08 14:10:13 +00:00
|
|
|
;;
|
2024-02-18 16:08:02 +00:00
|
|
|
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
|
2021-03-08 14:10:13 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
2022-12-19 21:07:48 +00:00
|
|
|
;; URL: https://devheroes.codes/FG42/FG42
|
2021-03-08 14:10:13 +00:00
|
|
|
;; 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:
|
2021-07-02 15:48:30 +01:00
|
|
|
(require 'server)
|
2021-03-08 14:10:13 +00:00
|
|
|
(require 'fpkg)
|
|
|
|
(require 'fg42/cube)
|
2021-12-11 14:56:57 +00:00
|
|
|
(require 'fg42/utils)
|
|
|
|
(require 'fg42/modeline)
|
2024-02-18 16:06:30 +00:00
|
|
|
(require 'fg42/cubes/modeline)
|
2023-05-31 23:37:58 +01:00
|
|
|
(require 'fg42/themes)
|
2023-07-21 10:46:16 +01:00
|
|
|
(require 'fg42/project)
|
2021-03-08 14:10:13 +00:00
|
|
|
|
2021-04-21 19:42:09 +01:00
|
|
|
(defflag font-icons
|
2021-05-07 16:03:33 +01:00
|
|
|
"Enable the support for font icones in FG42." t)
|
2021-03-08 14:10:13 +00:00
|
|
|
|
2021-04-21 19:42:09 +01:00
|
|
|
|
2021-07-02 15:48:30 +01:00
|
|
|
(defflag server
|
|
|
|
"Enable the support for server mode in FG42." t)
|
|
|
|
|
|
|
|
|
2022-06-27 23:37:51 +01:00
|
|
|
(defcube fg42/folding-cube
|
|
|
|
"This cube install ~origami~ which let you collapse and expand regions of text.
|
|
|
|
|
|
|
|
For more info checkout [[https://github.com/gregsexton/origami.el]]"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Folding cube"
|
|
|
|
:flag folding
|
|
|
|
:flag-default t
|
2022-06-27 23:37:51 +01:00
|
|
|
(fpkg/use origami
|
|
|
|
:bind
|
|
|
|
(("C-c TAB" . origami-toggle-node))
|
|
|
|
:config
|
|
|
|
(global-origami-mode t)))
|
|
|
|
|
|
|
|
|
2023-06-01 01:11:00 +01:00
|
|
|
(->cube dirvish
|
|
|
|
"Dirvish is an improved version of the Emacs inbuilt package Dired.
|
|
|
|
It not only gives Dired an appealing and highly customizable user interface,
|
|
|
|
but also comes together with almost all possible parts required for full usability
|
|
|
|
as a modern file manager."
|
|
|
|
:init
|
|
|
|
(dirvish-override-dired-mode))
|
|
|
|
|
|
|
|
|
2023-06-01 00:42:57 +01:00
|
|
|
(->cube 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."
|
|
|
|
:init
|
|
|
|
(require 'which-key)
|
|
|
|
:config
|
|
|
|
(which-key-setup-side-window-bottom)
|
|
|
|
(which-key-mode))
|
|
|
|
|
|
|
|
|
2023-06-01 00:25:05 +01:00
|
|
|
(->cube helpful
|
2023-06-01 00:42:57 +01:00
|
|
|
"Helpful is an alternative to the built-in Emacs help that provides much more
|
|
|
|
contextual information."
|
2023-06-01 00:25:05 +01:00
|
|
|
:init
|
|
|
|
(require 'helpful)
|
|
|
|
:config
|
|
|
|
(global-set-key (kbd "C-h f") #'helpful-callable)
|
|
|
|
(global-set-key (kbd "C-h v") #'helpful-variable)
|
|
|
|
(global-set-key (kbd "C-h k") #'helpful-key)
|
|
|
|
(global-set-key (kbd "C-h x") #'helpful-command)
|
|
|
|
(global-set-key (kbd "C-c C-d") #'helpful-at-point))
|
|
|
|
|
|
|
|
|
2021-05-06 09:29:34 +01:00
|
|
|
(defcube fg42/pinentry-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"Pinentry cube with setup the =pinentry= program to be used within FG42."
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Pinentry cube"
|
|
|
|
:flag pinentry
|
|
|
|
:flag-default t
|
2021-05-06 09:29:34 +01:00
|
|
|
(fpkg/use pinentry
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq epa-pinentry-mode 'loopback)
|
|
|
|
(pinentry-start))))
|
|
|
|
|
2022-10-31 13:32:26 +00:00
|
|
|
|
2021-08-29 19:44:18 +01:00
|
|
|
(defcube fg42/imenu-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"Imenu support"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Imenu cube"
|
|
|
|
:flag imenu
|
|
|
|
:flag-default t
|
2021-08-29 19:44:18 +01:00
|
|
|
(fpkg/use imenu-list
|
|
|
|
:init
|
|
|
|
(global-set-key (kbd "C-'") #'imenu-list-smart-toggle)))
|
|
|
|
|
2022-10-31 13:32:26 +00:00
|
|
|
|
2021-10-12 00:56:20 +01:00
|
|
|
(defcube fg42/alert-cube
|
|
|
|
"alert support"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Alert cube"
|
|
|
|
:flag alert
|
|
|
|
:flag-default t
|
2021-10-12 00:56:20 +01:00
|
|
|
(fpkg/use alert))
|
|
|
|
|
2021-05-06 09:29:34 +01:00
|
|
|
|
2022-10-31 13:32:26 +00:00
|
|
|
(defcube fg42/emojify-cube
|
|
|
|
"Adds support for emojis to *FG42*"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Emojify cube"
|
|
|
|
:flag emoji
|
|
|
|
:flag-default t
|
2022-10-31 13:32:26 +00:00
|
|
|
(fpkg/use emojify
|
|
|
|
:hook (after-init . global-emojify-mode)))
|
|
|
|
|
2022-10-31 13:32:54 +00:00
|
|
|
|
|
|
|
(defcube fg42/discover-cube
|
|
|
|
"Adds support for the [[https://github.com/mickeynp/discover.el][discover]]"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Discover cube"
|
|
|
|
:flag discover
|
|
|
|
:flag-default t
|
2022-10-31 13:32:54 +00:00
|
|
|
(fpkg/use discover))
|
|
|
|
|
|
|
|
|
2021-05-04 10:16:39 +01:00
|
|
|
(defcube fg42/exec-path-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"This cube fixes the =exec-path-from-shell= issue on MacOS."
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Exec path cube"
|
|
|
|
:flag exec-path-from-shell
|
|
|
|
:flag-default t
|
2021-05-04 10:16:39 +01:00
|
|
|
(fpkg/use exec-path-from-shell
|
|
|
|
:init
|
|
|
|
(when (memq window-system '(mac ns x))
|
|
|
|
(exec-path-from-shell-initialize))))
|
|
|
|
|
|
|
|
|
2021-08-29 19:44:18 +01:00
|
|
|
(defcube fg42/hl-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"This cube highlight the curret line."
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Current line highlight cube"
|
|
|
|
:flag hl-line
|
|
|
|
:flag-default t
|
2021-08-29 19:44:18 +01:00
|
|
|
(require 'hl-line)
|
|
|
|
(global-hl-line-mode))
|
|
|
|
|
|
|
|
|
2022-12-02 22:35:04 +00:00
|
|
|
(defcube fg42/rainbow-delimiters-cube
|
|
|
|
"rainbow-delimiters is a =rainbow parentheses= like mode which highlights delimiters
|
|
|
|
such as parentheses, brackets or braces according to their depth. Each successive level
|
|
|
|
is highlighted in a different color. This makes it easy to spot matching delimiters,
|
|
|
|
orient yourself in the code, and tell which statements are at a given depth."
|
|
|
|
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Rainbow Delimiters Cube"
|
|
|
|
:flag rainbow-delimiters
|
|
|
|
:flag-default t
|
2022-12-02 22:35:04 +00:00
|
|
|
|
|
|
|
(fpkg/use rainbow-delimiters
|
|
|
|
;; It doesn't work due to a problem/conflict in rainbow-delimiters
|
|
|
|
;; But we use it any way they might fix it
|
|
|
|
:hook (prog-mode . rainbow-delimiters-mode)))
|
|
|
|
|
|
|
|
|
|
|
|
(defcube fg42/paredit-cube
|
|
|
|
"=paredit= is a minor mode for performing structured editing of S-expression
|
|
|
|
data. The typical example of this would be Lisp or Scheme source code."
|
|
|
|
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Paredit Cube"
|
|
|
|
:flag paredit
|
|
|
|
:flag-default t
|
2022-12-02 22:35:04 +00:00
|
|
|
(fpkg/use paredit
|
2022-12-29 12:10:26 +00:00
|
|
|
:hook ((emacs-lisp-mode . paredit-mode)
|
|
|
|
(clojure-mode . paredit-mode)
|
|
|
|
(scheme-mode . paredit-mode))))
|
2022-12-02 22:35:04 +00:00
|
|
|
|
|
|
|
|
2021-05-03 17:02:13 +01:00
|
|
|
(defcube fg42/cursor-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"This cube controls the shape of the cursor."
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Cursor cube"
|
|
|
|
:flag cursor-type
|
|
|
|
:flag-default t
|
2021-05-03 17:02:13 +01:00
|
|
|
(let ((ctype (or (plist-get fg42/cursor-cube-params :type) 'box))
|
|
|
|
(ccolor (or (plist-get fg42/cursor-cube-params :color) "#aa0000")))
|
2021-05-07 16:03:33 +01:00
|
|
|
|
|
|
|
(add-hook 'fg42/after-initializing-theme-hook
|
|
|
|
(lambda ()
|
|
|
|
(set-default 'cursor-type ctype)
|
|
|
|
(set-cursor-color ccolor)))))
|
2021-05-03 17:02:13 +01:00
|
|
|
|
2021-04-21 19:42:09 +01:00
|
|
|
(defcube fg42/buffer-navigation-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"This cube controls the different aspect of buffer navigation"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Buffer navigation cube"
|
|
|
|
:flag buffer-navigation
|
|
|
|
:flag-default t
|
2021-04-21 19:42:09 +01:00
|
|
|
|
|
|
|
(fpkg/use avy
|
|
|
|
:bind ("M-1" . avy-goto-word-1)))
|
|
|
|
|
|
|
|
|
|
|
|
(defcube fg42/window-navigation-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"This cube controls the different aspect of buffer navigation"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Window navigation cube"
|
|
|
|
:flag window-navigation
|
|
|
|
:flag-default t
|
2021-04-21 19:42:09 +01:00
|
|
|
|
|
|
|
(fpkg/use ace-window
|
|
|
|
:bind ("C-<tab>" . ace-window)))
|
|
|
|
|
|
|
|
|
|
|
|
(defcube fg42/font-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"This cube controls the font configuration of *FG42*"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Font Cube"
|
|
|
|
:no-flag t
|
|
|
|
:flag-default t
|
2021-04-21 19:42:09 +01:00
|
|
|
(let ((font (or (plist-get fg42/font-cube-params :font-name)
|
|
|
|
"Fira Mono"))
|
|
|
|
(size (or (plist-get fg42/font-cube-params :font-size)
|
|
|
|
12)))
|
2022-06-27 23:37:51 +01:00
|
|
|
(when font
|
|
|
|
;; Sets the default font to fg42 font
|
|
|
|
(add-to-list 'default-frame-alist
|
|
|
|
(cons 'font (format "%s-%d" font size)))
|
2021-05-02 22:47:01 +01:00
|
|
|
|
2022-06-27 23:37:51 +01:00
|
|
|
(set-face-attribute 'default t :font font))))
|
2021-03-08 14:10:13 +00:00
|
|
|
|
2021-10-12 00:35:05 +01:00
|
|
|
|
2024-02-11 12:18:21 +00:00
|
|
|
;; ;TODO: Replace this cube with a `theme-cube'
|
|
|
|
;; (defcube fg42/dracula-theme-cube
|
|
|
|
;; "Replace this with a theme cube"
|
|
|
|
;; :title "Dracula theme"
|
|
|
|
;; :no-flag t
|
|
|
|
;; :ui-hook (lambda ()
|
|
|
|
;; (fpkg/use dracula-theme
|
|
|
|
;; :init
|
|
|
|
;; (fg42/setup-theme
|
|
|
|
;; (load-theme 'dracula t)
|
|
|
|
;; (custom-theme-set-faces
|
|
|
|
;; 'dracula
|
|
|
|
;; '(match ((t (:background "#44475a"))))
|
|
|
|
;; '(all-the-icons-lgreen ((t (:background "#bd93f9"))))
|
|
|
|
;; '(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)
|
|
|
|
;; (set-face-attribute 'region nil :background "#888")))))
|
2021-05-02 22:47:01 +01:00
|
|
|
|
2022-01-28 21:00:02 +00:00
|
|
|
(defcube fg42/badwolf-theme-cube
|
2022-08-21 16:33:20 +01:00
|
|
|
"Badwolf theme cube. An Emacs port of Bad Wolf theme for Vim.
|
|
|
|
https://emacsthemes.com/themes/badwolf-theme.html"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Badwolf theme"
|
|
|
|
:no-flag t
|
2022-01-28 21:00:02 +00:00
|
|
|
(require 'fg42/themes)
|
|
|
|
|
|
|
|
(fpkg/use badwolf-theme
|
|
|
|
:init
|
|
|
|
(fg42/setup-theme
|
|
|
|
(load-theme 'badwolf t)
|
|
|
|
(custom-theme-set-faces
|
|
|
|
'badwolf)
|
|
|
|
(enable-theme 'badwolf))))
|
|
|
|
|
2021-05-02 22:47:01 +01:00
|
|
|
|
|
|
|
(defcube fg42/selectrum-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"This cube adds support for `selectrum' to FG42"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Selectrum cube"
|
|
|
|
:flag selectrum
|
|
|
|
:flag-default t
|
2021-05-02 22:47:01 +01:00
|
|
|
(fpkg/use selectrum
|
|
|
|
:defer nil
|
|
|
|
:init
|
|
|
|
(selectrum-mode +1))
|
|
|
|
|
|
|
|
(fpkg/use selectrum-prescient
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
2021-05-03 00:45:03 +01:00
|
|
|
(setq prescient-filter-method '(literal fuzzy regexp initialism))
|
2021-05-02 22:47:01 +01:00
|
|
|
(selectrum-prescient-mode +1)
|
|
|
|
(prescient-persist-mode +1)))
|
|
|
|
|
|
|
|
;; TODO: Disbale ctrlf in WM mode
|
|
|
|
(fpkg/use ctrlf
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(ctrlf-mode +1)))
|
|
|
|
|
2021-03-08 14:10:13 +00:00
|
|
|
|
|
|
|
(defcube fg42/editor-cube
|
2021-10-12 00:35:05 +01:00
|
|
|
"This is a meta cube that sets up the basic functionalities of an Editor"
|
2023-06-10 22:47:07 +01:00
|
|
|
:title "Editor cube"
|
|
|
|
:no-flag t
|
2021-04-18 16:10:02 +01:00
|
|
|
|
2023-06-25 23:40:24 +01:00
|
|
|
(fg42/disable-modeline-cube)
|
2021-03-08 14:10:13 +00:00
|
|
|
(fpkg/use rainbow-delimiters
|
|
|
|
;; It doesn't work due to a problem/conflict in rainbow-delimiters
|
|
|
|
;; But we use it any way they might fix it
|
|
|
|
:hook (prog-mode . rainbow-delimiters-mode))
|
|
|
|
|
2021-04-21 19:42:09 +01:00
|
|
|
(when-flag font-icon
|
|
|
|
(fpkg/use all-the-icons))
|
|
|
|
|
2021-03-08 14:10:13 +00:00
|
|
|
;; 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.
|
|
|
|
|
2021-04-21 19:42:09 +01:00
|
|
|
;; Remove splash screen
|
2021-03-08 14:10:13 +00:00
|
|
|
(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)
|
2021-04-21 19:42:09 +01:00
|
|
|
;; Automatically removed excess backups of the file
|
|
|
|
(setq delete-old-versions t)
|
2021-03-08 14:10:13 +00:00
|
|
|
|
|
|
|
;; Global configurations
|
|
|
|
(tool-bar-mode -1)
|
2023-07-21 10:45:13 +01:00
|
|
|
|
2021-03-08 14:10:13 +00:00
|
|
|
(menu-bar-mode -1)
|
2023-07-21 10:45:13 +01:00
|
|
|
(when (display-graphic-p)
|
|
|
|
(scroll-bar-mode -1))
|
|
|
|
|
2021-03-08 14:10:13 +00:00
|
|
|
(column-number-mode t)
|
|
|
|
(show-paren-mode t)
|
2021-05-04 18:25:39 +01:00
|
|
|
(electric-pair-mode 1)
|
|
|
|
|
|
|
|
;; Rectangular select
|
|
|
|
(cua-selection-mode t)
|
|
|
|
|
|
|
|
;; Yank the region on type
|
|
|
|
(delete-selection-mode 1)
|
2021-03-08 14:10:13 +00:00
|
|
|
|
|
|
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
|
|
|
|
|
|
;; Hooks ---
|
|
|
|
;; Deletel extra trailing white spaces on save
|
|
|
|
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
|
|
|
|
|
|
|
;; Enable rainbow-delimiters for programming
|
2021-05-07 16:03:33 +01:00
|
|
|
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
|
|
|
|
|
|
|
|
|
2021-07-02 15:48:30 +01:00
|
|
|
(when-flag server
|
2021-12-11 18:35:15 +00:00
|
|
|
(when (not (server-running-p))
|
2023-06-10 20:47:55 +01:00
|
|
|
(when-wm
|
|
|
|
(setq server-name "fg42-wm"))
|
|
|
|
(server-start)))
|
2021-07-02 15:48:30 +01:00
|
|
|
|
2021-05-07 16:03:33 +01:00
|
|
|
;; Call the editor related cubes. They will be run only if
|
|
|
|
;; their flag is active otherwise they will be skipped
|
2021-12-12 11:15:23 +00:00
|
|
|
|
2023-07-21 10:46:16 +01:00
|
|
|
(when-flag fg42-project
|
|
|
|
(fg42-project-global-mode t))
|
2023-06-25 23:40:24 +01:00
|
|
|
|
2021-12-11 14:56:57 +00:00
|
|
|
(let ((mline (or (plist-get fg42/editor-cube-params :modeline)
|
2021-12-12 19:51:09 +00:00
|
|
|
#'fg42/default-modeline)))
|
2021-12-14 19:52:35 +00:00
|
|
|
;;(fg42/statusbar-cube)
|
2023-06-25 23:40:24 +01:00
|
|
|
;;(fg42/modeline-cube)
|
|
|
|
;; (fg42/setup-modeline-format mline)
|
|
|
|
))
|
2021-03-08 14:10:13 +00:00
|
|
|
|
|
|
|
|
2024-02-18 16:06:30 +00:00
|
|
|
(provide 'fg42/cubes/editor)
|
2021-03-08 14:10:13 +00:00
|
|
|
;;; editor.el ends here
|