sf mono + symbols nerd font, modeline, rust-mode

This commit is contained in:
Janis 2024-12-26 15:54:58 +01:00
parent fe09732b80
commit d9f7ec85f5

213
init.org
View file

@ -194,7 +194,6 @@ Add package repositories and rank them by priority
** Global Variables ** Global Variables
#+begin_src emacs-lisp #+begin_src emacs-lisp
(set-language-environment "UTF-8") (set-language-environment "UTF-8")
(column-number-mode t) ;; Show current column number in mode line
(delete-selection-mode t) ;; Replace selected text when yanking (delete-selection-mode t) ;; Replace selected text when yanking
(dirtrack-mode t) ;; Directory tracking in shell (dirtrack-mode t) ;; Directory tracking in shell
(global-so-long-mode t) ;; Mitigate performance for long lines (global-so-long-mode t) ;; Mitigate performance for long lines
@ -320,16 +319,20 @@ Font size [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Face-Attri
#+end_src #+end_src
#+begin_src emacs-lisp #+begin_src emacs-lisp
(set-face-attribute 'default nil :font "monospace" :height nemo/font-height-mono) (set-face-attribute 'default nil :font "monospace" :height nemo/font-height-mono)
(set-face-attribute 'fixed-pitch nil :font "monospace" :height nemo/font-height-mono) (set-face-attribute 'fixed-pitch nil :font "monospace" :height nemo/font-height-mono)
(set-face-attribute 'variable-pitch nil :font "sans-serif" :height nemo/font-height-sans) (set-face-attribute 'variable-pitch nil :font "sans-serif" :height nemo/font-height-sans)
(when (member "SF Mono" (font-family-list)) ;; (when (member "SF Mono" (font-family-list))
(set-face-attribute 'default nil :font "SF Mono" :height nemo/font-height-mono) ;; (set-face-attribute 'default nil :font "SF Mono" :height nemo/font-height-mono)
(set-face-attribute 'fixed-pitch nil :family "SF Mono" :height nemo/font-height-mono)) ;; (set-face-attribute 'fixed-pitch nil :family "SF Mono" :height nemo/font-height-mono))
(defvar nemo/nerd-fonts-font "Symbols Nerd Font")
(when (member "SF Pro Text" (font-family-list)) (when (member nemo/nerd-fonts-font (font-family-list))
(set-face-attribute 'variable-pitch nil :family "SF Pro Text" :height nemo/font-height-sans)) (set-fontset-font t nil (font-spec :height nemo/font-height-mono :font "Symbols Nerd Font")))
(when (member "SF Pro Text" (font-family-list))
(set-face-attribute 'variable-pitch nil :family "SF Pro Text" :height nemo/font-height-sans))
#+end_src #+end_src
Use nerd-icons and apple emojis Use nerd-icons and apple emojis
@ -355,97 +358,100 @@ Use both fixed and variable pitched fonts and faces.
** Mode Line ** Mode Line
Honestly not very happy with this at the moment, but it's kind of hacked together based on Sophie's and Amit's modelines. Honestly not very happy with this at the moment, but it's kind of hacked together based on Sophie's and Amit's modelines.
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; Mode line setup ;; Mode line setup
(setq-default (column-number-mode t) ;; Show current column number in mode line
mode-line-format (setq-default
'(" " mode-line-format
(:propertize "λ" face font-lock-comment-face) '((:propertize "λ" face mode-line-emphasis)
" " " "
mode-line-buffer-identification mode-line-buffer-identification
" " " "
; read-only or modified status ; read-only or modified status
(:eval (:eval
(cond (buffer-read-only (cond (buffer-read-only
(propertize " RO " 'face 'mode-line-read-only-face)) (propertize "  " 'face 'mode-line-read-only-face))
((buffer-modified-p) ((buffer-modified-p)
(propertize " ** " 'face 'mode-line-modified-face)) (propertize " 󰳻 " 'face 'mode-line-modified-face))
(t " "))) (t "  " 'face 'mode-line)))
; directory and buffer/file name ; directory and buffer/file name
(:propertize (:eval (shorten-directory default-directory 30)) (:propertize (:eval (shorten-directory default-directory 30))
face mode-line-folder-face) face mode-line-folder-face)
(:propertize "%b" (:propertize "%b"
face mode-line-filename-face) face mode-line-filename-face)
;; Version control info ;; Version control info
(:eval (when-let (vc vc-mode) (:eval (when-let (vc vc-mode)
;; Use a pretty branch symbol in front of the branch name ;; Use a pretty branch symbol in front of the branch name
(list (propertize "  " 'face 'font-lock-comment-face) (list (propertize " " 'face 'font-lock-keyword-face)
(propertize (substring vc 5) (propertize (substring vc 5)
'face 'font-lock-comment-face)))) 'face 'font-lock-doc-face))))
" " " "
(:propertize mode-name) (:propertize mode-name)
; (global-mode-string global-mode-string) (:propertize (length local-minor-modes))
(:eval (propertize ; (global-mode-string global-mode-string)
" " 'display (:eval (propertize
`((space :align-to " " 'display
(- (+ right right-fringe right-margin) `((space :align-to
,(+ 2 (string-width "%4l:%c"))))))) (- (+ right right-fringe right-margin)
;; Line and column numbers ,(+ 1 (string-width "%p %4l:%c")))))))
(:propertize "%4l:" face mode-line-position-face) ;; Line and column numbers
(:eval (propertize "%c" 'face mode-line-percent-position
(if (>= (current-column) 80) " "
'mode-line-80col-face (:propertize "%4l:" face mode-line-position-face)
'mode-line-position-face))) (:eval (propertize "%c" 'face
)) (if (>= (current-column) 80)
'mode-line-80col-face
'mode-line-position-face)))
))
;; Helper function ;; Helper function
(defun shorten-directory (dir max-length) (defun shorten-directory (dir max-length)
"Show up to `max-length' characters of a directory name `dir'." "Show up to `max-length' characters of a directory name `dir'."
(let ((path (reverse (split-string (abbreviate-file-name dir) "/"))) (let ((path (reverse (split-string (abbreviate-file-name dir) "/")))
(output "")) (output ""))
(when (and path (equal "" (car path))) (when (and path (equal "" (car path)))
(setq path (cdr path))) (setq path (cdr path)))
(while (and path (< (length output) (- max-length 4))) (while (and path (< (length output) (- max-length 4)))
(setq output (concat (car path) "/" output)) (setq output (concat (car path) "/" output))
(setq path (cdr path))) (setq path (cdr path)))
(when path (when path
(setq output (concat ".../" output))) (setq output (concat ".../" output)))
output)) output))
;; Extra mode line faces ;; Extra mode line faces
(make-face 'mode-line-read-only-face) (make-face 'mode-line-read-only-face)
(make-face 'mode-line-modified-face) (make-face 'mode-line-modified-face)
(make-face 'mode-line-folder-face) (make-face 'mode-line-folder-face)
(make-face 'mode-line-filename-face) (make-face 'mode-line-filename-face)
(make-face 'mode-line-position-face) (make-face 'mode-line-position-face)
(make-face 'mode-line-mode-face) (make-face 'mode-line-mode-face)
(make-face 'mode-line-80col-face) (make-face 'mode-line-80col-face)
(set-face-attribute 'mode-line-read-only-face nil (set-face-attribute 'mode-line-read-only-face nil
:inherit 'mode-line-face :inherit 'mode-line-face
:foreground "#4271ae" :foreground "#4271ae"
:box '(:line-width 2 :color "#4271ae")) :box '(:line-width 2 :color "#4271ae"))
(set-face-attribute 'mode-line-modified-face nil (set-face-attribute 'mode-line-modified-face nil
:inherit 'mode-line-face :inherit 'mode-line-face
:foreground "#c82829" :foreground "#c82829"
:background "#ffffff" :background "#ffffff"
:box '(:line-width 2 :color "#c82829")) :box '(:line-width 2 :color "#c82829"))
(set-face-attribute 'mode-line-folder-face nil (set-face-attribute 'mode-line-folder-face nil
:inherit 'mode-line-face :inherit 'mode-line-face
:foreground "gray60") :foreground "gray60")
(set-face-attribute 'mode-line-filename-face nil (set-face-attribute 'mode-line-filename-face nil
:inherit 'mode-line-face :inherit 'mode-line-face
:foreground "#eab700" :foreground "#eab700"
:weight 'bold) :weight 'bold)
(set-face-attribute 'mode-line-position-face nil (set-face-attribute 'mode-line-position-face nil
:inherit 'mode-line-face) :inherit 'mode-line-face)
(set-face-attribute 'mode-line-mode-face nil (set-face-attribute 'mode-line-mode-face nil
:inherit 'mode-line-face :inherit 'mode-line-face
:foreground "gray80") :foreground "gray80")
(set-face-attribute 'mode-line-80col-face nil (set-face-attribute 'mode-line-80col-face nil
:inherit 'mode-line-position-face :inherit 'mode-line-position-face
:foreground "black" :background "#eab700") :foreground "black" :background "#eab700")
#+end_src #+end_src
* Packages * Packages
@ -1458,12 +1464,12 @@ hlsl-mode:
** Rust ** Rust
[[https://github.com/rust-lang/rust-mode][=rust-mode=]] [[https://github.com/rust-lang/rust-mode][=rust-mode=]]
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package rust-mode ;; (use-package rust-mode
:straight t ;; :straight t
;; :hook (rust-mode . lsp-mode) ;; ;; :hook (rust-mode . lsp-mode)
:init ;; :init
(setq rust-mode-treesitter-derive t ;; (setq rust-mode-treesitter-derive t
)) ;; ))
#+end_src #+end_src
[[https://github.com/brotzeit/rustic][=rustic-mode=]] [[https://github.com/brotzeit/rustic][=rustic-mode=]]
@ -1498,7 +1504,10 @@ hlsl-mode:
) )
:config :config
(setq rustic-format-on-save t (setq rustic-format-on-save t
rustic-format-on-save-method #'rustic-format-buffer rust-format-on-save t
rust-mode-treesitter-derive t
rustic-format-trigger 'on-save
;; rustic-format-on-save-method #'rustic-format-buffer
rustic-analyzer-command '("/usr/bin/rust-analyzer") rustic-analyzer-command '("/usr/bin/rust-analyzer")
) )
) )