Browse Source

editor(emacs): Adds further configuration file changes

main
creton32 5 days ago
parent
commit
fe245180f7
  1. 338
      editor/.config/emacs/init.el

338
editor/.config/emacs/init.el

@ -1,40 +1,23 @@
;; Load secrets
(load-file (concat user-emacs-directory "private.el"))
;; Set emoji fonts
(defun my-emoji-fonts ()
"Sets my emoji fonts"
(set-fontset-font t 'symbol "Noto Color Emoji"))
(if (daemonp)
(add-hook 'server-after-make-frame-hook #'my-emoji-fonts)
(my-emoji-fonts))
;;; init.el --- Personal Emacs initialization file
;;; Visual Settings
(tool-bar-mode -1) ; disable toolbar
(menu-bar-mode -1) ; disable the menubar
(menu-bar-mode -1)
(setq ring-bell-function 'ignore
echo-keystrokes 0) ; don't echo keystrokes in the minibuffer
(setq-default cursor-in-non-selected-windows nil ; only show cursor in active window
frame-title-format '("%b - Emacs")) ; set window title as current buffer name
;; Shorten startup time by disabling garbage collector temporarily
(setq gc-cons-threshold 64000000)
(setq gc-cons-threshold (* 100 1024 1024))
(add-hook 'after-init-hook #'(lambda()
(setq gc-cons-threshold 800000))) ; re-enable it after startup
(setq gc-cons-threshold (* 2 1024 1024)))) ; re-enable it after startup
;; Change yes-or-no questions to y-or-n
(fset 'yes-or-no-p 'y-or-n-p)
;; Font settings
(set-face-attribute 'default nil :font "Iosevka Custom" :height 105)
(set-face-attribute 'fixed-pitch nil :font "Iosevka Custom" :height 105)
(set-face-attribute 'variable-pitch nil :font "SourceSans3" :height 120)
(set-fontset-font "fontset-default" nil (font-spec :name "Noto Color Emoji"))
(set-fontset-font t 'unicode "Noto Color Emoji" nil 'append)
(set-fontset-font t 'symbol "Noto Color Emoji" nil 'append)
;; Edit init.el
(defun my-open-init-file ()
"Opens my Emacs configuration file"
"Opens my Emacs configuration file."
(interactive)
(when (file-exists-p user-init-file)
(find-file user-init-file)))
@ -44,26 +27,49 @@
;; Initialize package sources
(require 'package)
(setq package-archives '(("MELPA" . "https://melpa.org/packages/")
("GNU ELPA" . "https://elpa.gnu.org/packages/"))
package-archive-priorities '(("MELPA" . 1)
("GNU ELPA" . 0)))
(package-initialize)
(package-refresh-contents)
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(use-package package
:ensure nil ;; built-in
:init
(package-initialize)
(unless package-archive-contents
(package-refresh-contents 1))
(setq package-archives '(("MELPA" . "https://melpa.org/packages/")
("GNU ELPA" . "https://elpa.gnu.org/packages/"))
package-archive-priorities '(("MELPA" . 1)
("GNU ELPA" . 0))))
(use-package faces
:ensure nil ;; built-in
:init
(defun my-emoji-fonts ()
"Sets my emoji fonts."
(set-fontset-font t 'symbol "Noto Color Emoji"))
(if (daemonp)
(add-hook 'server-after-make-frame-hook #'my-emoji-fonts)
(my-emoji-fonts))
(set-face-attribute 'default nil :font "Iosevka Custom" :height 105)
(set-face-attribute 'fixed-pitch nil :font "Iosevka Custom" :height 105)
(set-face-attribute 'variable-pitch nil :font "SourceSans3" :height 120)
(set-fontset-font "fontset-default" nil (font-spec :name "Noto Color Emoji"))
(set-fontset-font t 'unicode "Noto Color Emoji" nil 'append)
(set-fontset-font t 'symbol "Noto Color Emoji" nil 'append))
(use-package use-package
:init
(setq use-package-always-ensure t)
(setq use-package-always-ensure t
use-package-verbose t)
(use-package use-package-ensure-system-package :ensure t))
(use-package tool-bar
:ensure nil
:init
(tool-bar-mode -1))
;; Install Emacs packages from source
(use-package quelpa
:demand t
:custom (quelpa-upgrade-p t))
(use-package quelpa-use-package
@ -118,32 +124,41 @@
:defer t
:init
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8))
(use-package simple
:ensure nil ; built-in
:hook
((text-mode prog-mode conf-mode) . display-line-numbers-mode)
((org-mode term-mode shell-mode eshell-mode) . (lambda () (display-line-numbers-mode -1)))
:init
(transient-mark-mode 1)
(transient-mark-mode 1))
;; Enable line numbers for some modes
(column-number-mode)
(setq display-line-numbers-type 'relative)
(dolist (mode '(text-mode-hook
prog-mode-hook
conf-mode-hook))
(add-hook mode (lambda ()
(display-line-numbers-mode 1))))
;; Disable line numbers for some modes
(dolist (mode '(org-mode-hook
term-mode-hook
shell-mode-hook
eshell-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0)))))
;; (column-number-mode)
;; (dolist (mode '(text-mode-hook
;; prog-mode-hook
;; conf-mode-hook))
;; (add-hook mode (lambda ()
;; (display-line-numbers-mode 1))))
;; ;; Disable line numbers for some modes
;; (dolist (mode '(org-mode-hook
;; term-mode-hook
;; shell-mode-hook
;; eshell-mode-hook))
;; (add-hook mode (lambda () (display-line-numbers-mode 0)))))
(use-package display-line-numbers
:ensure nil ;; built-in
:after simple
:config
(setq display-line-numbers-type 'relative))
(use-package files
:ensure nil ; built-in
:init
;; Load personal files
(load-file (concat user-emacs-directory "private.el"))
;; Store all backup and autosave files in /tmp
(setq backup-directory-alist
`((".*" . ,temporary-file-directory))
@ -182,11 +197,8 @@
(defun my-dired-mode-setup ()
"My setup for dired mode"
(dired-hide-details-mode 1))
(setq ls-lisp-dirs-first t
ls-lisp-use-insert-directory-program nil
dired-dwim-target t
(setq dired-dwim-target t
dired-listing-switches "-lA"
dired-guess-shell-alist-user '(("" "xdg-open"))
delete-by-moving-to-trash t)
:hook (dired-mode . my-dired-mode-setup)
:bind (:map dired-mode-map
@ -195,8 +207,16 @@
([remap dired-up-directory] . (lambda () (interactive) (find-alternate-file "..")))))
(use-package dired-x
:ensure nil
:bind (("C-c j" . dired-jump)))
:ensure nil ;; built-in
:bind (("C-c j" . dired-jump))
:config
(setq dired-guess-shell-alist-user '(("" "xdg-open"))))
(use-package ls-lisp
:ensure nil ;; built-in
:config
(setq ls-lisp-dirs-first t
ls-lisp-use-insert-directory-program nil))
(use-package vc
:ensure nil ; built-in
@ -227,6 +247,7 @@
:after doom-themes
:hook (org-mode . my-org-mode-setup)
:diminish org-indent-mode
:commands (org-capture org-agenda)
:bind (("C-c a" . org-agenda)
("C-c s l" . org-store-link)
("C-c c" . org-capture)
@ -300,60 +321,70 @@
"* TODO %?\n %U\n %a\n %i" :empty-lines 1)))
;; List of languages evaluated by org-babel
(org-babel-do-load-languages
'org-babel-load-languages
'((js . t)
(lua . t)
(python . t)))
(require 'org-tempo)
(add-to-list 'org-modules 'org-tempo)
;; Block templates for commonly used languages
(add-to-list 'org-structure-template-alist '("sh" . "src sh"))
(add-to-list 'org-structure-template-alist '("js" . "src js"))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(add-to-list 'org-structure-template-alist '("cf" . "src conf"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(require 'org-indent)
(add-to-list 'org-modules 'org-indent)
;; Make some org faces use fixed pitch fonts
(set-face-attribute 'org-block nil :inherit 'fixed-pitch)
(set-face-attribute 'org-verbatim nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-document-info nil :foreground "dark orange")
(set-face-attribute 'org-document-info-keyword nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-indent nil :inherit '(org-hide fixed-pitch))
(set-face-attribute 'org-link nil :underline t)
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-table nil :inherit 'fixed-pitch :foreground "#83a598")
(require 'org-habit)
(add-to-list 'org-modules 'org-habit)
(setq org-habit-graph-column 60)
;; Set custom scaling for Org headings
(dolist (face '((org-level-1 . 1.2)
(org-level-2 . 1.1)
(org-level-3 . 1.05)
(org-level-4 . 1.0)
(org-level-5 . 1.1)
(org-level-6 . 1.1)
(org-level-7 . 1.1)
(org-level-8 . 1.1)))
(set-face-attribute (car face) nil :height (cdr face)))
;; Change bullet lists hyphens
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) ""))))))
(with-eval-after-load 'org
(org-babel-do-load-languages
'org-babel-load-languages
'((js . t)
(lua . t)
(python . t)))
(push '("conf-unix" . conf-unix) org-src-lang-modes))
(with-eval-after-load 'org
(require 'org-tempo)
(add-to-list 'org-modules 'org-tempo)
;; Block templates for commonly used languages
(add-to-list 'org-structure-template-alist '("sh" . "src sh"))
(add-to-list 'org-structure-template-alist '("js" . "src js"))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(add-to-list 'org-structure-template-alist '("cf" . "src conf"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")))
(with-eval-after-load 'org
(require 'org-indent)
(add-to-list 'org-modules 'org-indent)
;; Make some org faces use fixed pitch fonts
(set-face-attribute 'org-block nil :inherit 'fixed-pitch)
(set-face-attribute 'org-verbatim nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-document-info nil :foreground "dark orange")
(set-face-attribute 'org-document-info-keyword nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-indent nil :inherit '(org-hide fixed-pitch))
(set-face-attribute 'org-link nil :underline t)
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-table nil :inherit 'fixed-pitch :foreground "#83a598"))
(with-eval-after-load 'org
(require 'org-habit)
(add-to-list 'org-modules 'org-habit)
(setq org-habit-graph-column 60)
;; Set custom scaling for Org headings
(dolist (face '((org-level-1 . 1.2)
(org-level-2 . 1.1)
(org-level-3 . 1.05)
(org-level-4 . 1.0)
(org-level-5 . 1.1)
(org-level-6 . 1.1)
(org-level-7 . 1.1)
(org-level-8 . 1.1)))
(set-face-attribute (car face) nil :height (cdr face)))
;; Change bullet lists hyphens
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "")))))))
(use-package org-bullets
:hook (org-mode . org-bullets-mode)
:config
(setq org-bullets-bullet-list '("" "" "" "" "")))
;; Temporarily show the emphasis markers around markup elements
(use-package org-appear
:hook (org-mode . org-appear-mode))
;; Set margins for Org mode
(defun my-org-visual-fill ()
(setq visual-fill-column-width 100
@ -371,49 +402,56 @@
:hook (org-mode . org-make-toc-mode)))
(use-package keycast
:commands keycast-mode
:commands (keycast-mode keycast-log-mode)
:defer t
:config
;; We need to lazy-load its minor mode
(define-minor-mode keycast-mode
"Show current command and its keybinding in the mode line."
:global t
(if keycast-mode
(progn
(add-hook 'pre-command-hook 'keycast--update t)
(add-to-list 'global-mode-string '("" mode-line-keycast " ")))
(remove-hook 'pre-command-hook 'keycast--update)
(setq global-mode-string (remove '("" mode-line-keycast " ") global-mode-string)))))
(define-minor-mode keycast-mode
"Show current command and its keybinding in the mode line."
:global t
(if keycast-mode
(progn
(add-hook 'pre-command-hook 'keycast--update t)
(add-to-list 'global-mode-string '("" mode-line-keycast " ")))
(remove-hook 'pre-command-hook 'keycast--update)
(setq global-mode-string (remove '("" mode-line-keycast " ") global-mode-string)))))
(use-package counsel
:bind (([remap execute-extended-command] . counsel-M-x)
([remap switch-to-buffer] . counsel-switch-buffer)
("C-x b" . counsel-switch-buffer)
([remap find-file] . counsel-find-file)
([remap describe-bindings] . counsel-descbinds)
:map minibuffer-local-map
("C-r" . 'counsel-minibuffer-history))
:config
(counsel-mode 1)
(setq ivy-initial-inputs-alist nil)) ;; Dont' start searches with ^
(use-package ivy
:diminish
:demand
:bind (("C-s" . swiper)
:map ivy-minibuffer-map
("TAB" . ivy-alt-done)
("C-l" . ivy-alt-done)
("C-j" . ivy-next-line)
("C-k" . ivy-previous-line)
:map ivy-switch-buffer-map
("C-k" . ivy-previous-line)
("C-l" . ivy-done)
("C-c" . ivy-switch-buffer-kill)
:map ivy-reverse-i-search-map
("C-k" . ivy-previous-line)
("C-d" . ivy-reverse-i-search-kill))
:config
(ivy-mode 1)
(setq ivy-extra-directories nil))
(use-package ivy-rich
:after ivy
:init (ivy-rich-mode 1))
(use-package ivy-prescient
:after (counsel ivy)
:custom
(ivy-prescient-enable-filtering nil)
:config
(prescient-persist-mode 1)
(ivy-prescient-mode 1))
(use-package ibuffer
:bind ([remap list-buffers] . ibuffer)
:init
@ -429,23 +467,17 @@
;; (use-package wakatime-mode
;; :config (global-wakatime-mode))
;; Temporarily show the emphasis markers around markup elements
(use-package org-appear
:hook (org-mode . org-appear-mode))
;; Make the parentheses nesting clearer
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
(use-package which-key
:init (which-key-mode)
:defer t
:diminish which-key-mode
:config
(which-key-mode)
(setq which-key-idle-delay 0.3))
(use-package ivy-rich
:init (ivy-rich-mode 1))
(use-package auto-package-update
:config
(setq auto-package-update-delete-old-versions t
@ -455,6 +487,7 @@
(auto-package-update-at-time "09:00"))
(use-package helpful
:commands (helpful-callable helpful-variable helpful-command -helpful-key)
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable)
@ -477,8 +510,7 @@
(use-package projectile
:diminish projectile-mode
:config (projectile-mode)
:bind-keymap
("C-c p" . projectile-command-map)
:bind ("C-c p" . projectile-command-map)
:init
(when (file-directory-p "~/dev")
(setq projectile-project-search-path '("~/dev/projects" "~/dev/work")))
@ -488,12 +520,14 @@
compilation-save-buffers-predicate #'projectile-current-project-buffer-p))
(use-package counsel-projectile
:after (counsel projectile)
:config
(counsel-projectile-mode)
(setq counsel-projectile-switch-project-action #'counsel-projectile-switch-project-action-dired))
;; Git porcelain
(use-package magit
:bind ("C-x g" . magit)
:config
(setq magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
@ -541,8 +575,7 @@
("<C-backspace>" . (lambda () (interactive) (vterm-send-key (kbd "C-w"))))))
(use-package term
:bind(("C-c t" . term)
:map term-mode-map
:bind(:map term-mode-map
("C-c C-c" . term-interrupt-subjob)
("M-p" . term-send-up)
("M-n" . term-send-down)
@ -584,6 +617,7 @@
;;; Mode specific packages
(use-package js
:ensure nil ; built-in
:mode "\\.js\\?x\\'"
:custom
(js-indent-level 2)
(js-highlight-level 3)
@ -604,14 +638,17 @@
:init (electric-pair-mode -1)
:hook ((emacs-lisp-mode js-mode sh-mode) . electric-pair-local-mode))
(use-package lua-mode)
(use-package lua-mode
:mode "\\.lua\\'")
(use-package sh-script
:ensure nil ; built-in
:init
(setq sh-indentation 2))
:mode ("\\.sh\\'")
:config
(setq sh-basic-offset 2))
(use-package sass-mode)
(use-package sass-mode
:mode ("\\.s[ca]ss\\'"))
(use-package markdown-mode
:mode
@ -621,9 +658,11 @@
:init
(setq markdown-command "multimarkdown"))
(use-package css-mode)
(use-package css-mode
:mode ("\\.css\\'"))
(use-package json-mode)
(use-package json-mode
:mode ("\\.js\\'" "\\.json\\'"))
(use-package emmet-mode
:hook (js-mode css-mode)
@ -632,10 +671,13 @@
emmet-self-closing-tag-style " /"))
(use-package yaml-mode
:mode "\\.yml\\'")
:mode ("\\.yml\\'" "\\.yaml\\'"))
(use-package pug-mode
:mode ("\\.pug\\'" "\\.jade\\'"))
(use-package pug-mode)
(use-package stylus-mode)
(use-package stylus-mode
:mode ("\\.styl"))
;; LSP
(use-package lsp-mode
@ -700,7 +742,8 @@
aw-background nil))
;; Directory tree
(use-package treemacs)
(use-package treemacs
:bind ("C-c t" . treemacs))
(use-package treemacs-projectile
:after (treemacs projectile))
@ -749,6 +792,11 @@
:after company
:hook (company-mode . company-box-mode))
(use-package company-prescient
:after company
:config
(company-prescient-mode 1))
;; Misc
(use-package woman
:ensure nil ; built-in
@ -770,7 +818,6 @@
(require 'emms-setup)
(emms-all)
(emms-default-players)
(emms-mode-line -1)
(setq emms-source-file-default-directory "~/music"
emms-seek-seconds 15
emms-mode-line-active-p nil
@ -806,3 +853,6 @@
:quelpa
(ivy-emoji :fetcher github :repo "sbozzolo/ivy-emoji")
:bind (("C-c i e" . ivy-emoji)))
(provide 'init)
;;; init.el ends here
Loading…
Cancel
Save