2024-03-21 19:37:50 +00:00
|
|
|
;;; 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
|
2024-04-05 21:04:36 +01:00
|
|
|
;; Version: 4.0.0
|
2024-03-21 19:37:50 +00:00
|
|
|
;;
|
|
|
|
;; 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
|
2024-03-23 22:37:54 +00:00
|
|
|
(require 'fpkg)
|
|
|
|
;; Language support
|
2024-03-24 21:56:25 +00:00
|
|
|
(require 'fg42/autocomplete)
|
2024-03-26 22:03:07 +00:00
|
|
|
(require 'fg42/langs/langs)
|
2024-04-11 20:04:49 +01:00
|
|
|
(require 'fg42/eglot)
|
2024-03-24 23:05:07 +00:00
|
|
|
(require 'fg42/langs/cpp)
|
2024-03-25 17:21:04 +00:00
|
|
|
(require 'fg42/langs/verilog)
|
|
|
|
(require 'fg42/langs/python)
|
2024-03-25 18:28:07 +00:00
|
|
|
(require 'fg42/langs/elisp)
|
2024-03-26 12:59:58 +00:00
|
|
|
(require 'fg42/langs/nix)
|
2024-04-06 12:53:30 +01:00
|
|
|
|
2024-04-05 19:35:22 +01:00
|
|
|
(require 'fg42/git)
|
2024-04-06 12:53:30 +01:00
|
|
|
(require 'fg42/wm)
|
2024-04-06 13:54:08 +01:00
|
|
|
(require 'fg42/org)
|
2024-04-06 14:09:05 +01:00
|
|
|
(require 'fg42/minibuffer)
|
2024-04-10 14:48:47 +01:00
|
|
|
(require 'fg42/graphics)
|
|
|
|
(require 'fg42/modeline))
|
2024-03-24 23:05:07 +00:00
|
|
|
|
2024-03-23 22:37:54 +00:00
|
|
|
(require 'server)
|
2024-04-10 14:48:47 +01:00
|
|
|
|
2024-03-23 12:06:01 +00:00
|
|
|
|
2024-03-23 22:37:54 +00:00
|
|
|
(defvar fg42/font '("Fira Mono" 12)
|
|
|
|
"Font name and size to be used with FG42. (Default (\"Fira Mono\" 12).")
|
2024-03-21 19:37:50 +00:00
|
|
|
|
2024-03-23 22:37:54 +00:00
|
|
|
(defvar fg42/snippet-dir nil
|
|
|
|
"Where to find user's snippets.")
|
2024-03-21 19:37:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
(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)))
|
|
|
|
|
|
|
|
|
2024-03-23 22:37:54 +00:00
|
|
|
|
2024-03-21 19:37:50 +00:00
|
|
|
(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))
|
|
|
|
|
2024-03-23 12:06:01 +00:00
|
|
|
(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)))
|
|
|
|
|
2024-03-24 23:05:07 +00:00
|
|
|
|
2024-03-23 12:06:01 +00:00
|
|
|
(use! projectile-ripgrep
|
|
|
|
"Use ripgrep with projectile"
|
|
|
|
:after projectile)
|
|
|
|
|
2024-03-24 21:56:25 +00:00
|
|
|
|
2024-03-24 23:05:07 +00:00
|
|
|
(use! pkg-info
|
|
|
|
"`pkg-info' integration.")
|
|
|
|
|
|
|
|
|
2024-04-05 22:18:59 +01:00
|
|
|
(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))
|
|
|
|
|
|
|
|
|
2024-03-21 19:37:50 +00:00
|
|
|
(use! helpful
|
|
|
|
"Helpful is an alternative to the built-in Emacs help that provides much more
|
|
|
|
contextual information."
|
2024-03-23 12:06:01 +00:00
|
|
|
: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)))
|
2024-03-21 19:37:50 +00:00
|
|
|
|
|
|
|
(use! envrc
|
|
|
|
"Activate direnv whenever encounter a `.envrc' file"
|
2024-03-23 12:06:01 +00:00
|
|
|
:config
|
2024-03-21 19:37:50 +00:00
|
|
|
(envrc-global-mode))
|
|
|
|
|
|
|
|
(use! pinentry
|
|
|
|
"Pinentry cube with setup the =pinentry= program to be used within FG42."
|
2024-03-23 12:06:01 +00:00
|
|
|
:commands pinentry-start
|
2024-03-21 19:37:50 +00:00
|
|
|
:init
|
2024-03-23 12:06:01 +00:00
|
|
|
(setq epa-pinentry-mode 'loopback))
|
2024-03-21 19:37:50 +00:00
|
|
|
|
|
|
|
(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)."
|
2024-03-23 12:06:01 +00:00
|
|
|
:bind (("C-'" . imenu-list-smart-toggle)))
|
2024-03-21 19:37:50 +00:00
|
|
|
|
|
|
|
(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."
|
2024-03-23 12:06:01 +00:00
|
|
|
:config
|
2024-03-21 19:37:50 +00:00
|
|
|
(when (memq window-system '(mac ns x))
|
|
|
|
(exec-path-from-shell-initialize)))
|
|
|
|
|
|
|
|
(use! hl-line
|
|
|
|
"Highlights the current line."
|
2024-03-23 12:06:01 +00:00
|
|
|
:hook (emacs-startup . global-hl-line-mode))
|
2024-03-21 19:37:50 +00:00
|
|
|
|
|
|
|
(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))
|
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
(when-not-wm
|
2024-04-05 18:35:26 +01:00
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
(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")))
|
2024-04-05 18:35:26 +01:00
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
(use! savehist
|
|
|
|
"Persist history over Emacs restarts. Vertico sorts by history position."
|
|
|
|
:init
|
|
|
|
(savehist-mode))
|
2024-04-05 18:35:26 +01:00
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
(use! display-line-numbers
|
|
|
|
"The builtin replacement of linum. It's is pretty fast."
|
|
|
|
:config
|
|
|
|
(global-display-line-numbers-mode 1)))
|
2024-03-21 19:37:50 +00:00
|
|
|
|
2024-04-05 18:35:26 +01:00
|
|
|
|
2024-03-23 22:37:54 +00:00
|
|
|
(use! yasnippet
|
2024-03-25 20:51:00 +00:00
|
|
|
"A Snippet is a template system for Emacs. "
|
2024-03-23 22:37:54 +00:00
|
|
|
: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))
|
2024-03-25 20:51:00 +00:00
|
|
|
(yas-global-mode 1)))
|
2024-03-23 22:37:54 +00:00
|
|
|
|
|
|
|
(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))
|
|
|
|
|
2024-03-21 19:37:50 +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.
|
2024-03-23 12:06:01 +00:00
|
|
|
(fg42/setup-font)
|
|
|
|
(add-hook 'fg42/after-initializing-theme-hook
|
|
|
|
(lambda ()
|
|
|
|
(set-default 'cursor-type 'bar)
|
|
|
|
(set-cursor-color "#eeeeec")))
|
2024-03-21 19:37:50 +00:00
|
|
|
|
|
|
|
;; 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)
|
2024-03-23 22:37:54 +00:00
|
|
|
|
|
|
|
(setq tooltip-use-echo-area t)
|
|
|
|
(setq x-gtk-use-system-tooltips nil)
|
|
|
|
|
2024-03-21 19:37:50 +00:00
|
|
|
;; Global configurations
|
|
|
|
(tool-bar-mode -1)
|
2024-03-23 22:37:54 +00:00
|
|
|
(tooltip-mode nil)
|
2024-03-21 19:37:50 +00:00
|
|
|
(menu-bar-mode -1)
|
2024-03-26 18:42:50 +00:00
|
|
|
|
2024-03-21 19:37:50 +00:00
|
|
|
(when (display-graphic-p)
|
2024-03-23 22:37:54 +00:00
|
|
|
;; Smoother scrolling
|
|
|
|
(pixel-scroll-precision-mode)
|
2024-03-21 19:37:50 +00:00
|
|
|
(scroll-bar-mode -1))
|
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
2024-03-21 19:37:50 +00:00
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
;; Hooks ---
|
|
|
|
(add-hook
|
|
|
|
'emacs-startup-hook
|
|
|
|
(lambda ()
|
2024-04-11 15:39:22 +01:00
|
|
|
;; It only applies to toolkit=no
|
|
|
|
(set-mouse-color (get-base16-color-or :base07 "#eeeeec"))
|
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
;; Switch from `dabbrev-expand' to `hippie-expand'
|
|
|
|
(global-set-key [remap dabbrev-expand] 'hippie-expand)
|
2024-04-05 19:35:22 +01:00
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
(column-number-mode t)
|
|
|
|
(show-paren-mode t)
|
|
|
|
(electric-pair-mode 1)
|
|
|
|
(global-company-mode)
|
2024-04-05 20:54:36 +01:00
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
;; git changes in the fringe
|
|
|
|
(global-diff-hl-mode)
|
2024-03-21 19:37:50 +00:00
|
|
|
|
2024-04-11 22:34:55 +01:00
|
|
|
;; Modeline replacement
|
2024-04-11 22:56:23 +01:00
|
|
|
(noether-global-mode)
|
2024-03-21 19:37:50 +00:00
|
|
|
|
2024-04-10 14:48:47 +01:00
|
|
|
;; Rectangular select
|
|
|
|
(cua-selection-mode t)
|
|
|
|
|
|
|
|
;; Yank the region on type
|
|
|
|
(delete-selection-mode 1)))
|
2024-03-21 19:37:50 +00:00
|
|
|
|
|
|
|
;; 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"))
|
2024-04-06 12:53:30 +01:00
|
|
|
(server-start)
|
|
|
|
(require 'org-protocol))
|
2024-03-25 18:28:07 +00:00
|
|
|
|
|
|
|
(when-wm
|
|
|
|
;; Activating the WM mode
|
|
|
|
(exwm-enable)
|
|
|
|
(exwm-systemtray-enable)
|
2024-04-06 15:56:41 +01:00
|
|
|
(exwm-randr-enable))
|
|
|
|
(message "[FG42]: Use `fg42-help' to get help."))
|
2024-03-21 19:37:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
(provide 'fg42/editor)
|
|
|
|
;;; editor.el ends here
|