;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- ;; ;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors ;; ;; Author: Sameer Rahmani ;; URL: https://devheroes.codes/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 . ;; ;;; Commentary: ;;; Code: (eval-when-compile (require 'fpkg) ;; Language support (require 'fg42/autocomplete) (require 'fg42/langs/cpp) (require 'fg42/langs/verilog) (require 'fg42/langs/python) (require 'fg42/langs/elisp) (require 'fg42/wm)) (require 'server) (require 'fg42/modeline) ;; (require 'fg42/utils) ;; (require 'fg42/modeline) ;; (require 'fg42/cubes/modeline) ;; (require 'fg42/themes) ;; (require 'fg42/project) (defvar fg42/font '("Fira Mono" 12) "Font name and size to be used with FG42. (Default (\"Fira Mono\" 12).") (defvar fg42/snippet-dir nil "Where to find user's snippets.") (defun fg42/setup-font () "Set the default font of `FG42' to FONT-NAME and FONT-SIZE." (let ((name (car fg42/font)) (size (cadr fg42/font))) (add-to-list 'default-frame-alist (cons 'font (format "%s-%d" name size))) (set-face-attribute 'default t :font name))) (defun fg42/setup-editor () "Setup the overall functionality of FG42." (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! 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 "The Imenu facility offers a way to find the major definitions in a file by name." :bind (("M-i" . imenu))) (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! emojify "Adds support for emojis to `FG42'" :hook (emacs-startup . global-emojify-mode)) (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! rainbow-delimiters "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." ;; 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)) (use! paredit "`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." :hook ((emacs-lisp-mode . paredit-mode) (clojure-mode . paredit-mode) (scheme-mode . paredit-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-" . ace-window)) (use! vertico "Vertico provides a performant and minimalistic vertical completion UI based on the default completion system. The focus of Vertico is to provide a UI which behaves correctly under all circumstances." :config (require 'vertico-multiform) (require 'vertico-flat) (require 'vertico-grid) (require 'vertico-buffer) (require 'vertico-indexed) (require 'vertico-quick) (require 'vertico-repeat) (vertico-mode) (vertico-multiform-mode) ;; Configure the display per command. ;; Use a buffer with indices for imenu (setq vertico-multiform-commands '((imenu buffer indexed))) ;; Configure the display per completion category. ;; Use the grid display for files and a buffer ;; for the consult-grep commands. (setq vertico-multiform-categories '((file grid))) (setq vertico-count 10) (setq vertico-cycle t) (when-wm (setq vertico-multiform-commands '((t flat))) (setq vertico-multiform-categories '((file flat))))) (use! orderless "This package provides an orderless completion style that divides the pattern into space-separated components, and matches candidates that match all of the components in any order." :init (setq completion-styles '(orderless basic) completion-category-defaults nil completion-category-overrides '((file (styles partial-completion))))) (use! savehist "Persist history over Emacs restarts. Vertico sorts by history position." :init (savehist-mode)) (when-not-wm ;; Minibuffer related stuff (use! ctrlf "Single buffer text search." :config (ctrlf-mode +1)) (use! display-line-numbers "The builtin replacement of linum. It's is pretty fast." :config (global-display-line-numbers-mode 1))) (use! all-the-icons "A utility package to collect various Icon Fonts and propertize them within Emacs." :if (display-graphic-p)) (use! yasnippet "A Snippet is a template system for Emacs. " :config (let* ((snippet-home (expand-file-name "snippets" (file-name-directory (locate-library "yasnippet-snippets")))) (local-snippet (expand-file-name "snippets" fg42-home)) (user-snippets (or fg42/snippet-dir local-snippet))) (setq yas-snippet-dirs `(,user-snippets ,local-snippet ,snippet-home)) (yas-global-mode 1))) (use! yasnippet-snippets "Yasnippet's snippets." :after yasnippet) ;; Language Servers and friends (use! eglot "Eglot is a minimalistic yet powerful LSP replacement shipped with Emacs." :commands eglot :autoload eglot-ensure) (use! flycheck "Flycheck is a modern on-the-fly syntax checking extension for GNU Emacs." :config (global-flycheck-mode)) ;; 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-initializing-theme-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)) (column-number-mode t) (show-paren-mode t) (electric-pair-mode 1) (global-company-mode) ;; Rectangular select (cua-selection-mode t) ;; Yank the region on type (delete-selection-mode 1) (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 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode) ;; 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)) (when-wm ;; Activating the WM mode (exwm-enable) (exwm-systemtray-enable) (exwm-randr-enable))) (provide 'fg42/editor) ;;; editor.el ends here