From eb798b6a555601b3696e489bc27f51a7f18991bc Mon Sep 17 00:00:00 2001 From: Leni Ven Date: Wed, 14 Dec 2022 18:52:44 -0500 Subject: [PATCH] Restructure spacemacs and add macOS version of setup-home --- README.md | 3 +- home/spacemacs/layers.el | 9 ++-- home/spacemacs/setup-macos.sh | 13 +++++ home/spacemacs/spacemacs.el | 2 - home/spacemacs/user-config.el | 95 +++++++++++++++++++---------------- setup-home.sh | 31 +++++++----- 6 files changed, 91 insertions(+), 62 deletions(-) create mode 100755 home/spacemacs/setup-macos.sh diff --git a/README.md b/README.md index cc30bc7..30acdb3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ Common configuration files for: ## Setup -Execute `setup-home.sh` to create symbolic links. +Execute `setup-home.sh` to create symbolic links. Note that macOS users will +need to install `coreutils` to provide the `grealpath` utility. ## Docker Images diff --git a/home/spacemacs/layers.el b/home/spacemacs/layers.el index 15a8a18..8a77286 100644 --- a/home/spacemacs/layers.el +++ b/home/spacemacs/layers.el @@ -38,15 +38,18 @@ This function should only modify configuration layer settings." ;; 3 Checker (spell-checking :variables ;; Required: aspell - spell-checking-enable-by-default t - spell-checking-enable-auto-dictionary t) + spell-checking-enable-by-default t) syntax-checking ;; 4 Completion auto-completion helm ;; 6 Emacs - org + (org :variables + org-enable-notifications 't + org-start-notification-daemon-on-startup 't + org-enable-org-journal-support 't + ) semantic tabs diff --git a/home/spacemacs/setup-macos.sh b/home/spacemacs/setup-macos.sh new file mode 100755 index 0000000..20dc35f --- /dev/null +++ b/home/spacemacs/setup-macos.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +relative() { + grealpath --relative-to=$1 $2 +} + +DIR=~/Library/LaunchAgents/ +BASE=$(relative $DIR $PWD) +ln -s $BASE/daemon.plist ~/Library/LaunchAgents/gnu.emacs.daemon.plist + +DIR=~/Applications +BASE=$(relative $DIR $PWD) +ln -s $BASE/emacsclient.applescript ~/Applications/Spacemacs.app diff --git a/home/spacemacs/spacemacs.el b/home/spacemacs/spacemacs.el index 6db5228..7c9a772 100644 --- a/home/spacemacs/spacemacs.el +++ b/home/spacemacs/spacemacs.el @@ -40,9 +40,7 @@ This function is called at the very end of Spacemacs startup, after layer configuration. Put your configuration code here, except for variables that should be set before packages are loaded." - (exec-path-from-shell-initialize) (load "~/common/home/spacemacs/user-config.el") - ) ;; This is the stub that spacemacs works with. diff --git a/home/spacemacs/user-config.el b/home/spacemacs/user-config.el index d8a9ecf..b0cb6c5 100644 --- a/home/spacemacs/user-config.el +++ b/home/spacemacs/user-config.el @@ -1,31 +1,23 @@ -;; Centaur -(setq - centaur-tabs-set-icons t - centaur-tabs-set-bar 'over - centaur-tabs-set-close-button t - centaur-tabs-style "wave" - centaur-tabs-set-bar 'under - centaur-tabs-set-modified-marker t - centaur-tabs-modified-marker "*" - centaur-tabs-cycle-scope 'tabs) -(setq - pdf-sync-backward-display-action t - pdf-sync-forward-display-action t) +;; Spacemacs itself +(exec-path-from-shell-initialize) +;; 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) -(setq centaur-tabs-style "wave") +;; Auto save upon defocus +(add-hook 'focus-out-hook + (defun save-current-buffer-if-needed () + (interactive) + (when (and (buffer-file-name) (buffer-modified-p)) + (save-buffer)))) -;; Ensures the pdf view mode doesn't get into emacs state. -;; If it does get into emacs state, checked by -;; (describe-variable 'evil-state) -;; Use M-x evil-normal-state or M-x evil-force-evilified-state to revert. -(evil-set-initial-state 'pdf-view-mode 'evilified) - -;; Displaying whitespaces +;; Display (spacemacs/toggle-whitespace-globally-on) (setq whitespace-display-mappings ;; all numbers are Unicode codepoint in decimal. ⁖ (insert-char 182 1) @@ -60,29 +52,39 @@ (set-face-attribute 'font-lock-constant-face nil :foreground "#ecbd3d") -;(add-hook 'after-make-frame-functions 'spacemacs/enable-transparency) (spacemacs/enable-transparency) -;; Auto save upon defocus -(add-hook 'focus-out-hook - (defun save-current-buffer-if-needed () - (interactive) - (when (and (buffer-file-name) (buffer-modified-p)) - (save-buffer)))) +;; Org mode +(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0)) + +;; Spellchecking +(setq ispell-dictionary "english") + +;; Centaur +(setq + centaur-tabs-set-icons t + centaur-tabs-set-bar 'over + centaur-tabs-set-close-button t + centaur-tabs-style "wave" + centaur-tabs-set-bar 'under + centaur-tabs-set-modified-marker t + centaur-tabs-modified-marker "*" + centaur-tabs-cycle-scope 'tabs) +(setq + pdf-sync-backward-display-action t + pdf-sync-forward-display-action t) + + + +;; Ensures the pdf view mode doesn't get into emacs state. +;; If it does get into emacs state, checked by +;; (describe-variable 'evil-state) +;; Use M-x evil-normal-state or M-x evil-force-evilified-state to revert. +(evil-set-initial-state 'pdf-view-mode 'evilified) + + ;; 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 - c-default-style "stroustrup" - c-basic-offset 2 - lsp-clients-clangd-args - '("-j=4" - "--clang-tidy" - "--header-insertion=never" - "--pch-storage=memory" - )) (setq css-indent-offset 2) (smart-tabs-insinuate @@ -97,6 +99,16 @@ (lambda () (setq indent-tabs-mode t))) +;; C/C++ +(setq + -default-style "stroustrup" + -basic-offset 2 + lsp-clients-clangd-args + '("-j=4" + "--clang-tidy" + "--header-insertion=never" + "--pch-storage=memory" + )) (highlight-doxygen-global-mode 1) (set-face-attribute 'highlight-doxygen-comment nil :background nil @@ -108,6 +120,3 @@ ;;(with-eval-after-load 'merlin ;; (setq merlin-command 'opam)) ;;(require 'merlin) - -;; Prevent creation of lockfiles for angular -(setq create-lockfiles nil) diff --git a/setup-home.sh b/setup-home.sh index 22d551a..af92a53 100755 --- a/setup-home.sh +++ b/setup-home.sh @@ -1,9 +1,21 @@ #!/bin/bash + +if [[ "$OSTYPE" == "darwin"* ]]; then + relative() { + grealpath --relative-to=$1 $2 + } +else + relative() { + realpath --relative-to=$1 $2 + } +fi + # Calculate directory relative to $HOME DIR=$HOME -BASE=$(realpath --relative-to=$DIR $PWD) +BASE=$(relative $DIR $PWD) pushd $HOME >> /dev/null +ln -vs $BASE/home/rustfmt.toml .rustfmt.toml ln -vs $BASE/home/bashrc .bashrc ln -vs $BASE/home/clang-format .clang-format ln -vs $BASE/home/latexmkrc .latexmkrc @@ -13,34 +25,27 @@ ln -vs $BASE/home/vimrc .vimrc cp $BASE/home/spacemacs/spacemacs.el .spacemacs popd >> /dev/null -# Create ftplugin links +# Vim DIR=$HOME/.vim/after/ftplugin -BASE=$(realpath --relative-to=$DIR $PWD) +BASE=$(relative $DIR $PWD) mkdir -p $DIR pushd $DIR >> /dev/null ln -vs $BASE/home/vim/after/ftplugin/tex.vim . popd >> /dev/null DIR=$HOME/.vim/colors -BASE=$(realpath --relative-to=$DIR $PWD) +BASE=$(relative $DIR $PWD) mkdir -p $DIR pushd $DIR >> /dev/null ln -vs $BASE/home/vim/vim-amino/amino.vim . popd >> /dev/null - +# Fish DIR=$HOME/.config/fish -BASE=$(realpath --relative-to=$DIR $PWD) +BASE=$(relative $DIR $PWD) mkdir -p $DIR pushd $DIR >> /dev/null ln -vs $BASE/home/fish/config.fish . ln -vs $BASE/home/fish/fishd_color . ln -vs $BASE/home/fish/functions . popd >> /dev/null - -DIR=$HOME/.config/rustfmt -BASE=$(realpath --relative-to=$DIR $PWD) -mkdir -p $DIR -pushd $DIR >> /dev/null -ln -vs $BASE/home/rustfmt.toml . -popd >> /dev/null