283 lines
10 KiB
EmacsLisp
283 lines
10 KiB
EmacsLisp
;;; init --- Summary
|
||
|
||
;;; Commentary:
|
||
|
||
;;; Code:
|
||
|
||
(setq custom-file (concat user-emacs-directory "customizations.el"))
|
||
(load custom-file)
|
||
|
||
;; Initialize the package system and use-package
|
||
(setq load-prefer-newer t)
|
||
|
||
;; Add my own, version controlled ~lisp~ directory to ~load-path~
|
||
|
||
(add-to-list 'load-path (expand-file-name
|
||
(convert-standard-filename "lisp/")
|
||
user-emacs-directory))
|
||
|
||
;; Do the same with the local ~site-lisp~ if it’s there
|
||
|
||
(let ((site-lisp-dir "/usr/local/share/emacs/site-lisp"))
|
||
(when (file-directory-p site-lisp-dir)
|
||
(dolist (elt (directory-files site-lisp-dir))
|
||
(unless (or (string= elt ".") (string= elt ".."))
|
||
(add-to-list 'load-path (expand-file-name elt site-lisp-dir))))))
|
||
|
||
;; I prefer using freedesktop’s desktop specification everywhere
|
||
(load "xdg-paths")
|
||
|
||
;; Set up the package manager
|
||
|
||
;; Package archives
|
||
|
||
(require 'package)
|
||
|
||
;; GNU ELPA
|
||
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
|
||
;; MELPA Stable
|
||
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
|
||
;; MELPA
|
||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
||
|
||
;; Finally, initialise the package manager
|
||
(package-initialize)
|
||
|
||
;; use-package is a really convenient way to install packages. It’s installed in 30.1, but let’s stay on the safe side.
|
||
(unless (package-installed-p 'use-package)
|
||
(package-refresh-contents)
|
||
(package-install 'use-package))
|
||
(require 'use-package)
|
||
|
||
(use-package use-package
|
||
:custom
|
||
(use-package-always-ensure t)
|
||
(use-package-verbose nil))
|
||
|
||
(use-package bind-key)
|
||
|
||
;; Custom functions and commands
|
||
(load "gpolonkai/utilities")
|
||
(load "gpolonkai/windows")
|
||
(load "gpolonkai/org-utils")
|
||
(load "gpolonkai/text-utils")
|
||
(load "gpolonkai/nav-utils")
|
||
(load "gpolonkai/file-utils")
|
||
(load "gpolonkai/magit-utils")
|
||
|
||
(defun crm-indicator (args)
|
||
"Generate a prompt for `completing-read-multiple'.
|
||
|
||
ARGS is a cons cell of two strings, which will be used in the prompt in reverse
|
||
order."
|
||
(cons (format "[CRM%s] %s"
|
||
(replace-regexp-in-string
|
||
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'"
|
||
""
|
||
crm-separator)
|
||
(car args))
|
||
(cdr args)))
|
||
|
||
(use-package emacs
|
||
:ensure nil
|
||
:init
|
||
;; Required for Consult/Vertico
|
||
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
|
||
(setq frame-title-format
|
||
'((:eval (concat system-name
|
||
": "
|
||
(if (buffer-file-name)
|
||
(abbreviate-file-name (buffer-file-name))
|
||
"%b")))))
|
||
:custom
|
||
(user-full-name "Gergely Polonkai")
|
||
(user-mail-address "gergely@polonkai.eu")
|
||
(kill-read-only-ok t)
|
||
(use-dialog-box nil)
|
||
(cursor-type 'bar)
|
||
(echo-keystrokes .01)
|
||
(fill-column 120)
|
||
(initial-scratch-message "")
|
||
(minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt))
|
||
(enable-recursive-minibuffers t)
|
||
(completion-cycle-threshold 3)
|
||
(tab-always-indent 'complete)
|
||
:hook
|
||
(minibuffer-setup . cursor-intangible-mode))
|
||
|
||
;; Basic settings
|
||
;;
|
||
;; Now that we have package management configured we can set up defaults more
|
||
;; easily. This includes every builtin packages, font faces, and the like.
|
||
|
||
;; Set Org’s main directory
|
||
;;
|
||
;; Since a lot of packages (org-projectile, org-caldav, etc.) rely on it, it
|
||
;; needs to be set as early as possible.
|
||
|
||
(setq org-directory (expand-file-name "~/Nextcloud/orgmode"))
|
||
|
||
;; Set up my personal keymap
|
||
|
||
(defvar gpolonkai/pers-map (make-sparse-keymap)
|
||
"My own, personal, keymap!")
|
||
(define-prefix-command 'gpolonkai/pers-map)
|
||
(define-key ctl-x-map "t" 'gpolonkai/pers-map)
|
||
(define-key global-map (kbd "C-t") 'gpolonkai/pers-map)
|
||
|
||
;; Set up some faces
|
||
|
||
(use-package faces
|
||
:ensure nil
|
||
:custom-face
|
||
(default ((t (:family "Fira Code Retina" :foundry "simp" :slant normal :weight normal :height 100 :width normal))))
|
||
(trailing-whitespace ((t (:inherit nil :background "red3")))))
|
||
|
||
;; Fira Code comes with nice ligatures, let’s use them!
|
||
|
||
(use-package ligature
|
||
:config
|
||
;; Enable the "www" ligature in every possible major mode
|
||
(ligature-set-ligatures 't '("www"))
|
||
;; Enable traditional ligature support in eww-mode, if the
|
||
;; `variable-pitch' face supports it
|
||
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
|
||
;; Enable all Cascadia and Fira Code ligatures in programming modes
|
||
(ligature-set-ligatures 'prog-mode
|
||
'(;; == === ==== => =| =>>=>=|=>==>> ==< =/=//=// =~
|
||
;; =:= =!=
|
||
("=" (rx (+ (or ">" "<" "|" "/" "~" ":" "!" "="))))
|
||
;; ;; ;;;
|
||
(";" (rx (+ ";")))
|
||
;; && &&&
|
||
("&" (rx (+ "&")))
|
||
;; !! !!! !. !: !!. != !== !~
|
||
("!" (rx (+ (or "=" "!" "\." ":" "~"))))
|
||
;; ?? ??? ?: ?= ?.
|
||
("?" (rx (or ":" "=" "\." (+ "?"))))
|
||
;; %% %%%
|
||
("%" (rx (+ "%")))
|
||
;; |> ||> |||> ||||> |] |} || ||| |-> ||-||
|
||
;; |->>-||-<<-| |- |== ||=||
|
||
;; |==>>==<<==<=>==//==/=!==:===>
|
||
("|" (rx (+ (or ">" "<" "|" "/" ":" "!" "}" "\]"
|
||
"-" "=" ))))
|
||
;; \\ \\\ \/
|
||
("\\" (rx (or "/" (+ "\\"))))
|
||
;; ++ +++ ++++ +>
|
||
("+" (rx (or ">" (+ "+"))))
|
||
;; :: ::: :::: :> :< := :// ::=
|
||
(":" (rx (or ">" "<" "=" "//" ":=" (+ ":"))))
|
||
;; // /// //// /\ /* /> /===:===!=//===>>==>==/
|
||
("/" (rx (+ (or ">" "<" "|" "/" "\\" "\*" ":" "!"
|
||
"="))))
|
||
;; .. ... .... .= .- .? ..= ..<
|
||
("\." (rx (or "=" "-" "\?" "\.=" "\.<" (+ "\."))))
|
||
;; -- --- ---- -~ -> ->> -| -|->-->>->--<<-|
|
||
("-" (rx (+ (or ">" "<" "|" "~" "-"))))
|
||
;; *> */ *) ** *** ****
|
||
("*" (rx (or ">" "/" ")" (+ "*"))))
|
||
;; www wwww
|
||
("w" (rx (+ "w")))
|
||
;; <> <!-- <|> <: <~ <~> <~~ <+ <* <$ </ <+> <*>
|
||
;; <$> </> <| <|| <||| <|||| <- <-| <-<<-|-> <->>
|
||
;; <<-> <= <=> <<==<<==>=|=>==/==//=!==:=>
|
||
;; << <<< <<<<
|
||
("<" (rx (+ (or "\+" "\*" "\$" "<" ">" ":" "~" "!"
|
||
"-" "/" "|" "="))))
|
||
;; >: >- >>- >--|-> >>-|-> >= >== >>== >=|=:=>>
|
||
;; >> >>> >>>>
|
||
(">" (rx (+ (or ">" "<" "|" "/" ":" "=" "-"))))
|
||
;; #: #= #! #( #? #[ #{ #_ #_( ## ### #####
|
||
("#" (rx (or ":" "=" "!" "(" "\?" "\[" "{" "_(" "_"
|
||
(+ "#"))))
|
||
;; ~~ ~~~ ~= ~- ~@ ~> ~~>
|
||
("~" (rx (or ">" "=" "-" "@" "~>" (+ "~"))))
|
||
;; __ ___ ____ _|_ __|____|_
|
||
("_" (rx (+ (or "_" "|"))))
|
||
;; Fira code: 0xFF 0x12
|
||
("0" (rx (and "x" (+ (in "A-F" "a-f" "0-9")))))
|
||
;; Fira code:
|
||
"Fl" "Tl" "fi" "fj" "fl" "ft"
|
||
;; The few not covered by the regexps.
|
||
"{|" "[|" "]#" "(*" "}#" "$>" "^="))
|
||
;; Enables ligature checks globally in all buffers. You can also do it
|
||
;; per mode with `ligature-mode'.
|
||
(global-ligature-mode t))
|
||
|
||
;; Set the default font and configure font resizing
|
||
|
||
;; Before this can be used, make sure the Symbola font
|
||
;; (https://zhm.github.io/symbola/) font is installed.
|
||
|
||
(defun gpolonkai/set-font-size (frame)
|
||
"Set default fonts and font sizes in FRAME."
|
||
(when (display-graphic-p frame)
|
||
(set-face-attribute 'default frame :font "Fira Code Retina-10")
|
||
(set-frame-font "Fira Code Retina-10" t (list frame))))
|
||
|
||
(defun --set-emoji-font (frame)
|
||
"Adjust the font setting of FRAME so Emacs can display Emoji properly."
|
||
(when (display-graphic-p frame)
|
||
(set-fontset-font t 'symbol
|
||
(font-spec :family "Symbola")
|
||
frame 'prepend)
|
||
(set-fontset-font t 'unicode
|
||
"Noto Emoji"
|
||
nil 'append)))
|
||
|
||
(add-hook 'after-make-frame-functions 'gpolonkai/set-font-size)
|
||
(add-hook 'after-make-frame-functions '--set-emoji-font)
|
||
|
||
(gpolonkai/set-font-size nil)
|
||
(--set-emoji-font nil)
|
||
|
||
;; Set UTF-8 as the default encoding
|
||
(set-language-environment "UTF-8")
|
||
(set-default-coding-systems 'utf-8)
|
||
|
||
(use-package frame
|
||
:ensure nil
|
||
:custom
|
||
(blink-cursor-mode t))
|
||
|
||
;; I really don’t want to type more than i really must…
|
||
|
||
(defalias 'yes-or-no-p 'y-or-n-p)
|
||
|
||
;; Tweak window chrome, AKA let’s set up the UI!
|
||
|
||
;; Turn off the toolbar
|
||
(tool-bar-mode 0)
|
||
;; Turn off the menu bar
|
||
(menu-bar-mode 0)
|
||
|
||
;; If we are running in a graphical environment, turn off the scroll bar
|
||
;;
|
||
;; TODO: This is not done for every new frame!
|
||
(when window-system
|
||
(scroll-bar-mode -1))
|
||
|
||
;; Maximise newly created frames (AKA DE windows)
|
||
(set-frame-parameter nil 'fullscreen 'maximized)
|
||
|
||
;; Enable all the commands! These are disabled for a reason, but i’m a rockstar,
|
||
;; so who cares‽
|
||
;;
|
||
;; TODO: There must be a way to do it programatically
|
||
(put 'downcase-region 'disabled nil)
|
||
(put 'upcase-region 'disabled nil)
|
||
(put 'erase-buffer 'disabled nil)
|
||
(put 'narrow-to-region 'disabled nil)
|
||
(put 'narrow-to-page 'disabled nil)
|
||
(put 'set-goal-column 'disabled nil)
|
||
(put 'scroll-left 'disabled nil)
|
||
(put 'dired-find-alternate-file 'disabled nil)
|
||
(put 'Info-edit 'disabled nil)
|
||
(put 'list-timers 'disabled nil)
|
||
|
||
;; I started moving my configuration to this Org file. It’s easier to document this way.
|
||
(org-babel-load-file (expand-file-name "configuration.org" user-emacs-directory))
|
||
|
||
;;; init.el ends here
|