Spacemacs: Modify structure and add custom dark/light themes.

Specifically:
1. Separate the face attribute configuration part to `user-init` using theming.
2. Fix some indentation problems in `layers.el`
3. Reorganise code
This commit is contained in:
Leni Ven 2023-01-13 21:09:39 -08:00
parent c01c180946
commit d5935f525d
5 changed files with 256 additions and 214 deletions

View File

@ -90,7 +90,7 @@ It should only modify the values of Spacemacs settings."
;; directory. A string value must be a path to an image format supported ;; directory. A string value must be a path to an image format supported
;; by your Emacs build. ;; by your Emacs build.
;; If the value is nil then no banner is displayed. (default 'official) ;; If the value is nil then no banner is displayed. (default 'official)
dotspacemacs-startup-banner 'official dotspacemacs-startup-banner 'random
;; List of items to show in startup buffer or an association list of ;; List of items to show in startup buffer or an association list of
;; the form `(list-type . list-size)`. If nil then it is disabled. ;; the form `(list-type . list-size)`. If nil then it is disabled.
@ -128,11 +128,21 @@ It should only modify the values of Spacemacs settings."
;; (default nil) ;; (default nil)
dotspacemacs-initial-scratch-message nil dotspacemacs-initial-scratch-message nil
;; List of themes, the first of the list is loaded when spacemacs starts. ;; List of themes, the first of the list is loaded when spacemacs starts.
;; Press `SPC T n' to cycle to the next theme in the list (works great ;; Press `SPC T n' to cycle to the next theme in the list (works great
;; with 2 themes variants, one dark and one light) ;; with 2 themes variants, one dark and one light)
dotspacemacs-themes '(spacemacs-dark dotspacemacs-themes '(noctilux
spacemacs-light) occidental)
;; Default font or prioritized list of fonts. The `:size' can be specified as
;; a non-negative integer (pixel size), or a floating-point (point size).
;; Point size is recommended, because it's device independent. (default 10.0)
;; Placing this in front of themes.
dotspacemacs-default-font '("Source Code Pro"
:size 14.0
:weight normal
:width normal)
;; Set the theme for the Spaceline. Supported themes are `spacemacs', ;; Set the theme for the Spaceline. Supported themes are `spacemacs',
;; `all-the-icons', `custom', `doom', `vim-powerline' and `vanilla'. The ;; `all-the-icons', `custom', `doom', `vim-powerline' and `vanilla'. The
@ -147,14 +157,6 @@ It should only modify the values of Spacemacs settings."
;; (default t) ;; (default t)
dotspacemacs-colorize-cursor-according-to-state t dotspacemacs-colorize-cursor-according-to-state t
;; Default font or prioritized list of fonts. The `:size' can be specified as
;; a non-negative integer (pixel size), or a floating-point (point size).
;; Point size is recommended, because it's device independent. (default 10.0)
dotspacemacs-default-font '("Source Code Pro"
:size 14.0
:weight normal
:width normal)
;; The leader key (default "SPC") ;; The leader key (default "SPC")
dotspacemacs-leader-key "SPC" dotspacemacs-leader-key "SPC"

View File

