feat(emacs): add priime-general.el
Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
parent
e99a639325
commit
e8bbfc318d
5 changed files with 171 additions and 219 deletions
|
@ -1,216 +0,0 @@
|
|||
;;; general.el --- General configuration settings.
|
||||
;;; Commentary:
|
||||
;; General configuration for Emacs.
|
||||
;;; Code:
|
||||
|
||||
(require 'nano-theme)
|
||||
(require 'view)
|
||||
|
||||
|
||||
|
||||
;; Backups
|
||||
(setq make-backup-files nil)
|
||||
(setq vc-make-backup-files nil)
|
||||
(setq kept-new-versions nil)
|
||||
(setq kept-old-versions nil)
|
||||
(setq delete-old-versions t)
|
||||
(rassq-delete-all 'auto-save-mode auto-mode-alist)
|
||||
(setq auto-save-default nil)
|
||||
(setq auto-save-mode -1)
|
||||
(setq backup-directory-alist '(("." . "~/.emacs.d/backups/")))
|
||||
(setq backup-by-copying t)
|
||||
(setq create-lockfiles nil)
|
||||
|
||||
;; UI
|
||||
(menu-bar-mode -1)
|
||||
(tool-bar-mode -1)
|
||||
(scroll-bar-mode -1)
|
||||
(setq inhibit-startup-message t)
|
||||
(setq-default truncate-lines t)
|
||||
|
||||
;; Bell
|
||||
(setq visible-bell nil)
|
||||
(setq ring-bell-function 'ignore)
|
||||
|
||||
;; Scratch
|
||||
(setq initial-scratch-message nil)
|
||||
|
||||
;; Line
|
||||
(column-number-mode 1)
|
||||
(size-indication-mode 1)
|
||||
(setq display-line-numbers 'relative)
|
||||
|
||||
;; Window splitting
|
||||
(setq-default split-height-threshold
|
||||
(cond ((string= (system-name) "framework") 100)
|
||||
;; default emacs value
|
||||
(t 80)))
|
||||
(setq-default split-width-threshold
|
||||
(cond ((string= (system-name) "framework") 180)
|
||||
;; default emacs value
|
||||
(t 160)))
|
||||
|
||||
;; Tabs
|
||||
(setq-default tab-width 2)
|
||||
|
||||
;; Cursor
|
||||
(blink-cursor-mode 1)
|
||||
|
||||
;; Theme & Font
|
||||
(load-theme 'nano t)
|
||||
(nano-light)
|
||||
|
||||
(defvar priime--font-config
|
||||
(cond ((string= (system-name) "framework") '("Roboto Mono Medium" "Roboto" 10 0.8))
|
||||
((eq system-type 'gnu/linux) '("Roboto Mono Medium" "Roboto" 10 0.8))
|
||||
((eq system-type 'darwin) '("Menlo" "Verdana" 12 1))
|
||||
(t '("Roboto Mono" "Roboto" 10 0.8))))
|
||||
|
||||
(defvar priime-fixed-font (-first-item priime--font-config))
|
||||
(defvar priime-variable-font (-second-item priime--font-config))
|
||||
(defvar priime-font-size (-third-item priime--font-config))
|
||||
(defvar priime-fixed-height (-fourth-item priime--font-config))
|
||||
|
||||
(add-to-list 'default-frame-alist `(font . ,(format "%s-10" priime-fixed-font)))
|
||||
(set-frame-font (format "%s %d" priime-fixed-font priime-font-size))
|
||||
|
||||
(custom-set-faces
|
||||
'(region ((t (:inherit nano-subtle :background "#EBE5F5"))))
|
||||
'(lazy-highlight ((t (:inherit region))))
|
||||
`(variable-pitch ((t (:inherit default :family ,priime-variable-font :height 125 :weight regular))))
|
||||
`(fixed-pitch ((t (:family ,priime-fixed-font :height ,priime-fixed-height :inherit nil))))
|
||||
`(shr-text ((t (:inherit variable-pitch-text :family ,priime-variable-font))))
|
||||
'(line-number ((t (:inherit default :foreground "#98A4AE"))))
|
||||
'(line-number-current-line ((t (:inherit default :foreground "#98A4AE")))))
|
||||
(set-face-attribute 'italic nil
|
||||
:family 'inherit
|
||||
:slant 'italic
|
||||
:weight 'medium
|
||||
:foreground nano-light-foreground)
|
||||
|
||||
;; Use spaces instead of tabs
|
||||
(setq-default indent-tabs-mode nil)
|
||||
|
||||
;; Column width
|
||||
(setq fill-column 80)
|
||||
|
||||
;; Directional window moving
|
||||
(windmove-default-keybindings)
|
||||
|
||||
;; Auto file refresh
|
||||
(global-auto-revert-mode t)
|
||||
|
||||
;; Improve performance in files with long lines
|
||||
(global-so-long-mode t)
|
||||
|
||||
;; Automatically follow symlinks
|
||||
(setq vc-follow-symlinks t)
|
||||
|
||||
;; Undos
|
||||
(setq undo-limit 200000)
|
||||
|
||||
;; Whitespace
|
||||
(setq-default show-trailing-whitespace t)
|
||||
|
||||
;; Sentences
|
||||
;; Emacs thinks that sentences ends with period and two spaces,
|
||||
;; disable this.
|
||||
(setq sentence-end-double-space nil)
|
||||
|
||||
;; Scrolling
|
||||
(put 'scroll-left 'disabled nil)
|
||||
(put 'scroll-right 'disabled nil)
|
||||
(setq scroll-conservatively 101)
|
||||
|
||||
;; Keybindings
|
||||
(keymap-global-set "<f6>"
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(split-window-right)
|
||||
(windmove-right)))
|
||||
(keymap-global-set "<f7>"
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(split-window-below)
|
||||
(windmove-down)))
|
||||
(keymap-global-set "<f8>"
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(split-window-right)
|
||||
(windmove-right)
|
||||
(if (projectile-project-p)
|
||||
(projectile-run-vterm)
|
||||
(vterm))
|
||||
(balance-windows)))
|
||||
(keymap-global-set "C-M-j" (lambda () (interactive) (scroll-up 1)))
|
||||
(keymap-global-set "C-M-k" (lambda () (interactive) (scroll-down 1)))
|
||||
(keymap-global-set "C-x <"
|
||||
(lambda (arg)
|
||||
(interactive "P")
|
||||
(let ((amt (or arg 1)))
|
||||
(scroll-right amt))))
|
||||
(keymap-global-set "C-x >"
|
||||
(lambda (arg)
|
||||
(interactive "P")
|
||||
(let ((amt (or arg 1)))
|
||||
(scroll-left amt))))
|
||||
(keymap-global-unset "C-x f")
|
||||
(keymap-global-set "C-x f f" #'set-fill-column)
|
||||
(keymap-global-set "C-x f i" #'display-fill-column-indicator-mode)
|
||||
(keymap-global-set "C-x f a" #'auto-fill-mode)
|
||||
(keymap-global-set "C-x f n" #'toggle-display-line-numbers)
|
||||
(keymap-global-set "C-v" #'View-scroll-half-page-forward)
|
||||
(keymap-global-set "M-v" #'View-scroll-half-page-backward)
|
||||
|
||||
(defun toggle-display-line-numbers ()
|
||||
"Toggle the display of line numbers."
|
||||
(interactive)
|
||||
(cond ((equal display-line-numbers t)
|
||||
(setq display-line-numbers 'relative))
|
||||
((equal display-line-numbers 'relative)
|
||||
(setq display-line-numbers t))
|
||||
(t
|
||||
(progn
|
||||
(display-line-numbers-mode 1)
|
||||
(setq display-line-numbers t)))))
|
||||
|
||||
;; Garbage Collection
|
||||
(setq gc-cons-threshold 50000000)
|
||||
|
||||
;; Confirmations
|
||||
(fset 'yes-or-no-p 'y-or-n-p)
|
||||
|
||||
;; Disable suspend state
|
||||
(keymap-global-unset "C-z")
|
||||
(keymap-global-unset "C-x C-z")
|
||||
|
||||
;; emacs-nativecomp
|
||||
(setq native-comp-async-report-warnings-errors nil)
|
||||
(setq warning-minimum-level :error)
|
||||
|
||||
;; From https://stackoverflow.com/questions/8309769/how-can-i-prevent-emacs-from-opening-new-window-for-compilation-output
|
||||
|
||||
;; Helper for compilation. Close the compilation window if
|
||||
;; there was no error at all. (emacs wiki)
|
||||
(defun compilation-exit-autoclose (status code msg)
|
||||
;; If M-x compile exists with a 0
|
||||
(when (and (eq status 'exit) (zerop code))
|
||||
;; then bury the *compilation* buffer, so that C-x b doesn't go there
|
||||
(bury-buffer)
|
||||
;; and delete the *compilation* window
|
||||
(delete-window (get-buffer-window (get-buffer "*compilation*"))))
|
||||
;; Always return the anticipated result of compilation-exit-message-function
|
||||
(cons msg code))
|
||||
;; Specify my function (maybe I should have done a lambda function)
|
||||
(setq compilation-exit-message-function 'compilation-exit-autoclose)
|
||||
|
||||
;; shell
|
||||
(setq vterm-shell (or (executable-find "fish") shell-file-name))
|
||||
(keymap-global-set "C-c v" #'vterm)
|
||||
|
||||
;; epa/gpg
|
||||
(setq epa-file-encrypt-to '("lucas@priime.dev"))
|
||||
(setq epa-file-select-keys 1)
|
||||
|
||||
(provide 'general)
|
||||
;;; general.el ends here
|
|
@ -17,7 +17,9 @@
|
|||
(use-package embark-consult :straight t)
|
||||
(use-package wgrep :straight t)
|
||||
(use-package no-littering :straight t)
|
||||
(use-package vterm :straight t)
|
||||
(use-package vterm :straight t
|
||||
:custom (vterm-shell (or (executable-find "fish") shell-file-name))
|
||||
:bind (("C-c v" . #'vterm)))
|
||||
(use-package rg :straight t)
|
||||
(use-package anzu :straight t
|
||||
:init
|
||||
|
|
163
.emacs.d/include/priime-general.el
Normal file
163
.emacs.d/include/priime-general.el
Normal file
|
@ -0,0 +1,163 @@
|
|||
;;; priime-general.el --- General package configuration
|
||||
;;; Commentary:
|
||||
;; Provides general configuration for Emacs.
|
||||
;;; Code:
|
||||
|
||||
(require 'dash)
|
||||
(require 'view)
|
||||
|
||||
;;; Font
|
||||
(defvar priime--font-config
|
||||
(cond ((string= (system-name) "framework") '("Roboto Mono Medium" "Roboto" 10 0.8))
|
||||
((eq system-type 'gnu/linux) '("Roboto Mono Medium" "Roboto" 10 0.8))
|
||||
((eq system-type 'darwin) '("Menlo" "Verdana" 12 1))
|
||||
(t '("Roboto Mono" "Roboto" 10 0.8))))
|
||||
|
||||
(defvar priime-fixed-font (-first-item priime--font-config))
|
||||
(defvar priime-variable-font (-second-item priime--font-config))
|
||||
(defvar priime-font-size (-third-item priime--font-config))
|
||||
(defvar priime-fixed-height (-fourth-item priime--font-config))
|
||||
|
||||
;;; Keybindings
|
||||
(defun priime-split-right ()
|
||||
"Split the window right and move to it."
|
||||
(interactive)
|
||||
(split-window-right)
|
||||
(windmove-right))
|
||||
|
||||
(defun priime-split-down ()
|
||||
"Split the window down and move to it."
|
||||
(interactive)
|
||||
(split-window-below)
|
||||
(windmove-down))
|
||||
|
||||
(defun priime-split-terminal ()
|
||||
"Split a terminal on the right and move to it."
|
||||
(priime-split-right)
|
||||
(if (projectile-project-p)
|
||||
(projectile-run-vterm)
|
||||
(vterm))
|
||||
(balance-windows))
|
||||
|
||||
(defun priime-scroll-up ()
|
||||
"Scroll up granularly."
|
||||
(interactive)
|
||||
(scroll-up 1))
|
||||
|
||||
(defun priime-scroll-down ()
|
||||
"Scroll down granularly."
|
||||
(interactive)
|
||||
(scroll-down 1))
|
||||
|
||||
(defun priime-scroll-left (arg)
|
||||
"Scroll left granularly by ARG."
|
||||
(interactive "P")
|
||||
(let ((amt (or arg 1)))
|
||||
(scroll-left amt)))
|
||||
|
||||
(defun priime-scroll-right (arg)
|
||||
"Scroll right granularly by ARG."
|
||||
(interactive "P")
|
||||
(let ((amt (or arg 1)))
|
||||
(scroll-right amt)))
|
||||
|
||||
(defun priime-toggle-line-numbers ()
|
||||
"Toggle the display of line numbers."
|
||||
(interactive)
|
||||
(cond ((equal display-line-numbers t)
|
||||
(setq display-line-numbers 'relative))
|
||||
((equal display-line-numbers 'relative)
|
||||
(setq display-line-numbers t))
|
||||
(t
|
||||
(display-line-numbers-mode 1)
|
||||
(setq display-line-numbers t))))
|
||||
|
||||
(defvar-keymap priime-fill-map
|
||||
"f" #'set-fill-column
|
||||
"i" #'display-fill-column-indicator-mode
|
||||
"a" #'auto-fill-mode
|
||||
"n" #'priime-toggle-line-numbers)
|
||||
|
||||
;;; Configuration
|
||||
|
||||
(use-package emacs
|
||||
:custom
|
||||
;; Backups
|
||||
(make-backup-files nil)
|
||||
(vc-make-backup-files nil)
|
||||
(kept-new-versions nil)
|
||||
(delete-old-versions t)
|
||||
(auto-save-default nil)
|
||||
(backup-directory-alist '(("." . "~/.emacs.d/backups/")))
|
||||
(backup-by-copying t)
|
||||
(create-lockfiles nil)
|
||||
;; UI
|
||||
(inhibit-startup-message t)
|
||||
(truncate-lines t)
|
||||
(visible-bell nil)
|
||||
(ring-bell-function 'ignore)
|
||||
(initial-scratch-message nil)
|
||||
(display-line-numbers 'relative)
|
||||
(split-height-threshold
|
||||
(cond ((string= (system-name) "framework") 100)
|
||||
(t 80)))
|
||||
(split-width-threshold
|
||||
(cond ((string= (system-name) "framework") 180)
|
||||
(t 160)))
|
||||
;; Editing
|
||||
(indent-tabs-mode nil)
|
||||
(fill-column 80)
|
||||
(vc-follow-symblinks t)
|
||||
(undo-limit 200000)
|
||||
(show-trailing-whitespace t)
|
||||
(sentence-end-double-space nil)
|
||||
(scroll-conservatively 101)
|
||||
;; GC
|
||||
(gc-cons-threshold 50000000)
|
||||
;; emacs-nativecomp
|
||||
(native-comp-async-report-warnings-errors nil)
|
||||
(warning-minimum-level :error)
|
||||
;; Misc
|
||||
(epa-file-encrypt-to '("lucas@priime.dev"))
|
||||
(epa-file-select-keys 1)
|
||||
|
||||
:custom-face
|
||||
(default ((t (:family ,priime-fixed-font :weight medium))))
|
||||
(region ((t (:inherit nano-subtle :background "#EBE5F5"))))
|
||||
(italic) ((t (:family inherit :slant italic :weight medium)))
|
||||
(lazy-highlight ((t (:inherit region))))
|
||||
(variable-pitch ((t (:inherit default :family ,priime-variable-font :height 125 :weight regular))))
|
||||
(fixed-pitch ((t (:family ,priime-fixed-font :height ,priime-fixed-height :inherit nil))))
|
||||
(shr-text ((t (:inherit variable-pitch-text :family ,priime-variable-font))))
|
||||
(line-number ((t (:inherit default :foreground "#98A4AE"))))
|
||||
(line-number-current-line ((t (:inherit default :foreground "#98A4AE"))))
|
||||
|
||||
:bind
|
||||
(("C-v" . View-scroll-half-page-forward)
|
||||
("M-v" . View-scroll-half-page-backward))
|
||||
|
||||
:init
|
||||
(menu-bar-mode -1)
|
||||
(tool-bar-mode -1)
|
||||
(scroll-bar-mode -1)
|
||||
(column-number-mode 1)
|
||||
(size-indication-mode 1)
|
||||
(blink-cursor-mode 1)
|
||||
(global-auto-revert-mode 1)
|
||||
(global-so-long-mode 1)
|
||||
|
||||
(rassq-delete-all 'auto-save-mode auto-mode-alist)
|
||||
(windmove-default-keybindings)
|
||||
(put 'scroll-left 'disabled nil)
|
||||
(put 'scroll-right 'disabled nil)
|
||||
|
||||
(fset 'yes-or-no-p 'y-or-n-p)
|
||||
|
||||
(keymap-global-unset "C-z")
|
||||
(keymap-global-unset "C-x C-z")
|
||||
(keymap-global-unset "C-x f")
|
||||
(keymap-global-set "C-x f" priime-fill-map))
|
||||
|
||||
(provide 'priime-general)
|
||||
|
||||
;;; priime-general.el ends here
|
|
@ -5,7 +5,10 @@
|
|||
|
||||
(use-package nano-theme
|
||||
:straight '(nano-theme :type git :host github
|
||||
:repo "rougier/nano-theme"))
|
||||
:repo "rougier/nano-theme")
|
||||
:init
|
||||
(load-theme 'nano t)
|
||||
(nano-light))
|
||||
(use-package all-the-icons :straight t)
|
||||
(use-package neotree :straight t
|
||||
:after (all-the-icons)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue