147 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			EmacsLisp
		
	
	
	
	
	
			
		
		
	
	
			147 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			EmacsLisp
		
	
	
	
	
	
| ;; GENERAL UI
 | |
| (setq x-stretch-cursor t
 | |
|       blink-cursor-mode nil
 | |
|       show-paren-delay 0
 | |
|       scroll-conservatively 5
 | |
|       scroll-margin 0
 | |
|       mouse-wheel-scroll-amount '(2 ((shift) . 2)) ;; one line at a time
 | |
|       mouse-wheel-progressive-speed nil ;; don't accelerate scrolling
 | |
|       mouse-wheel-follow-mouse 't ;; scroll window under mouse
 | |
|       scroll-step 2 ;; keyboard scroll two lines at a time
 | |
|       frame-resize-pixelwise t
 | |
|       frame-title-format "Allmighty Editor w/o Kitchen Sink")
 | |
| 
 | |
| ;; Highlight matching parens
 | |
| (show-paren-mode t)
 | |
| ;; Show line numbers on the left side of the buffer
 | |
| (global-display-line-numbers-mode 0)
 | |
| ;; Highlight current horizontal line with a different background
 | |
| (global-hl-line-mode t)
 | |
| ;; Also display the current column index in e.g. the mode-line
 | |
| (column-number-mode t)
 | |
| ;; Show tooltip on hover in minibuffer
 | |
| (tooltip-mode 0)
 | |
| ;; Default encoding
 | |
| (set-language-environment "UTF-8")
 | |
| ;; Show line that indicates maximum number of "allowed" characters
 | |
| (add-hook 'prog-mode-hook 'display-fill-column-indicator-mode)
 | |
| 
 | |
| ;; FONT SETUP
 | |
| ;; TODO: Configure your font
 | |
| (defvar phga/font "Jetbrains Mono")
 | |
| (defvar phga/font-size "19")
 | |
| (defvar phga/font-family (concat phga/font ":size=" phga/font-size))
 | |
| ;; These are required to have the correct font size with the first frame (emacs server)
 | |
