From 0fa3658cd8e283825dcd0a54ce1579dec55eb568 Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Sun, 4 Mar 2018 20:36:40 -0500 Subject: [PATCH] reorganize spacemacs-base distribution into +spacemacs/spacemacs-xxx This idea is to have the spacemacs-base distribution only configure defaults for built-in packages. Those buit-in packages are now configured in the new layer spacemacs-defaults. Additionally some other packages of spacemacs-base have been dispatched to better suiting spacemacs layers. Projectile has been moved to the new layer spacemacs-project - Move the following packages to bootsrap distributio layer: - exec-path-from-shell - evil-evilified-state - holy-mode - hybrid-mode - spacemacs-theme - ace-window has been moved to spacemacs-navigation - centered-buffer-mode has been moved to spacemacs-editing-visual - pcre2el has been moved to spacemacs-editing - evil-escape and evil-visualstar have been moved to spacemacs-evil --- .../+distributions/spacemacs-base/README.org | 39 --- .../+distributions/spacemacs-base/layers.el | 12 + .../spacemacs-bootstrap/README.org | 4 +- .../evil-evilified-state.el | 0 .../local/holy-mode/holy-mode.el | 0 .../local/hybrid-mode/hybrid-mode.el | 0 .../spacemacs-bootstrap/packages.el | 66 ++++- layers/+distributions/spacemacs/layers.el | 3 +- .../spacemacs-completion/README.org | 15 +- .../+spacemacs/spacemacs-defaults/README.org | 13 + .../spacemacs-defaults}/config.el | 2 +- .../spacemacs-defaults}/funcs.el | 58 +--- .../spacemacs-defaults}/keybindings.el | 2 +- .../local/help-fns+/help-fns+.el | 0 .../spacemacs-defaults}/packages.el | 248 +++--------------- .../spacemacs-editing-visual/funcs.el | 41 +++ .../centered-buffer-mode.el | 0 .../spacemacs-editing-visual/packages.el | 3 + .../+spacemacs/spacemacs-editing/README.org | 1 + .../+spacemacs/spacemacs-editing/packages.el | 25 ++ layers/+spacemacs/spacemacs-evil/README.org | 16 ++ layers/+spacemacs/spacemacs-evil/packages.el | 18 ++ .../+spacemacs/spacemacs-navigation/funcs.el | 28 ++ .../spacemacs-navigation/packages.el | 16 ++ .../+spacemacs/spacemacs-project/README.org | 14 + .../+spacemacs/spacemacs-project/packages.el | 80 ++++++ 26 files changed, 382 insertions(+), 322 deletions(-) create mode 100644 layers/+distributions/spacemacs-base/layers.el rename layers/+distributions/{spacemacs-base => spacemacs-bootstrap}/local/evil-evilified-state/evil-evilified-state.el (100%) rename layers/+distributions/{spacemacs-base => spacemacs-bootstrap}/local/holy-mode/holy-mode.el (100%) rename layers/+distributions/{spacemacs-base => spacemacs-bootstrap}/local/hybrid-mode/hybrid-mode.el (100%) create mode 100644 layers/+spacemacs/spacemacs-defaults/README.org rename layers/{+distributions/spacemacs-base => +spacemacs/spacemacs-defaults}/config.el (99%) rename layers/{+distributions/spacemacs-base => +spacemacs/spacemacs-defaults}/funcs.el (96%) rename layers/{+distributions/spacemacs-base => +spacemacs/spacemacs-defaults}/keybindings.el (99%) rename layers/{+distributions/spacemacs-base => +spacemacs/spacemacs-defaults}/local/help-fns+/help-fns+.el (100%) rename layers/{+distributions/spacemacs-base => +spacemacs/spacemacs-defaults}/packages.el (63%) create mode 100644 layers/+spacemacs/spacemacs-editing-visual/funcs.el rename layers/{+distributions/spacemacs-base => +spacemacs/spacemacs-editing-visual}/local/centered-buffer-mode/centered-buffer-mode.el (100%) create mode 100644 layers/+spacemacs/spacemacs-project/README.org create mode 100644 layers/+spacemacs/spacemacs-project/packages.el diff --git a/layers/+distributions/spacemacs-base/README.org b/layers/+distributions/spacemacs-base/README.org index 263f0167e79d..398e08141926 100644 --- a/layers/+distributions/spacemacs-base/README.org +++ b/layers/+distributions/spacemacs-base/README.org @@ -11,42 +11,3 @@ This is the base distribution for Spacemacs. - Minimalistic approach to Spacemacs, contains only the core packages. Good starting point to make something completely new. This distribution should not be used for a new standalone Spacemacs installation except you have very good reasons to. - It contains the following packages: - - abbrev - - ace-window - - archive-mode - - bookmark - - centered-buffer-mode - - conf-mode - - dired - - electric-indent-mode - - ediff - - eldoc - - evil-escape - - evil-evilified-state - - evil-visualstar - - help-fns+ - - hi-lock - - holy-mode - - hybrid-mode - - image-mode - - imenu - - linum - - occur-mode - - package-menu - - page-break-lines - - pcre2el - - process-menu - - projectile - - recentf - - savehist - - saveplace - - spacemacs-theme - - subword - - tar-mode - - uniquify - - url - - visual-line-mode - - whitespace - - winner - - zone diff --git a/layers/+distributions/spacemacs-base/layers.el b/layers/+distributions/spacemacs-base/layers.el new file mode 100644 index 000000000000..690d6d6ec4a0 --- /dev/null +++ b/layers/+distributions/spacemacs-base/layers.el @@ -0,0 +1,12 @@ +;;; layers.el --- Spacemacs base distribution layers File +;; +;; Copyright (c) 2012-2018 Sylvain Benner & Contributors +;; +;; Author: Sylvain Benner +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +(configuration-layer/declare-layers '(spacemacs-defaults)) diff --git a/layers/+distributions/spacemacs-bootstrap/README.org b/layers/+distributions/spacemacs-bootstrap/README.org index 5ce47707a32b..c7392d50c71e 100644 --- a/layers/+distributions/spacemacs-bootstrap/README.org +++ b/layers/+distributions/spacemacs-bootstrap/README.org @@ -8,7 +8,9 @@ This layer loads the necessary packages for spacemacs to start-up. ** Features: -- Loads =evil= key bindings +- Loads =evil= key bindings and macros for auto-evilifcation of maps +- Loads =holy= and =hybrid= modes +- Loads the official Spacemacs theme - Loads =use-package= which is used to load other packages more easily - Loads =hydra= which is used to create transient modes - Loads =which-key= which is used to show keybindings in other modes diff --git a/layers/+distributions/spacemacs-base/local/evil-evilified-state/evil-evilified-state.el b/layers/+distributions/spacemacs-bootstrap/local/evil-evilified-state/evil-evilified-state.el similarity index 100% rename from layers/+distributions/spacemacs-base/local/evil-evilified-state/evil-evilified-state.el rename to layers/+distributions/spacemacs-bootstrap/local/evil-evilified-state/evil-evilified-state.el diff --git a/layers/+distributions/spacemacs-base/local/holy-mode/holy-mode.el b/layers/+distributions/spacemacs-bootstrap/local/holy-mode/holy-mode.el similarity index 100% rename from layers/+distributions/spacemacs-base/local/holy-mode/holy-mode.el rename to layers/+distributions/spacemacs-bootstrap/local/holy-mode/holy-mode.el diff --git a/layers/+distributions/spacemacs-base/local/hybrid-mode/hybrid-mode.el b/layers/+distributions/spacemacs-bootstrap/local/hybrid-mode/hybrid-mode.el similarity index 100% rename from layers/+distributions/spacemacs-base/local/hybrid-mode/hybrid-mode.el rename to layers/+distributions/spacemacs-bootstrap/local/hybrid-mode/hybrid-mode.el diff --git a/layers/+distributions/spacemacs-bootstrap/packages.el b/layers/+distributions/spacemacs-bootstrap/packages.el index d1f1056311b1..a41ebcc77f95 100644 --- a/layers/+distributions/spacemacs-bootstrap/packages.el +++ b/layers/+distributions/spacemacs-bootstrap/packages.el @@ -11,17 +11,30 @@ (setq spacemacs-bootstrap-packages '( + ;; bootstrap packages, + ;; `use-package' cannot be used for bootstrap packages configuration (async :step bootstrap) (bind-map :step bootstrap) (bind-key :step bootstrap) (diminish :step bootstrap) (evil :step bootstrap) + (exec-path-from-shell :step bootstrap + :toggle (or (spacemacs/system-is-mac) + (spacemacs/system-is-linux) + (eq window-system 'x))) (hydra :step bootstrap) (use-package :step bootstrap) (which-key :step bootstrap) + ;; pre packages, initialized aftert the bootstrap packages + ;; these packages can use use-package + (evil-evilified-state :location local :step pre :protected t) + (holy-mode :location local :step pre) + (hybrid-mode :location local :step pre) + (spacemacs-theme :location built-in) )) -;; Note: `use-package' cannot be used for bootstrap packages configuration + +;; bootstrap packages (defun spacemacs-bootstrap/init-async ()) @@ -272,6 +285,10 @@ (evil-declare-ignore-repeat 'spacemacs/next-error) (evil-declare-ignore-repeat 'spacemacs/previous-error)) +(defun spacemacs-bootstrap/init-exec-path-from-shell () + (require 'exec-path-from-shell) + (exec-path-from-shell-initialize)) + (defun spacemacs-bootstrap/init-hydra () (require 'hydra) (setq hydra-key-doc-function 'spacemacs//hydra-key-doc-function @@ -475,3 +492,50 @@ (which-key-mode) (spacemacs|diminish which-key-mode " Ⓚ" " K")) + +;; pre packages + +(defun spacemacs-bootstrap/init-evil-evilified-state () + (use-package evil-evilified-state) + (define-key evil-evilified-state-map (kbd dotspacemacs-leader-key) + spacemacs-default-map)) + +(defun spacemacs-bootstrap/init-holy-mode () + (use-package holy-mode + :commands holy-mode + :init + (progn + (when (eq 'emacs dotspacemacs-editing-style) + (holy-mode)) + (spacemacs|add-toggle holy-mode + :status holy-mode + :on (progn (when (bound-and-true-p hybrid-mode) + (hybrid-mode -1)) + (holy-mode)) + :off (holy-mode -1) + :documentation "Globally toggle holy mode." + :evil-leader "tEe") + (spacemacs|diminish holy-mode " Ⓔe" " Ee")))) + +(defun spacemacs-bootstrap/init-hybrid-mode () + (use-package hybrid-mode + :config + (progn + (when (eq 'hybrid dotspacemacs-editing-style) (hybrid-mode)) + (spacemacs|add-toggle hybrid-mode + :status hybrid-mode + :on (progn (when (bound-and-true-p holy-mode) + (holy-mode -1)) + (hybrid-mode)) + :off (hybrid-mode -1) + :documentation "Globally toggle hybrid mode." + :evil-leader "tEh") + (spacemacs|diminish hybrid-mode " Ⓔh" " Eh")))) + +(defun spacemacs-bootstrap/init-spacemacs-theme () + (use-package spacemacs-theme + :defer t + :init + (progn + (setq spacemacs-theme-comment-bg t) + (setq spacemacs-theme-org-height t)))) diff --git a/layers/+distributions/spacemacs/layers.el b/layers/+distributions/spacemacs/layers.el index 33515765603d..d2558a2cf957 100644 --- a/layers/+distributions/spacemacs/layers.el +++ b/layers/+distributions/spacemacs/layers.el @@ -1,4 +1,4 @@ -;;; layers.el --- Spacemacs Layer layers File +;;; layers.el --- Spacemacs distribution Layer layers File ;; ;; Copyright (c) 2012-2018 Sylvain Benner & Contributors ;; @@ -23,6 +23,7 @@ spacemacs-modeline spacemacs-navigation spacemacs-org + spacemacs-project spacemacs-purpose spacemacs-visual )) diff --git a/layers/+spacemacs/spacemacs-completion/README.org b/layers/+spacemacs/spacemacs-completion/README.org index d33a95c8c303..3b8758987f7f 100644 --- a/layers/+spacemacs/spacemacs-completion/README.org +++ b/layers/+spacemacs/spacemacs-completion/README.org @@ -5,9 +5,16 @@ - [[#features][Features:]] * Description -This layer adds basics for providing code-completion for various major modes -to Spacemacs. +This layer does basic setup for completion frameworks like =helm=, =ivy= and +=ido=. + +Its main role is to ensure sane defaults and consistent UI between =helm= +and =ivy= because even when you are using only one of them you could still +need to use the other (for instance a package that supports only =helm=). + +Advanced configuration of these packages can be found in their respective +layers in =+completion= layer directory. ** Features: -- Preconfiguration of =helm= and =ivy= for other layers to use. -- Adding of =ido-navigation= configuration and transient state. +- Base preconfiguration of =helm= and =ivy= for other layers to use. +- Basic support for =ido-navigation= configuration and transient state. diff --git a/layers/+spacemacs/spacemacs-defaults/README.org b/layers/+spacemacs/spacemacs-defaults/README.org new file mode 100644 index 000000000000..5bd3a8f8cce2 --- /dev/null +++ b/layers/+spacemacs/spacemacs-defaults/README.org @@ -0,0 +1,13 @@ +#+TITLE: spacemacs-defaults + +* Table of Contents :TOC_4_gh:noexport: +- [[#description][Description]] + - [[#features][Features:]] + +* Description +This layer configures mostly Emacs built-in packages to given them better +defaults. + +** Features: +See [[file:packages.el][packages.el]] for a list of all configured packages or use Spacemacs help system +with ~SPC h SPC spacemacs-defaults~ to browse all the configuration for this layer. diff --git a/layers/+distributions/spacemacs-base/config.el b/layers/+spacemacs/spacemacs-defaults/config.el similarity index 99% rename from layers/+distributions/spacemacs-base/config.el rename to layers/+spacemacs/spacemacs-defaults/config.el index f76c12339cca..049ef54055e1 100644 --- a/layers/+distributions/spacemacs-base/config.el +++ b/layers/+spacemacs/spacemacs-defaults/config.el @@ -1,4 +1,4 @@ -;;; config.el --- Spacemacs Base Layer configuration File +;;; config.el --- Spacemacs Defaults Layer configuration File ;; ;; Copyright (c) 2012-2018 Sylvain Benner & Contributors ;; diff --git a/layers/+distributions/spacemacs-base/funcs.el b/layers/+spacemacs/spacemacs-defaults/funcs.el similarity index 96% rename from layers/+distributions/spacemacs-base/funcs.el rename to layers/+spacemacs/spacemacs-defaults/funcs.el index 50c0025dea1b..c52270ae552d 100644 --- a/layers/+distributions/spacemacs-base/funcs.el +++ b/layers/+spacemacs/spacemacs-defaults/funcs.el @@ -1,4 +1,4 @@ -;;; funcs.el --- Spacemacs Base Layer functions File +;;; funcs.el --- Spacemacs Defaults Layer functions File ;; ;; Copyright (c) 2012-2018 Sylvain Benner & Contributors ;; @@ -134,37 +134,6 @@ automatically applied to." (while (condition-case nil (windmove-down) (error nil)) (delete-window)))) -(defun spacemacs/toggle-centered-buffer-mode () - "Toggle `spacemacs-centered-buffer-mode'." - (interactive) - (when (require 'centered-buffer-mode nil t) - (call-interactively 'spacemacs-centered-buffer-mode))) - -(defun spacemacs/toggle-centered-buffer-mode-frame () - "Open current buffer in the new frame centered and without mode-line." - (interactive) - (when (require 'centered-buffer-mode nil t) - (switch-to-buffer-other-frame (current-buffer) t) - (toggle-frame-fullscreen) - (run-with-idle-timer - ;; FIXME: We need this delay to make sure that the - ;; `toggle-frame-fullscreen' fully "finished" - ;; it will be better to use something more reliable - ;; instead :) - 1 - nil - (lambda () - (call-interactively 'spacemacs-centered-buffer-mode) - (setq mode-line-format nil))))) - -(defun spacemacs/centered-buffer-mode-full-width () - "Center buffer in the frame." - ;; FIXME Needs new key-binding. - (interactive) - (when (require 'centered-buffer-mode nil t) - (spacemacs/maximize-horizontally) - (call-interactively 'spacemacs-centered-buffer-mode))) - (defun spacemacs/useful-buffer-p (buffer) "Determines if a buffer is useful." (let ((buf-name (buffer-name buffer))) @@ -475,19 +444,6 @@ If the universal prefix argument is used then kill the buffer too." (kill-buffer-and-window) (delete-window))) -(defun spacemacs/ace-delete-window (&optional arg) - "Ace delete window. -If the universal prefix argument is used then kill the buffer too." - (interactive "P") - (require 'ace-window) - (aw-select - " Ace - Delete Window" - (lambda (window) - (when (equal '(4) arg) - (with-selected-window window - (spacemacs/kill-this-buffer arg))) - (aw-delete-window window)))) - ;; our own implementation of kill-this-buffer from menu-bar.el (defun spacemacs/kill-this-buffer (&optional arg) "Kill the current buffer. @@ -499,18 +455,6 @@ If the universal prefix argument is used then kill also the window." (kill-buffer-and-window) (kill-buffer)))) -(defun spacemacs/ace-kill-this-buffer (&optional arg) - "Ace kill visible buffer in a window. -If the universal prefix argument is used then kill also the window." - (interactive "P") - (require 'ace-window) - (let (golden-ratio-mode) - (aw-select - " Ace - Kill buffer in Window" - (lambda (window) - (with-selected-window window - (spacemacs/kill-this-buffer arg)))))) - ;; found at http://emacswiki.org/emacs/KillingBuffers (defun spacemacs/kill-other-buffers (&optional arg) "Kill all other buffers. diff --git a/layers/+distributions/spacemacs-base/keybindings.el b/layers/+spacemacs/spacemacs-defaults/keybindings.el similarity index 99% rename from layers/+distributions/spacemacs-base/keybindings.el rename to layers/+spacemacs/spacemacs-defaults/keybindings.el index 69bab6faf171..0723b8947fad 100644 --- a/layers/+distributions/spacemacs-base/keybindings.el +++ b/layers/+spacemacs/spacemacs-defaults/keybindings.el @@ -1,4 +1,4 @@ -;;; keybindings.el --- Spacemacs Base Layer key-bindings File +;;; keybindings.el --- Spacemacs Defaults Layer key-bindings File ;; ;; Copyright (c) 2012-2018 Sylvain Benner & Contributors ;; diff --git a/layers/+distributions/spacemacs-base/local/help-fns+/help-fns+.el b/layers/+spacemacs/spacemacs-defaults/local/help-fns+/help-fns+.el similarity index 100% rename from layers/+distributions/spacemacs-base/local/help-fns+/help-fns+.el rename to layers/+spacemacs/spacemacs-defaults/local/help-fns+/help-fns+.el diff --git a/layers/+distributions/spacemacs-base/packages.el b/layers/+spacemacs/spacemacs-defaults/packages.el similarity index 63% rename from layers/+distributions/spacemacs-base/packages.el rename to layers/+spacemacs/spacemacs-defaults/packages.el index 2b973fe107a6..864cc910228e 100644 --- a/layers/+distributions/spacemacs-base/packages.el +++ b/layers/+spacemacs/spacemacs-defaults/packages.el @@ -1,4 +1,4 @@ -;;; packages.el --- Spacemacs Base Layer packages File +;;; packages.el --- Spacemacs Defaults Layer packages File ;; ;; Copyright (c) 2012-2018 Sylvain Benner & Contributors ;; @@ -9,32 +9,19 @@ ;; ;;; License: GPLv3 -(setq spacemacs-base-packages +(setq spacemacs-defaults-packages '( (abbrev :location built-in) - ace-window (archive-mode :location built-in) (bookmark :location built-in) - (centered-buffer-mode :location local) (conf-mode :location built-in) (dired :location built-in) (dired-x :location built-in) (electric-indent-mode :location built-in) (ediff :location built-in) (eldoc :location built-in) - evil-escape - (evil-evilified-state :location local :step pre :protected t) - evil-visualstar - ;; some packages need to look for binaries, - ;; which means the path must be ready by then - (exec-path-from-shell :step pre - :toggle (or (spacemacs/system-is-mac) - (spacemacs/system-is-linux) - (eq window-system 'x))) (help-fns+ :location local) (hi-lock :location built-in) - (holy-mode :location local :step pre) - (hybrid-mode :location local :step pre) (image-mode :location built-in) (imenu :location built-in) (linum :location built-in) @@ -42,13 +29,10 @@ (package-menu :location built-in) ;; page-break-lines is shipped with spacemacs core (page-break-lines :location built-in) - pcre2el (process-menu :location built-in) - projectile (recentf :location built-in) (savehist :location built-in) (saveplace :location built-in) - (spacemacs-theme :location built-in) (subword :location built-in) (tar-mode :location built-in) (uniquify :location built-in) @@ -61,30 +45,15 @@ ;; Initialization of packages -(defun spacemacs-base/init-abbrev () +(defun spacemacs-defaults/init-abbrev () (spacemacs|hide-lighter abbrev-mode)) -(defun spacemacs-base/init-ace-window () - (use-package ace-window - :defer t - :init - (progn - (spacemacs/set-leader-keys - "bD" 'spacemacs/ace-kill-this-buffer - ;; FIXME: Needs new binding. - ;; "wC" 'spacemacs/ace-center-window - "wD" 'spacemacs/ace-delete-window - "wM" 'ace-swap-window - "wW" 'ace-window) - ;; set ace-window keys to home-row - (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))))) - -(defun spacemacs-base/init-archive-mode () +(defun spacemacs-defaults/init-archive-mode () (evilified-state-evilify-map archive-mode-map :mode archive-mode :eval-after-load archive-mode)) -(defun spacemacs-base/init-bookmark () +(defun spacemacs-defaults/init-bookmark () (use-package bookmark :defer t :init @@ -94,28 +63,28 @@ bookmark-save-flag 1) (spacemacs/set-leader-keys "fb" 'bookmark-jump)))) -(defun spacemacs-base/init-conf-mode () +(defun spacemacs-defaults/init-conf-mode () :init ;; explicitly derive conf-mode from text-mode major-mode (add-hook 'conf-mode-hook 'spacemacs/run-text-mode-hooks)) -(defun spacemacs-base/init-dired () +(defun spacemacs-defaults/init-dired () (spacemacs/set-leader-keys "ad" 'dired "fj" 'dired-jump "jd" 'dired-jump "jD" 'dired-jump-other-window)) -(defun spacemacs-base/init-dired-x () +(defun spacemacs-defaults/init-dired-x () (use-package dired-x :commands (dired-jump dired-jump-other-window dired-omit-mode))) -(defun spacemacs-base/init-electric-indent-mode () +(defun spacemacs-defaults/init-electric-indent-mode () (electric-indent-mode)) -(defun spacemacs-base/init-visual-line-mode () +(defun spacemacs-defaults/init-visual-line-mode () (spacemacs|diminish visual-line-mode " Ⓛ" " L")) ;; notes from mijoharas @@ -135,7 +104,7 @@ ;; ;; inside the use-package function ;; (add-hook 'ediff-keymap-setup-hook 'ediff/setup-ediff-keymaps) ;; ``` -(defun spacemacs-base/init-ediff () +(defun spacemacs-defaults/init-ediff () (use-package ediff :defer t :init @@ -152,7 +121,7 @@ ;; restore window layout when done (add-hook 'ediff-quit-hook #'winner-undo)))) -(defun spacemacs-base/init-eldoc () +(defun spacemacs-defaults/init-eldoc () (use-package eldoc :defer t :config @@ -164,74 +133,16 @@ ;; don't display eldoc on modeline (spacemacs|hide-lighter eldoc-mode)))) -(defun spacemacs-base/init-evil-escape () - (use-package evil-escape - :init (evil-escape-mode) - :config (spacemacs|hide-lighter evil-escape-mode))) - -(defun spacemacs-base/init-evil-evilified-state () - (use-package evil-evilified-state) - (define-key evil-evilified-state-map (kbd dotspacemacs-leader-key) - spacemacs-default-map)) - -(defun spacemacs-base/init-evil-visualstar () - (use-package evil-visualstar - :commands (evil-visualstar/begin-search-forward - evil-visualstar/begin-search-backward) - :init - (progn - (define-key evil-visual-state-map (kbd "*") - 'evil-visualstar/begin-search-forward) - (define-key evil-visual-state-map (kbd "#") - 'evil-visualstar/begin-search-backward)))) - -(defun spacemacs-base/init-exec-path-from-shell () - (use-package exec-path-from-shell - :demand t - :config (exec-path-from-shell-initialize))) - -(defun spacemacs-base/init-help-fns+ () +(defun spacemacs-defaults/init-help-fns+ () (use-package help-fns+ :commands (describe-keymap) :init (spacemacs/set-leader-keys "hdK" 'describe-keymap))) -(defun spacemacs-base/init-hi-lock () +(defun spacemacs-defaults/init-hi-lock () (with-eval-after-load 'hi-lock (spacemacs|hide-lighter hi-lock-mode))) -(defun spacemacs-base/init-holy-mode () - (use-package holy-mode - :commands holy-mode - :init - (progn - (when (eq 'emacs dotspacemacs-editing-style) - (holy-mode)) - (spacemacs|add-toggle holy-mode - :status holy-mode - :on (progn (when (bound-and-true-p hybrid-mode) - (hybrid-mode -1)) - (holy-mode)) - :off (holy-mode -1) - :documentation "Globally toggle holy mode." - :evil-leader "tEe") - (spacemacs|diminish holy-mode " Ⓔe" " Ee")))) - -(defun spacemacs-base/init-hybrid-mode () - (use-package hybrid-mode - :config - (progn - (when (eq 'hybrid dotspacemacs-editing-style) (hybrid-mode)) - (spacemacs|add-toggle hybrid-mode - :status hybrid-mode - :on (progn (when (bound-and-true-p holy-mode) - (holy-mode -1)) - (hybrid-mode)) - :off (hybrid-mode -1) - :documentation "Globally toggle hybrid mode." - :evil-leader "tEh") - (spacemacs|diminish hybrid-mode " Ⓔh" " Eh")))) - -(defun spacemacs-base/init-image-mode () +(defun spacemacs-defaults/init-image-mode () (use-package image-mode :init (progn @@ -262,12 +173,12 @@ "k" 'image-previous-line "l" 'image-forward-hscroll))) -(defun spacemacs-base/init-imenu () +(defun spacemacs-defaults/init-imenu () (use-package imenu :defer t :init (spacemacs/set-leader-keys "ji" 'imenu))) -(defun spacemacs-base/init-linum () +(defun spacemacs-defaults/init-linum () (use-package linum :init (progn @@ -288,110 +199,23 @@ (when dotspacemacs-line-numbers (global-linum-mode))))) -(defun spacemacs-base/init-occur-mode () +(defun spacemacs-defaults/init-occur-mode () (evilified-state-evilify-map occur-mode-map :mode occur-mode)) -(defun spacemacs-base/init-package-menu () +(defun spacemacs-defaults/init-package-menu () (evilified-state-evilify-map package-menu-mode-map :mode package-menu-mode)) -(defun spacemacs-base/init-page-break-lines () +(defun spacemacs-defaults/init-page-break-lines () (require 'page-break-lines) (global-page-break-lines-mode t) (spacemacs|hide-lighter page-break-lines-mode)) -(defun spacemacs-base/init-pcre2el () - (use-package pcre2el - :defer t - :init - (progn - (spacemacs/declare-prefix "xr" "regular expressions") - (spacemacs/declare-prefix "xre" "elisp") - (spacemacs/declare-prefix "xrp" "pcre") - (spacemacs/set-leader-keys - "xr/" 'rxt-explain - "xr'" 'rxt-convert-to-strings - "xrt" 'rxt-toggle-elisp-rx - "xrx" 'rxt-convert-to-rx - "xrc" 'rxt-convert-syntax - "xre/" 'rxt-explain-elisp - "xre'" 'rxt-elisp-to-strings - "xrep" 'rxt-elisp-to-pcre - "xret" 'rxt-toggle-elisp-rx - "xrex" 'rxt-elisp-to-rx - "xrp/" 'rxt-explain-pcre - "xrp'" 'rxt-pcre-to-strings - "xrpe" 'rxt-pcre-to-elisp - "xrpx" 'rxt-pcre-to-rx)))) - -(defun spacemacs-base/init-process-menu () +(defun spacemacs-defaults/init-process-menu () (evilified-state-evilify process-menu-mode process-menu-mode-map)) -(defun spacemacs-base/init-projectile () - (use-package projectile - :commands (projectile-ack - projectile-ag - projectile-compile-project - projectile-dired - projectile-find-dir - projectile-find-file - projectile-find-tag - projectile-test-project - projectile-grep - projectile-invalidate-cache - projectile-kill-buffers - projectile-multi-occur - projectile-project-p - projectile-project-root - projectile-recentf - projectile-regenerate-tags - projectile-replace - projectile-replace-regexp - projectile-run-async-shell-command-in-root - projectile-run-shell-command-in-root - projectile-switch-project - projectile-switch-to-buffer - projectile-vc) - :init - (progn - ;; note for Windows: GNU find or Cygwin find must be in path to enable - ;; fast indexing - (when (and (spacemacs/system-is-mswindows) (executable-find "find")) - (setq projectile-indexing-method 'alien - projectile-generic-command "find . -type f")) - (setq projectile-sort-order 'recentf - projectile-cache-file (concat spacemacs-cache-directory - "projectile.cache") - projectile-known-projects-file (concat spacemacs-cache-directory - "projectile-bookmarks.eld")) - (spacemacs/set-leader-keys - "p!" 'projectile-run-shell-command-in-root - "p&" 'projectile-run-async-shell-command-in-root - "p%" 'projectile-replace-regexp - "pa" 'projectile-toggle-between-implementation-and-test - "pb" 'projectile-switch-to-buffer - "pc" 'projectile-compile-project - "pd" 'projectile-find-dir - "pD" 'projectile-dired - "pe" 'projectile-edit-dir-locals - "pf" 'projectile-find-file - "pF" 'projectile-find-file-dwim - "pg" 'projectile-find-tag - "pG" 'projectile-regenerate-tags - "pI" 'projectile-invalidate-cache - "pk" 'projectile-kill-buffers - "pp" 'projectile-switch-project - "pr" 'projectile-recentf - "pR" 'projectile-replace - "pT" 'projectile-test-project - "pv" 'projectile-vc)) - :config - (progn - (projectile-global-mode) - (spacemacs|hide-lighter projectile-mode)))) - -(defun spacemacs-base/init-recentf () +(defun spacemacs-defaults/init-recentf () (use-package recentf :defer t :init @@ -412,7 +236,7 @@ (add-to-list 'recentf-exclude (file-truename package-user-dir)) (add-to-list 'recentf-exclude "COMMIT_EDITMSG\\'")))) -(defun spacemacs-base/init-savehist () +(defun spacemacs-defaults/init-savehist () (use-package savehist :init (progn @@ -428,7 +252,7 @@ savehist-autosave-interval 60) (savehist-mode t)))) -(defun spacemacs-base/init-saveplace () +(defun spacemacs-defaults/init-saveplace () (use-package saveplace :init (progn @@ -439,15 +263,7 @@ ;; Save point position between sessions (setq save-place-file (concat spacemacs-cache-directory "places"))))) -(defun spacemacs-base/init-spacemacs-theme () - (use-package spacemacs-theme - :defer t - :init - (progn - (setq spacemacs-theme-comment-bg t) - (setq spacemacs-theme-org-height t)))) - -(defun spacemacs-base/init-subword () +(defun spacemacs-defaults/init-subword () (use-package subword :defer t :init @@ -476,12 +292,12 @@ :config (spacemacs|diminish subword-mode " ⓒ" " c"))) -(defun spacemacs-base/init-tar-mode () +(defun spacemacs-defaults/init-tar-mode () (evilified-state-evilify-map tar-mode-map :mode tar-mode :eval-after-load tar-mode)) -(defun spacemacs-base/init-uniquify () +(defun spacemacs-defaults/init-uniquify () (require 'uniquify) ;; When having windows with repeated filenames, uniquify them ;; by the folder they are in rather those annoying <2>,<3>,.. etc @@ -489,11 +305,11 @@ ;; don't screw special buffers uniquify-ignore-buffers-re "^\\*")) -(defun spacemacs-base/init-url () +(defun spacemacs-defaults/init-url () ;; gravatars from magit use this to store their cache (setq url-configuration-directory (concat spacemacs-cache-directory "url/"))) -(defun spacemacs-base/init-whitespace () +(defun spacemacs-defaults/init-whitespace () (use-package whitespace :defer t :init @@ -544,7 +360,7 @@ (spacemacs|diminish whitespace-mode " ⓦ" " w") (spacemacs|diminish global-whitespace-mode " ⓦ" " w")))) -(defun spacemacs-base/init-winner () +(defun spacemacs-defaults/init-winner () (use-package winner :init (progn @@ -564,7 +380,7 @@ (append winner-boring-buffers spacemacs/winner-boring-buffers)) (winner-mode t)))) -(defun spacemacs-base/init-zone () +(defun spacemacs-defaults/init-zone () (require 'zone) (when (and dotspacemacs-zone-out-when-idle (numberp dotspacemacs-zone-out-when-idle)) @@ -592,5 +408,3 @@ ;; zone-pgm-random-life ]) (spacemacs/set-leader-keys "TZ" 'zone)) - -(defun spacemacs-base/init-centered-buffer-mode ()) diff --git a/layers/+spacemacs/spacemacs-editing-visual/funcs.el b/layers/+spacemacs/spacemacs-editing-visual/funcs.el new file mode 100644 index 000000000000..7103791b9543 --- /dev/null +++ b/layers/+spacemacs/spacemacs-editing-visual/funcs.el @@ -0,0 +1,41 @@ +;;; funcs.el --- Spacemacs Editing Visual Layer functions File +;; +;; Copyright (c) 2012-2018 Sylvain Benner & Contributors +;; +;; Author: Sylvain Benner +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +(defun spacemacs/toggle-centered-buffer-mode () + "Toggle `spacemacs-centered-buffer-mode'." + (interactive) + (when (require 'centered-buffer-mode nil t) + (call-interactively 'spacemacs-centered-buffer-mode))) + +(defun spacemacs/toggle-centered-buffer-mode-frame () + "Open current buffer in the new frame centered and without mode-line." + (interactive) + (when (require 'centered-buffer-mode nil t) + (switch-to-buffer-other-frame (current-buffer) t) + (toggle-frame-fullscreen) + (run-with-idle-timer + ;; FIXME: We need this delay to make sure that the + ;; `toggle-frame-fullscreen' fully "finished" + ;; it will be better to use something more reliable + ;; instead :) + 1 + nil + (lambda () + (call-interactively 'spacemacs-centered-buffer-mode) + (setq mode-line-format nil))))) + +(defun spacemacs/centered-buffer-mode-full-width () + "Center buffer in the frame." + ;; FIXME Needs new key-binding. + (interactive) + (when (require 'centered-buffer-mode nil t) + (spacemacs/maximize-horizontally) + (call-interactively 'spacemacs-centered-buffer-mode))) diff --git a/layers/+distributions/spacemacs-base/local/centered-buffer-mode/centered-buffer-mode.el b/layers/+spacemacs/spacemacs-editing-visual/local/centered-buffer-mode/centered-buffer-mode.el similarity index 100% rename from layers/+distributions/spacemacs-base/local/centered-buffer-mode/centered-buffer-mode.el rename to layers/+spacemacs/spacemacs-editing-visual/local/centered-buffer-mode/centered-buffer-mode.el diff --git a/layers/+spacemacs/spacemacs-editing-visual/packages.el b/layers/+spacemacs/spacemacs-editing-visual/packages.el index 2a35ca3f5337..751f25284b02 100644 --- a/layers/+spacemacs/spacemacs-editing-visual/packages.el +++ b/layers/+spacemacs/spacemacs-editing-visual/packages.el @@ -13,6 +13,7 @@ '( ;; default adaptive-wrap + (centered-buffer-mode :location local) column-enforce-mode (hide-comnt :location local) highlight-indentation @@ -34,6 +35,8 @@ (progn (add-hook 'visual-line-mode-hook 'adaptive-wrap-prefix-mode)))) +(defun spacemacs-editing-visual/init-centered-buffer-mode ()) + (defun spacemacs-editing-visual/init-column-enforce-mode () (use-package column-enforce-mode :commands (column-enforce-mode global-column-enforce-mode) diff --git a/layers/+spacemacs/spacemacs-editing/README.org b/layers/+spacemacs/spacemacs-editing/README.org index 0dcb5168fb12..eb97fe366bd5 100644 --- a/layers/+spacemacs/spacemacs-editing/README.org +++ b/layers/+spacemacs/spacemacs-editing/README.org @@ -24,3 +24,4 @@ This layer adds packages to improve editing with Spacemacs. - Automatic whitespace cleanup on save via =spacemacs-whitespace-cleanup=. - Support for converting definitions to certain styles via =string-inflection=. - Support for generating UUIDs via =uuidgen=. +- Support for conversion between Emacs regexps and PCRE regexps. diff --git a/layers/+spacemacs/spacemacs-editing/packages.el b/layers/+spacemacs/spacemacs-editing/packages.el index 8b1da673d09e..6b951655071d 100644 --- a/layers/+spacemacs/spacemacs-editing/packages.el +++ b/layers/+spacemacs/spacemacs-editing/packages.el @@ -24,6 +24,7 @@ move-text (origami :toggle (eq 'origami dotspacemacs-folding-method)) password-generator + pcre2el smartparens (spacemacs-whitespace-cleanup :location local) string-inflection @@ -273,6 +274,30 @@ "ipp" 'password-generator-phonetic "ipn" 'password-generator-numeric)))) +(defun spacemacs-editing/init-pcre2el () + (use-package pcre2el + :defer t + :init + (progn + (spacemacs/declare-prefix "xr" "regular expressions") + (spacemacs/declare-prefix "xre" "elisp") + (spacemacs/declare-prefix "xrp" "pcre") + (spacemacs/set-leader-keys + "xr/" 'rxt-explain + "xr'" 'rxt-convert-to-strings + "xrt" 'rxt-toggle-elisp-rx + "xrx" 'rxt-convert-to-rx + "xrc" 'rxt-convert-syntax + "xre/" 'rxt-explain-elisp + "xre'" 'rxt-elisp-to-strings + "xrep" 'rxt-elisp-to-pcre + "xret" 'rxt-toggle-elisp-rx + "xrex" 'rxt-elisp-to-rx + "xrp/" 'rxt-explain-pcre + "xrp'" 'rxt-pcre-to-strings + "xrpe" 'rxt-pcre-to-elisp + "xrpx" 'rxt-pcre-to-rx)))) + (defun spacemacs-editing/init-smartparens () (use-package smartparens :defer t diff --git a/layers/+spacemacs/spacemacs-evil/README.org b/layers/+spacemacs/spacemacs-evil/README.org index abc975fc0b3d..4b2c56c39f44 100644 --- a/layers/+spacemacs/spacemacs-evil/README.org +++ b/layers/+spacemacs/spacemacs-evil/README.org @@ -9,7 +9,23 @@ This layer adds various adjustments to packages to create an evilified experienc througout the entirety of Spacemacs. ** Features: +- Add evil tutorial with =evil-tutor= +- Add relative line number with =linun-relative= +- Add escaping under ~fd~ by default with =evil-escape= +- Add occurences count in mode-line when searching a buffer +- Add support for lisp structure manipulation with =evil-lisp-state= +- Add safe structural editing of lisp dialects with =evil-cleverparens= +- Add =evil-exchange= to swap text +- Add easy live editing of multiple occurences with =evil-iedit-state= +- Add new vim text objects for indentation with =evil-indent-plus= +- Add operations to align text with =evil-lion= +- Easy management of comments with =evil-nerd-commenter= +- Nagivation between pairs with =evil-matchit= +- Advanced navigation on brackets with =evil-unimpaired= +- Easy increment and decrement of numbers with =evil-number= - Support for additional vim movements via =evil-args= - Support for surrounding the marked area with a given character via =evil-surround= - Evilification of various modes if the editing style is =vim= or =hybrid= - Improves the comment function to be able to also do the inverse operation +- Persistent highlight of searched text with =evil-search-highlight-persist= +- Display tidles in non-buffer area with =vi-tilde-fringe= diff --git a/layers/+spacemacs/spacemacs-evil/packages.el b/layers/+spacemacs/spacemacs-evil/packages.el index cd6d28ca9356..7cd7733e5945 100644 --- a/layers/+spacemacs/spacemacs-evil/packages.el +++ b/layers/+spacemacs/spacemacs-evil/packages.el @@ -14,6 +14,7 @@ evil-args evil-cleverparens evil-ediff + evil-escape evil-exchange evil-iedit-state evil-indent-plus @@ -34,6 +35,7 @@ evil-tutor (evil-unimpaired :location (recipe :fetcher local)) evil-visual-mark-mode + evil-visualstar (hs-minor-mode :location built-in) linum-relative vi-tilde-fringe @@ -92,6 +94,11 @@ :after (ediff) :if (memq dotspacemacs-editing-style '(hybrid vim)))) +(defun spacemacs-evil/init-evil-escape () + (use-package evil-escape + :init (evil-escape-mode) + :config (spacemacs|hide-lighter evil-escape-mode))) + (defun spacemacs-evil/init-evil-exchange () (use-package evil-exchange :init (evil-exchange-install))) @@ -285,6 +292,17 @@ :documentation "Enable evil visual marks mode." :evil-leader "t`"))) +(defun spacemacs-evil/init-evil-visualstar () + (use-package evil-visualstar + :commands (evil-visualstar/begin-search-forward + evil-visualstar/begin-search-backward) + :init + (progn + (define-key evil-visual-state-map (kbd "*") + 'evil-visualstar/begin-search-forward) + (define-key evil-visual-state-map (kbd "#") + 'evil-visualstar/begin-search-backward)))) + (defun spacemacs-evil/init-hs-minor-mode () (add-hook 'prog-mode-hook 'spacemacs//enable-hs-minor-mode)) diff --git a/layers/+spacemacs/spacemacs-navigation/funcs.el b/layers/+spacemacs/spacemacs-navigation/funcs.el index 95dabe58b5d3..f0f2940c9abe 100644 --- a/layers/+spacemacs/spacemacs-navigation/funcs.el +++ b/layers/+spacemacs/spacemacs-navigation/funcs.el @@ -9,6 +9,34 @@ ;; ;;; License: GPLv3 + +;; ace-window + +(defun spacemacs/ace-delete-window (&optional arg) + "Ace delete window. +If the universal prefix argument is used then kill the buffer too." + (interactive "P") + (require 'ace-window) + (aw-select + " Ace - Delete Window" + (lambda (window) + (when (equal '(4) arg) + (with-selected-window window + (spacemacs/kill-this-buffer arg))) + (aw-delete-window window)))) + +(defun spacemacs/ace-kill-this-buffer (&optional arg) + "Ace kill visible buffer in a window. +If the universal prefix argument is used then kill also the window." + (interactive "P") + (require 'ace-window) + (let (golden-ratio-mode) + (aw-select + " Ace - Kill buffer in Window" + (lambda (window) + (with-selected-window window + (spacemacs/kill-this-buffer arg)))))) + ;; auto-highlight symbol diff --git a/layers/+spacemacs/spacemacs-navigation/packages.el b/layers/+spacemacs/spacemacs-navigation/packages.el index 16aa7f5fd409..914f992d2d58 100644 --- a/layers/+spacemacs/spacemacs-navigation/packages.el +++ b/layers/+spacemacs/spacemacs-navigation/packages.el @@ -11,6 +11,7 @@ (setq spacemacs-navigation-packages '(ace-link + ace-window auto-highlight-symbol centered-cursor-mode (compile :location built-in) @@ -39,6 +40,21 @@ (define-key eww-link-keymap "o" 'ace-link-eww) (define-key eww-mode-map "o" 'ace-link-eww))))) +(defun spacemacs-navigation/init-ace-window () + (use-package ace-window + :defer t + :init + (progn + (spacemacs/set-leader-keys + "bD" 'spacemacs/ace-kill-this-buffer + ;; FIXME: Needs new binding. + ;; "wC" 'spacemacs/ace-center-window + "wD" 'spacemacs/ace-delete-window + "wM" 'ace-swap-window + "wW" 'ace-window) + ;; set ace-window keys to home-row + (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))))) + (defun spacemacs-navigation/init-auto-highlight-symbol () (use-package auto-highlight-symbol :defer t diff --git a/layers/+spacemacs/spacemacs-project/README.org b/layers/+spacemacs/spacemacs-project/README.org new file mode 100644 index 000000000000..1053ccc8558c --- /dev/null +++ b/layers/+spacemacs/spacemacs-project/README.org @@ -0,0 +1,14 @@ +#+TITLE: spacemacs-project layer + +* Table of Contents :TOC_4_gh:noexport: +- [[#description][Description]] + - [[#features][Features:]] + +* Description +This layer tweaks =org-mode= to integrate nicely into Spacemacs. + +** Features: +- Configuration for =flyspell= to check =org-buffers= for typos. +- Support for automatically generated Table-Of-Contents via =toc-org=. +- Support for custom bullet markers via =org-bullets=. +- Support for a special view mode for org documents via =space-doc=. diff --git a/layers/+spacemacs/spacemacs-project/packages.el b/layers/+spacemacs/spacemacs-project/packages.el new file mode 100644 index 000000000000..d27f5f5bb094 --- /dev/null +++ b/layers/+spacemacs/spacemacs-project/packages.el @@ -0,0 +1,80 @@ +;;; packages.el --- Spacemacs Project Management Layer packages File +;; +;; Copyright (c) 2012-2018 Sylvain Benner & Contributors +;; +;; Author: Sylvain Benner +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + + +(setq spacemacs-project-packages + '( + projectile + )) + + +(defun spacemacs-project/init-projectile () + (use-package projectile + :commands (projectile-ack + projectile-ag + projectile-compile-project + projectile-dired + projectile-find-dir + projectile-find-file + projectile-find-tag + projectile-test-project + projectile-grep + projectile-invalidate-cache + projectile-kill-buffers + projectile-multi-occur + projectile-project-p + projectile-project-root + projectile-recentf + projectile-regenerate-tags + projectile-replace + projectile-replace-regexp + projectile-run-async-shell-command-in-root + projectile-run-shell-command-in-root + projectile-switch-project + projectile-switch-to-buffer + projectile-vc) + :init + (progn + ;; note for Windows: GNU find or Cygwin find must be in path to enable + ;; fast indexing + (when (and (spacemacs/system-is-mswindows) (executable-find "find")) + (setq projectile-indexing-method 'alien + projectile-generic-command "find . -type f")) + (setq projectile-sort-order 'recentf + projectile-cache-file (concat spacemacs-cache-directory + "projectile.cache") + projectile-known-projects-file (concat spacemacs-cache-directory + "projectile-bookmarks.eld")) + (spacemacs/set-leader-keys + "p!" 'projectile-run-shell-command-in-root + "p&" 'projectile-run-async-shell-command-in-root + "p%" 'projectile-replace-regexp + "pa" 'projectile-toggle-between-implementation-and-test + "pb" 'projectile-switch-to-buffer + "pc" 'projectile-compile-project + "pd" 'projectile-find-dir + "pD" 'projectile-dired + "pe" 'projectile-edit-dir-locals + "pf" 'projectile-find-file + "pF" 'projectile-find-file-dwim + "pg" 'projectile-find-tag + "pG" 'projectile-regenerate-tags + "pI" 'projectile-invalidate-cache + "pk" 'projectile-kill-buffers + "pp" 'projectile-switch-project + "pr" 'projectile-recentf + "pR" 'projectile-replace + "pT" 'projectile-test-project + "pv" 'projectile-vc)) + :config + (progn + (projectile-global-mode) + (spacemacs|hide-lighter projectile-mode))))