@ -1,33 +1,31 @@
"Layer configuration: (setq-default
This function should only modify configuration layer settings." ;; Base distribution to use. This is a layer contained in the directory
(setq-default ;; `+distribution'. For now available distributions are `spacemacs-base'
;; Base distribution to use. This is a layer contained in the directory ;; or `spacemacs'. (default 'spacemacs)
;; `+distribution'. For now available distributions are `spacemacs-base' dotspacemacs-distribution 'spacemacs
;; or `spacemacs'. (default 'spacemacs)
dotspacemacs-distribution 'spacemacs
;; Lazy installation of layers (i.e. layers are installed only when a file ;; Lazy installation of layers (i.e. layers are installed only when a file
;; with a supported type is opened). Possible values are `all', `unused' ;; with a supported type is opened). Possible values are `all', `unused'
;; and `nil'. `unused' will lazy install only unused layers (i.e. layers ;; and `nil'. `unused' will lazy install only unused layers (i.e. layers
;; not listed in variable `dotspacemacs-configuration-layers'), `all' will ;; not listed in variable `dotspacemacs-configuration-layers'), `all' will
;; lazy install any layer that support lazy installation even the layers ;; lazy install any layer that support lazy installation even the layers
;; listed in `dotspacemacs-configuration-layers'. `nil' disable the lazy ;; listed in `dotspacemacs-configuration-layers'. `nil' disable the lazy
;; installation feature and you have to explicitly list a layer in the ;; installation feature and you have to explicitly list a layer in the
;; variable `dotspacemacs-configuration-layers' to install it. ;; variable `dotspacemacs-configuration-layers' to install it.
;; (default 'unused) ;; (default 'unused)
dotspacemacs-enable-lazy-installation 'unused dotspacemacs-enable-lazy-installation 'unused
;; If non-nil then Spacemacs will ask for confirmation before installing ;; If non-nil then Spacemacs will ask for confirmation before installing
;; a layer lazily. (default t) ;; a layer lazily. (default t)
dotspacemacs-ask-for-lazy-installation t dotspacemacs-ask-for-lazy-installation t
;; List of additional paths where to look for configuration layers. ;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (i.e. `~/.mycontribs/') ;; Paths must have a trailing slash (i.e. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '() dotspacemacs-configuration-layer-path '()
;; List of configuration layers to load. ;; List of configuration layers to load.
dotspacemacs-configuration-layers dotspacemacs-configuration-layers
'( '(
;; ---------------------------------------------------------------- ;; ----------------------------------------------------------------
;; Example of useful layers you may want to use right away. ;; Example of useful layers you may want to use right away.
;; Uncomment some layer names and press `SPC f e R' (Vim style) or ;; Uncomment some layer names and press `SPC f e R' (Vim style) or
@ -78,8 +76,7 @@ This function should only modify configuration layer settings."
bibtex bibtex
(latex :variables (latex :variables
latex-enable-folding t latex-enable-folding t
latex-enable-magic t latex-enable-magic t)
)
;; Scripting Languages ;; Scripting Languages
shell-scripts shell-scripts
@ -106,7 +103,6 @@ This function should only modify configuration layer settings."
c-c++-lsp-enable-semantic-highlight 'rainbow c-c++-lsp-enable-semantic-highlight 'rainbow
clang-format-style "file" clang-format-style "file"
) )
;; 16 Readers ;; 16 Readers
pdf pdf
@ -117,13 +113,20 @@ This function should only modify configuration layer settings."
;; 20 Tagging ;; 20 Tagging
cscope cscope
;; 21 themes
colors
theming ; Modification of themes
themes-megapack
;; 22 Tools ;; 22 Tools
(cmake :variables (cmake :variables
cmake-backend 'lsp) cmake-backend 'lsp)
debug debug
docker docker
finance ;; Required: ledger finance ;; Required: ledger
lsp (lsp :variables
lsp-headerline-breadcrumb-enable t
lsp-headerline-breadcrumb-segments '(symbols))
nginx nginx
(shell :variables (shell :variables
shell-default-height 30 shell-default-height 30
@ -133,16 +136,16 @@ This function should only modify configuration layer settings."
) )
;; List of additional packages that will be installed without being wrapped ;; List of additional packages that will be installed without being wrapped
;; in a layer (generally the packages are installed only and should still be ;; in a layer (generally the packages are installed only and should still be
;; loaded using load/require/use-package in the user-config section below in ;; loaded using load/require/use-package in the user-config section below in
;; this file). If you need some configuration for these packages, then ;; this file). If you need some configuration for these packages, then
;; consider creating a layer. You can also put the configuration in ;; consider creating a layer. You can also put the configuration in
;; `dotspacemacs/user-config'. To use a local version of a package, use the ;; `dotspacemacs/user-config'. To use a local version of a package, use the
;; `:location' property: '(your-package :location "~/path/to/your-package/") ;; `:location' property: '(your-package :location "~/path/to/your-package/")
;; Also include the dependencies as they will not be resolved automatically. ;; Also include the dependencies as they will not be resolved automatically.
dotspacemacs-additional-packages dotspacemacs-additional-packages
'( '(
all-the-icons all-the-icons
centaur-tabs centaur-tabs
smart-tabs-mode smart-tabs-mode
@ -156,18 +159,18 @@ This function should only modify configuration layer settings."
highlight-doxygen highlight-doxygen
) )
;; A list of packages that cannot be updated. ;; A list of packages that cannot be updated.
dotspacemacs-frozen-packages '() dotspacemacs-frozen-packages '()
;; A list of packages that will not be installed and loaded. ;; A list of packages that will not be installed and loaded.
;; Exclude orgit to fix mode problem in PDFView ;; Exclude orgit to fix mode problem in PDFView
dotspacemacs-excluded-packages '(orgit) dotspacemacs-excluded-packages '(orgit)
;; Defines the behaviour of Spacemacs when installing packages. ;; Defines the behaviour of Spacemacs when installing packages.
;; Possible values are `used-only', `used-but-keep-unused' and `all'. ;; Possible values are `used-only', `used-but-keep-unused' and `all'.
;; `used-only' installs only explicitly used packages and deletes any unused ;; `used-only' installs only explicitly used packages and deletes any unused
;; packages as well as their unused dependencies. `used-but-keep-unused' ;; packages as well as their unused dependencies. `used-but-keep-unused'
;; installs only the used packages but won't delete unused ones. `all' ;; installs only the used packages but won't delete unused ones. `all'
;; installs *all* packages supported by Spacemacs and never uninstalls them. ;; installs *all* packages supported by Spacemacs and never uninstalls them.
;; (default is `used-only') ;; (default is `used-only')
dotspacemacs-install-packages 'used-only) dotspacemacs-install-packages 'used-only)

View File

@ -25,6 +25,7 @@ This function is called immediately after `dotspacemacs/init', before layer
configuration. configuration.
It is mostly for variables that should be set before packages are loaded. It is mostly for variables that should be set before packages are loaded.
If you are unsure, try setting them in `dotspacemacs/user-config' first." If you are unsure, try setting them in `dotspacemacs/user-config' first."
(load "~/common/home/spacemacs/user-init.el")
) )
(defun dotspacemacs/user-load () (defun dotspacemacs/user-load ()

View File

@ -2,15 +2,6 @@
(exec-path-from-shell-initialize) (exec-path-from-shell-initialize)
(spacemacs/enable-transparency) (spacemacs/enable-transparency)
;; Typing
(setq evil-indent-convert-tabs nil)
(setq-default indent-tabs-mode t)
(setq-default tab-width 2)
;; Key Bindings
(evil-ex-define-cmd "q" 'kill-this-buffer)
(evil-ex-define-cmd "quit" 'evil-quit)
;; Auto save upon defocus ;; Auto save upon defocus
(add-hook 'focus-out-hook (add-hook 'focus-out-hook
(defun save-current-buffer-if-needed () (defun save-current-buffer-if-needed ()
@ -18,40 +9,6 @@
(when (and (buffer-file-name) (buffer-modified-p)) (when (and (buffer-file-name) (buffer-modified-p))
(save-buffer)))) (save-buffer))))
;; Display
(spacemacs/toggle-whitespace-globally-on)
(setq whitespace-display-mappings
;; all numbers are Unicode codepoint in decimal. ⁖ (insert-char 182 1)
'(
(space-mark 32 [183] [46]) ; 32 SPACE 「 」, 183 MIDDLE DOT 「·」, 46 FULL STOP 「.」
(newline-mark 10 [172 10]) ; 10 LINE FEED, 172 Not Sign「¬」
(tab-mark 9 [10141 9] [92 9]) ; 9 TAB, 10141 Triangle-headed rightwards arrow 「➝」
))
(set-face-attribute 'whitespace-space nil
:background nil
:foreground "gray30")
(set-face-attribute 'whitespace-space-after-tab nil
:background nil
:foreground "gray30")
(set-face-attribute 'whitespace-tab nil
:background nil
:foreground "gray30")
(set-face-attribute 'whitespace-newline nil
:background nil
:foreground "gray30")
(set-face-attribute 'whitespace-line nil
:background "gray20"
:foreground nil)
;; Disabling this since we use smart indenting
(set-face-attribute 'whitespace-indentation nil
:background nil
:foreground "gray30")
;; Syntax highlighting
(set-face-attribute 'font-lock-type-face nil
:foreground "#55fe55")
(set-face-attribute 'font-lock-constant-face nil
:foreground "#ecbd3d")
;; Org mode ;; Org mode
(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0)) (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
@ -85,6 +42,9 @@
;; Mixed indent mode (in conjunction with smart-tabs-mode) ;; Mixed indent mode (in conjunction with smart-tabs-mode)
(setq evil-indent-convert-tabs nil)
(setq-default indent-tabs-mode t)
(setq-default tab-width 2)
(setq css-indent-offset 2) (setq css-indent-offset 2)
(smart-tabs-insinuate (smart-tabs-insinuate
'c 'c
@ -109,9 +69,41 @@
"--pch-storage=memory" "--pch-storage=memory"
)) ))
(highlight-doxygen-global-mode 1) (highlight-doxygen-global-mode 1)
(set-face-attribute 'highlight-doxygen-comment nil
:background nil
:slant 'italic)
;; whitespace mode
(spacemacs/toggle-whitespace-globally-on)
(defun common-whitespace-program-hook ()
(setq whitespace-style '(face spaces tabs newline trailing space-mark tab-mark newline-mark lines-tail))
(interactive)
(whitespace-mode t)
(setq whitespace-line-column 80)
)
(add-hook 'text-mode-hook #'(lambda ()
(setq whitespace-style '(face spaces tabs newline trailing space-mark tab-mark newline-mark))
(interactive)
(whitespace-mode t)
(setq whitespace-line-column 'nil)))
(add-hook 'latex-mode-hook 'common-whitespace-program-hook)
(add-hook 'prog-mode-hook 'common-whitespace-program-hook)
(setq whitespace-display-mappings
;; all numbers are Unicode codepoint in decimal. ⁖ (insert-char 182 1)
'(
(space-mark 32 [183] [46]) ; 32 SPACE 「 」, 183 MIDDLE DOT 「·」, 46 FULL STOP 「.」
(newline-mark 10 [172 10]) ; 10 LINE FEED, 172 Not Sign「¬」
(tab-mark 9 [10141 9] [92 9]) ; 9 TAB, 10141 Triangle-headed rightwards arrow 「➝」
))
;; Syntax highlighting
;(set-face-attribute 'font-lock-type-face nil
; :foreground "#55fe55")
;(set-face-attribute 'font-lock-constant-face nil
; :foreground "#ecbd3d")
;;(setq opam-share (substring (shell-command-to-string ;;(setq opam-share (substring (shell-command-to-string
;; "opam config var share 2> /dev/null") 0 -1)) ;; "opam config var share 2> /dev/null") 0 -1))

View File

@ -0,0 +1,44 @@
(setq
theming-modifications
'(
(spacemacs-dark
(whitespace-space :background unspecified
:foreground "gray30")
(whitespace-space-after-tab :foreground "gray30")
(whitespace-tab :background unspecified)
(whitespace-newline :foreground "gray30")
(whitespace-line :background unspecified)
(whitespace-indentation :foreground "gray30")
(highlight-doxygen-comment :slant italic)
)
(noctilux
(whitespace-space :background unspecified
:foreground "gray30")
(whitespace-space-after-tab :foreground "gray30")
(whitespace-tab :background unspecified
:foreground "gray30")
(whitespace-newline :foreground "gray30")
(whitespace-line :background unspecified)
(whitespace-indentation :foreground "gray30")
(header-line :background unspecified
:box "gray80"
:inverse-video nil)
(highlight-doxygen-comment :slant italic)
)
(occidental
(highlight :background "#9EC4EB") ;; The default is too bright
(whitespace-space :background unspecified
:foreground "gray70")
(whitespace-space-after-tab :foreground "gray70")
(whitespace-tab :background unspecified
:foreground "gray70")
(whitespace-newline :foreground "gray70")
(whitespace-line :background unspecified)
(whitespace-indentation :foreground "gray70")
(header-line :background unspecified
:box "gray20"
:inverse-video nil)
(highlight-doxygen-comment :slant italic)
)))
(spacemacs/update-theme)