| (add-to-list 'default-frame-alist `(font . ,phga/font-family))
 | |
| 
 | |
| ;; TEXT-SCALE: Scale text globally
 | |
| (defvar phga/text-scale-amount 2)
 | |
| (defvar phga/text-scale--current-size (string-to-number phga/font-size))
 | |
| (defun phga/text-scale-adjust ()
 | |
|   "Adjust the size of the frame-font by `phga/text-scale-amount'."
 | |
|   (interactive)
 | |
|   (phga/text-scale--adjust))
 | |
| 
 | |
| (defun phga/text-scale--scale (inc)
 | |
|   "Scale the frame-font by `phga/text-scale-amount'.
 | |
| If INC is not nil increase the font size else decrease it"
 | |
|   (if inc (setq phga/text-scale--current-size
 | |
|                 (+ phga/text-scale--current-size phga/text-scale-amount))
 | |
|     (setq phga/text-scale--current-size
 | |
|           (- phga/text-scale--current-size phga/text-scale-amount)))
 | |
|   (set-frame-font (concat phga/font ":size="
 | |
|                           (number-to-string phga/text-scale--current-size)) t t))
 | |
| 
 | |
| (defun phga/text-scale--adjust ()
 | |
|   "Actual function which will call itself with the temporary keymap to scale the text."
 | |
|   (let ((ev last-command-event)
 | |
| 	      (echo-keystrokes nil))
 | |
|     (pcase (event-basic-type ev)
 | |
|       ((or ?= ?k) (phga/text-scale--scale t))
 | |
|       ((or ?- ?j) (phga/text-scale--scale nil))
 | |
|       ((or ?0) (progn (set-frame-font phga/font-family t t)
 | |
|                       (setq phga/text-scale--current-size
 | |
|                             (string-to-number phga/font-size))
 | |
|                       (error "Reset to normal text scale"))))
 | |
|     (message "Use j/=, k/-, 0 for further adjustment")
 | |
|     (set-transient-map
 | |
|      (let ((map (make-sparse-keymap)))
 | |
|        (dolist (key '(?- ?j ?k ?= ?0))
 | |
|          (define-key map (vector (list key))
 | |
|                      (lambda () (interactive) (phga/text-scale--adjust))))
 | |
|        map))))
 | |
| 
 | |
| ;; LIGATURES
 | |
| (straight-use-package 'ligature)
 | |
| ;; Enable the "www" ligature in every possible major mode
 | |
| ;; (ligature-set-ligatures 't '("www"))
 | |
| ;; Enable all Cascadia Code ligatures in programming modes
 | |
| (ligature-set-ligatures
 | |
|  'prog-mode
 | |
|  '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
 | |
|    ":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
 | |
|    "!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
 | |
|    "<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
 | |
|    "<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
 | |
|    "..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
 | |
|    "~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
 | |
|    "[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
 | |
|    ">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
 | |
|    "<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
 | |
|    "##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
 | |
|    "?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
 | |
|    "\\\\" "://"))
 | |
| 
 | |
| (global-ligature-mode t)
 | |
| 
 | |
| ;; THEMES
 | |
| ;; SHANTY
 | |
| (straight-use-package 'shanty-themes)
 | |
| (defvar phga/dark-theme 'shanty-themes-dark)
 | |
| (defvar phga/light-theme 'shanty-themes-light)
 | |
| 
 | |
| (defvar phga/current-theme phga/dark-theme)
 | |
| (load-theme phga/current-theme t)
 | |
| 
 | |
| (defun phga/cycle-themes ()
 | |
|   "Cycle through my preferred dark and light theme"
 | |
|   (interactive)
 | |
|   (if (eq phga/current-theme phga/dark-theme)
 | |
|       (progn
 | |
|         (disable-theme phga/dark-theme)
 | |
|         (load-theme phga/light-theme t)
 | |
|         (message "Loaded light theme")
 | |
|         (setq phga/current-theme phga/light-theme))
 | |
|     (progn
 | |
|       (disable-theme phga/light-theme)
 | |
|       (load-theme phga/dark-theme t)
 | |
|       (message "Loaded dark theme")
 | |
|       (setq phga/current-theme phga/dark-theme))))
 | |
| 
 | |
| ;; MODE-LINE
 | |
| ;; https://emacs.stackexchange.com/questions/5529/how-to-right-align-some-items-in-the-modeline
 | |
| (defun simple-mode-line-render (left right)
 | |
|   "Return a string of `window-width' length containing LEFT, and RIGHT aligned respectively."
 | |
|   (let* ((available-width (- (window-total-width) (length left) 2)))
 | |
|     (format (format " %%s %%%ds " available-width) left right)))
 | |
| 
 | |
| (setq-default mode-line-format
 | |
|               '((:eval (simple-mode-line-render
 | |
|                         ;; left
 | |
|                         (format-mode-line
 | |
|                          '(""
 | |
|                            ;; (:eval (propertize "%* %b"))
 | |
|                            (:eval (propertize "%* %b" 'face 'mode-line-buffer-id))
 | |
|                            evil-mode-line-tag
 | |
|                            (:eval (propertize "%m"))))
 | |
|                         ;; (:eval (propertize "%m" 'face 'font-lock-comment-face))))
 | |
|                         ;; right
 | |
|                         (format-mode-line mode-line-position)))))
 | |
| 
 | |
| ;; FIXES
 | |
| ;; Shell mode line highlighted
 | |
| ;; (set-face-attribute 'comint-highlight-prompt nil :inherit nil)
 | |
| ;; (custom-set-faces '(comint-highlight-prompt ((t nil))))
 | |
| 
 | |
| (message "ui.el was succesfully loaded")
 | |
| (provide 'ui) |