From 77ba076f697d270b011586944004ce8dfb6f61a4 Mon Sep 17 00:00:00 2001 From: Lucius Hu <1222865+lebensterben@users.noreply.github.com> Date: Fri, 11 Feb 2022 23:58:35 -0500 Subject: [PATCH] spacemacs-editing-visual: rework (#15322) --- .../spacemacs-defaults/keybindings.el | 6 +- .../spacemacs-editing-visual/README.org | 1 + .../spacemacs-editing-visual/funcs.el | 23 +- .../local/hide-comnt/hide-comnt.el | 312 ------------------ .../spacemacs-editing-visual/packages.el | 218 +++++++----- 5 files changed, 137 insertions(+), 423 deletions(-) delete mode 100644 layers/+spacemacs/spacemacs-editing-visual/local/hide-comnt/hide-comnt.el diff --git a/layers/+spacemacs/spacemacs-defaults/keybindings.el b/layers/+spacemacs/spacemacs-defaults/keybindings.el index 2b08ac217..dda79b4e5 100644 --- a/layers/+spacemacs/spacemacs-defaults/keybindings.el +++ b/layers/+spacemacs/spacemacs-defaults/keybindings.el @@ -661,9 +661,9 @@ respond to this toggle." "wl" 'evil-window-right "w " 'evil-window-right "wm" 'spacemacs/toggle-maximize-buffer - "wcc" 'spacemacs/toggle-centered-buffer - "wcC" 'spacemacs/toggle-distraction-free - "wc." 'spacemacs/centered-buffer-transient-state + ;; "wcc" 'spacemacs/toggle-centered-buffer + ;; "wcC" 'spacemacs/toggle-distraction-free + ;; "wc." 'spacemacs/centered-buffer-transient-state "wo" 'other-frame "wr" 'spacemacs/rotate-windows-forward "wR" 'spacemacs/rotate-windows-backward diff --git a/layers/+spacemacs/spacemacs-editing-visual/README.org b/layers/+spacemacs/spacemacs-editing-visual/README.org index 1cf571a48..264d9126d 100644 --- a/layers/+spacemacs/spacemacs-editing-visual/README.org +++ b/layers/+spacemacs/spacemacs-editing-visual/README.org @@ -17,3 +17,4 @@ edited line in Spacemacs. - Highlighting of different indentations - Automatic highlighting of numbers - Automatic highlighting of parentheses +- Adaptive cursor shape in terminal, as it would be in GUI diff --git a/layers/+spacemacs/spacemacs-editing-visual/funcs.el b/layers/+spacemacs/spacemacs-editing-visual/funcs.el index 2721d47f5..023ce2fee 100644 --- a/layers/+spacemacs/spacemacs-editing-visual/funcs.el +++ b/layers/+spacemacs/spacemacs-editing-visual/funcs.el @@ -20,27 +20,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . - -;; TODO: Allow direct transition between centered and distraction free states. - -(defun spacemacs/toggle-centered-buffer () - "Toggle visual centering of the current buffer." - (interactive) - (cl-letf ((writeroom-maximize-window nil) - (writeroom-mode-line t)) - (call-interactively 'writeroom-mode))) - -(defun spacemacs/toggle-distraction-free () - "Toggle visual distraction free mode." - (interactive) - (cl-letf ((writeroom-maximize-window t) - (writeroom-mode-line nil)) - (call-interactively 'writeroom-mode))) - (defun spacemacs/centered-buffer-transient-state () "Center buffer and enable centering transient state." (interactive) - (cl-letf ((writeroom-maximize-window nil) - (writeroom-mode-line t)) - (writeroom-mode 1) - (spacemacs/centered-buffer-mode-transient-state/body))) + (spacemacs/toggle-centered-buffer-on) + (spacemacs/centered-buffer-transient-state/body)) diff --git a/layers/+spacemacs/spacemacs-editing-visual/local/hide-comnt/hide-comnt.el b/layers/+spacemacs/spacemacs-editing-visual/local/hide-comnt/hide-comnt.el deleted file mode 100644 index 07e3e5e51..000000000 --- a/layers/+spacemacs/spacemacs-editing-visual/local/hide-comnt/hide-comnt.el +++ /dev/null @@ -1,312 +0,0 @@ -;;; hide-comnt.el --- Hide/show comments in code. -;; -;; Filename: hide-comnt.el -;; Description: Hide/show comments in code. -;; Author: Drew Adams -;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com") -;; Copyright (C) 2011-2017, Drew Adams, all rights reserved. -;; Created: Wed May 11 07:11:30 2011 (-0700) -;; Version: 0 -;; Package-Requires: () -;; Last-Updated: Thu Feb 23 07:40:11 2017 (-0800) -;; By: dradams -;; Update #: 228 -;; URL: https://www.emacswiki.org/emacs/download/hide-comnt.el -;; Doc URL: http://www.emacswiki.org/HideOrIgnoreComments -;; Keywords: comment, hide, show -;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x, 25.x -;; -;; Features that might be required by this library: -;; -;; None -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Commentary: -;; -;; Hide/show comments in code. -;; -;; Comments are hidden by giving them and `invisible' property of -;; value `hide-comment'. -;; -;; -;; Macros defined here: -;; -;; `with-comments-hidden'. -;; -;; Commands defined here: -;; -;; `hide/show-comments', `hide/show-comments-toggle'. -;; -;; User options defined here: -;; -;; `hide-whitespace-before-comment-flag', `ignore-comments-flag', -;; `show-invisible-comments-shows-all'. -;; -;; Non-interactive functions defined here: -;; -;; `hide/show-comments-1'. -;; -;; -;; Put this in your init file (`~/.emacs'): -;; -;; (require 'hide-comnt) -;; -;; -;; Note for Emacs 20: The commands and option defined here DO NOTHING -;; IN EMACS 20. Nevertheless, the library can be byte-compiled in -;; Emacs 20 and `hide-comnt.elc' can be loaded in later Emacs -;; versions and used there. This is the only real use of this -;; library for Emacs 20: it provides macro `with-comments-hidden'. -;; -;; Note for Emacs 21: It lacks the `comment-forward' function, so we -;; rely on the `comment-end' variable to determine the end of a -;; comment. This means that only one type of comment terminator is -;; supported. For example, `c++-mode' sets `comment-end' to "", -;; which is the convention for single-line comments ("// COMMENT"). -;; So "/* */" comments are treated as single-line commentsonly the -;; first line of such comments is hidden. The "*/" terminator is not -;; taken into account. -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Change Log: -;; -;; 2017/01/16 dadams -;; hide/show-comments-1: ((add-to|remove-from)-invisibility-spec 'hide-comment). -;; See https://github.com/syl20bnr/spacemacs/issues/8123. -;; 2016/12/27 dadams -;; Added: show-invisible-comments-shows-all. -;; hide/show-comments(-1): Respect show-invisible-comments-shows-all. -;; NOTE: Default behavior has changed: other invisible text is no longer made visible. -;; 2015/08/01 dadams -;; Added hide/show-comments-1. (And removed save-excursion around looking-back etc.) -;; hide/show-comments: -;; Use with-silent-modifications if available. Use hide/show-comments-1. -;; 2015/07/31 dadams -;; hide/show-comments: -;; Bind buffer-file-name to nil to inhibit ask-user-about-supersession-threat. -;; 2015/07/29 dadams -;; hide/show-comments: -;; No-op if no comment-start. Pass NOERROR arg to comment-normalize-vars. -;; 2014/11/05 dadams -;; hide/show-comments: -;; Use comment-forward even for "", so handle setting CEND correctly, e.g., for C++, -;; where comment-end is "" but multi-line comments are also OK. -;; Do not hide newline after single-line comments. -;; hide-whitespace-before-comment-flag non-nil no longer hides empty lines. -;; Prevent infloop for comment at bol. -;; Thx to Hinrik Sigurosson. -;; 2014/02/06 dadams -;; Added: hide-whitespace-before-comment-flag. -;; hide/show-comments: -;; Go to start of comment before calling comment-forward. -;; Hide whitespace preceding comment, if hide-whitespace-before-comment-flag. -;; 2013/12/26 dadams -;; hide/show-comments: Update START to comment end or END. -;; 2013/10/09 dadams -;; hide/show-comments: Use save-excursion. If empty comment-end go to CBEG. -;; Use comment-forward if available. -;; 2012/10/06 dadams -;; hide/show-comments: Call comment-normalize-vars first. Thx to Stefan Monnier. -;; hide/show-comments-toggle: Do nothing if newcomment.el not available. -;; 2012/05/10 dadams -;; Added: hide/show-comments-toggle. Thx to Denny Zhang for the suggestion. -;; 2011/11/23 dadams -;; hide/show-comments: Bug fix - ensure CEND is not past eob. -;; 2011/05/11 dadams -;; Created: moved code here from thing-cmds.el. -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 3, or -;; (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth -;; Floor, Boston, MA 02110-1301, USA. -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Code: - - -(defvar comment-start) ; In `newcomment.el'. - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;;;###autoload -(defcustom ignore-comments-flag t - "*Non-nil means macro `with-comments-hidden' hides comments." - :type 'boolean :group 'matching) - -;;;###autoload -(defcustom hide-whitespace-before-comment-flag t - "*Non-nil means `hide/show-comments' hides whitespace preceding a comment. -It does not hide empty lines (newline chars), however." - :type 'boolean :group 'matching) - -;;;###autoload -(defcustom show-invisible-comments-shows-all nil - "Non-nil means `(hide/show-comments 'show ...)' shows all invisible text. -The default value, nil, means it shows only text that was made -invisible by `(hide/show-comments 'hide ...)'." - :type 'boolean :group 'matching) - - -(defmacro with-comments-hidden (start end &rest body) - "Evaluate the forms in BODY while comments are hidden from START to END. -But if `ignore-comments-flag' is nil, just evaluate BODY, -without hiding comments. Show comments again when BODY is finished. - -See `hide/show-comments', which is used to hide and show the comments. -Note that prior to Emacs 21, this never hides comments." - (let ((result (make-symbol "result")) - (ostart (make-symbol "ostart")) - (oend (make-symbol "oend"))) - `(let ((,ostart ,start) - (,oend ,end) - ,result) - (unwind-protect (setq ,result (progn (when ignore-comments-flag - (hide/show-comments 'hide ,ostart ,oend)) - ,@body)) - (when ignore-comments-flag (hide/show-comments 'show ,ostart ,oend)) - ,result)))) - -;;;###autoload -(defun hide/show-comments (&optional hide/show start end) - "Hide or show comments from START to END. -Interactively, hide comments, or show them if you use a prefix arg. -\(This is thus *NOT* a toggle command.) - -If option `hide-whitespace-before-comment-flag' is non-nil, then hide -also any whitespace preceding a comment. - -Interactively, START and END default to the region limits, if active. -Otherwise, including non-interactively, they default to `point-min' -and `point-max'. - -Uses `save-excursion', restoring point. - -Option `show-invisible-comments-shows-all': - -* If non-nil then using this command to show invisible text shows - *ALL* such text, regardless of how it was hidden. IOW, it does not - just show invisible text that you previously hid using this command. - -* If nil (the default value) then using this command to show invisible - text makes visible only such text that was previously hidden by this - command. (More precisely, it makes visible only text whose - `invisible' property has value `hide-comment'.) - -From Lisp, a HIDE/SHOW value of `hide' hides comments. Other values -show them. - -This command does nothing in Emacs versions prior to Emacs 21, because -it needs `comment-search-forward'." - - (interactive - (cons (if current-prefix-arg 'show 'hide) - (if (or (not mark-active) (null (mark)) (= (point) (mark))) - (list (point-min) (point-max)) - (if (< (point) (mark)) (list (point) (mark)) (list (mark) (point)))))) - (when (and comment-start ; No-op if no comment syntax defined. - (require 'newcomment nil t)) ; `comment-search-forward', Emacs 21+. - (comment-normalize-vars 'NO-ERROR) ; Must call this first. - (unless start (setq start (point-min))) - (unless end (setq end (point-max))) - (unless (<= start end) (setq start (prog1 end (setq end start)))) ; Swap. - (if (fboundp 'with-silent-modifications) - (with-silent-modifications ; Emacs 23+. - (restore-buffer-modified-p nil) (hide/show-comments-1 hide/show start end)) - (let ((bufmodp (buffer-modified-p)) ; Emacs < 23. - (buffer-read-only nil) - (buffer-file-name nil)) ; Inhibit `ask-user-about-supersession-threat'. - (set-buffer-modified-p nil) - (unwind-protect (hide/show-comments-1 hide/show start end) - (set-buffer-modified-p bufmodp)))))) - -;; Used only so that we can use `hide/show-comments' with older Emacs releases that do not -;; have macro `with-silent-modifications' and built-in `restore-buffer-modified-p', which -;; it uses. -(defun hide/show-comments-1 (hide/show start end) - "Helper for `hide/show-comments'." - (let (cbeg cend) - (if (eq 'hide hide/show) - (add-to-invisibility-spec 'hide-comment) - (remove-from-invisibility-spec 'hide-comment)) - (save-excursion - (goto-char start) - (while (and (< start end) (save-excursion - (setq cbeg (comment-search-forward end 'NOERROR)))) - (goto-char cbeg) - (save-excursion - (setq cend (cond ((fboundp 'comment-forward) ; Emacs 22+ - (if (comment-forward 1) - (if (= (char-before) ?\n) (1- (point)) (point)) - end)) - ((string= "" comment-end) (min (line-end-position) end)) - (t (search-forward comment-end end 'NOERROR))))) - (when hide-whitespace-before-comment-flag ; Hide preceding whitespace. - (if (fboundp 'looking-back) ; Emacs 22+ - (when (looking-back "\n?\\s-*" nil 'GREEDY) - (setq cbeg (match-beginning 0))) - (while (memq (char-before cbeg) '(?\ ?\t ?\f)) (setq cbeg (1- cbeg))) - (when (eq (char-before cbeg) ?\n) (setq cbeg (1- cbeg)))) - ;; First line: Hide newline after comment. - (when (and (= cbeg (point-min)) (= (char-after cend) ?\n)) - (setq cend (min (1+ cend) end)))) - (when (and cbeg cend) - (if show-invisible-comments-shows-all - (put-text-property cbeg cend 'invisible (and (eq 'hide hide/show) - 'hide-comment)) - (while (< cbeg cend) - ;; Do nothing to text that is already invisible for some other reason. - (unless (and (get-text-property cbeg 'invisible) - (not (eq 'hide-comment (get-text-property cbeg 'invisible)))) - (put-text-property cbeg (1+ cbeg) 'invisible (and (eq 'hide hide/show) - 'hide-comment))) - (setq cbeg (1+ cbeg))))) - (goto-char (setq start (or cend end))))))) - -(defun hide/show-comments-toggle (&optional start end) - "Toggle hiding/showing of comments in the active region or whole buffer. -If the region is active then toggle in the region. Otherwise, in the -whole buffer. - -This command does nothing in Emacs versions prior to Emacs 21, because -it needs `comment-search-forward'. - -Interactively, START and END default to the region limits, if active. -Otherwise, including non-interactively, they default to `point-min' -and `point-max'. - -See `hide/show-comments' for more information." - (interactive (if (or (not mark-active) (null (mark)) (= (point) (mark))) - (list (point-min) (point-max)) - (if (< (point) (mark)) (list (point) (mark)) (list (mark) (point))))) - (when (require 'newcomment nil t) ; `comment-search-forward', Emacs 21+. - (comment-normalize-vars) ; Must call this first. - (if (save-excursion - (goto-char start) - (and (comment-search-forward end 'NOERROR) - (if show-invisible-comments-shows-all - (get-text-property (point) 'invisible) - (eq 'hide-comment (get-text-property (point) 'invisible))))) - (hide/show-comments 'show start end) - (hide/show-comments 'hide start end)))) - -;;;;;;;;;;;;;;;;;;;;;;;; - -(provide 'hide-comnt) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; hide-comnt.el ends here diff --git a/layers/+spacemacs/spacemacs-editing-visual/packages.el b/layers/+spacemacs/spacemacs-editing-visual/packages.el index 63917ebcf..859a77f86 100644 --- a/layers/+spacemacs/spacemacs-editing-visual/packages.el +++ b/layers/+spacemacs/spacemacs-editing-visual/packages.el @@ -1,6 +1,6 @@ ;;; packages.el --- Spacemacs Editing Visual Layer packages File ;; -;; Copyright (c) 2012-2021 Sylvain Benner & Contributors +;; Copyright (c) 2012-2022 Sylvain Benner & Contributors ;; ;; Author: Sylvain Benner ;; URL: https://github.com/syl20bnr/spacemacs @@ -20,40 +20,28 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . +;;; Commentary: -(setq spacemacs-editing-visual-packages - '( - ;; default - (hide-comnt :location local) - ;; see https://github.com/syl20bnr/spacemacs/issues/2529 - ;; waiting for an overlay bug to be fixed - (hl-anything :excluded t) - column-enforce-mode - highlight-indentation - highlight-numbers - highlight-parentheses - indent-guide - rainbow-delimiters - volatile-highlights - writeroom-mode - )) +;;; Code: -;; Initialization of packages - -(defun spacemacs-editing-visual/init-writeroom-mode () - (use-package writeroom-mode - :defer t - :init - (spacemacs|define-transient-state centered-buffer-mode - :title "Centered Buffer Transient State" - :bindings - ("[" writeroom-decrease-width "shrink") - ("]" writeroom-increase-width "enlarge") - ("=" writeroom-adjust-width "adjust width")))) +(defconst spacemacs-editing-visual-packages + '( + column-enforce-mode + (evil-terminal-cursor-changer :toggle (configuration-layer/package-used-p 'evil)) + (hide-comnt :location (recipe :fetcher github :repo "emacsmirror/hide-comnt")) + highlight-indentation + highlight-numbers + highlight-parentheses + indent-guide + rainbow-delimiters + (term-cursor :location (recipe :fetcher github :repo "h0d/term-cursor.el") + :toggle (not (configuration-layer/package-used-p 'evil))) + volatile-highlights + writeroom-mode)) + (defun spacemacs-editing-visual/init-column-enforce-mode () (use-package column-enforce-mode - :commands (column-enforce-mode global-column-enforce-mode) :init (progn (spacemacs|add-toggle highlight-long-lines @@ -63,18 +51,34 @@ :on-message (format "long-lines enabled for %s columns." (or columns column-enforce-column)) :off (column-enforce-mode -1) + :off-message (format "long-lines disabled for %s columns." + (or columns column-enforce-column)) :documentation "Highlight the characters past the 80th column." :evil-leader "t8") (spacemacs|add-toggle highlight-long-lines-globally :mode global-column-enforce-mode - :documentation "Globally Highlight the characters past the 80th column." + :documentation "Globally highlight the characters past the 80th column." :evil-leader "t C-8")) - :config (spacemacs|diminish column-enforce-mode "⑧" "8"))) + :spacediminish ("⑧" "8"))) + +(defun spacemacs-editing-visual/init-evil-terminal-cursor-changer () + (use-package evil-terminal-cursor-changer + :if (not (display-graphic-p)) + :after evil + :defer t + :init (evil-terminal-cursor-changer-activate))) (defun spacemacs-editing-visual/init-hide-comnt () (use-package hide-comnt :commands hide/show-comments-toggle - :init (spacemacs/set-leader-keys "ch" 'hide/show-comments-toggle))) + :init + (progn + (advice-add 'hide/show-comments + :after (lambda (&optional hide/show start end) + (pcase hide/show + ('hide (message "Hide comments enabled.")) + ('show (message "Hide comments disabled."))))) + (spacemacs/set-leader-keys "ch" 'hide/show-comments-toggle)))) (defun spacemacs-editing-visual/init-highlight-indentation () (use-package highlight-indentation @@ -89,107 +93,147 @@ :mode highlight-indentation-current-column-mode :documentation "Highlight indentation level at point." :evil-leader "thc")) - :config - (progn - (spacemacs|diminish highlight-indentation-mode " ⓗi" " hi") - (spacemacs|diminish - highlight-indentation-current-column-mode " ⓗc" " hc")))) + :spacediminish ((" ⓗi" " hi") + (highlight-indentation-current-column-mode " ⓗc" " hc")))) (defun spacemacs-editing-visual/init-highlight-numbers () (use-package highlight-numbers :defer t :init (progn + (spacemacs|add-toggle highlight-numbers + :mode highlight-numbers-mode + :documentation "Highlight numeric literals." + :evil-leader "thn") (add-hook 'prog-mode-hook 'highlight-numbers-mode) (add-hook 'asm-mode-hook (lambda () (highlight-numbers-mode -1)))))) (defun spacemacs-editing-visual/init-highlight-parentheses () (use-package highlight-parentheses :defer t + :custom + (highlight-parentheses-delay 0.2) + (highlight-parentheses-colors '("Springgreen3" + "IndianRed1" + "IndianRed3" + "IndianRed4")) + :custom-face (highlight-parentheses-highlight ((nil (:weight ultra-bold)))) + :commands highlight-parentheses-minibuffer-setup :init + (spacemacs|add-toggle highlight-parentheses + :mode highlight-parentheses-mode + :documentation "Highlight surrounding parentheses." + :evil-leader "thp") + (spacemacs|add-toggle highlight-parentheses-globally + :mode global-highlight-parentheses-mode + :documentation "Globally highlight surrounding parentheses." + :evil-leader "thP") (progn - (when (member dotspacemacs-highlight-delimiters '(all current)) + (when (memq dotspacemacs-highlight-delimiters '(all current)) (add-hook 'prog-mode-hook #'highlight-parentheses-mode)) - (setq hl-paren-delay 0.2) - (spacemacs/set-leader-keys "thp" 'highlight-parentheses-mode) - (setq hl-paren-colors '("Springgreen3" - "IndianRed1" - "IndianRed3" - "IndianRed4"))) - :config - (spacemacs|hide-lighter highlight-parentheses-mode) - (set-face-attribute 'hl-paren-face nil :weight 'ultra-bold))) - -(defun spacemacs-editing-visual/init-hl-anything () - (use-package hl-anything - :init - (progn - (hl-highlight-mode) - (setq-default hl-highlight-save-file - (concat spacemacs-cache-directory ".hl-save")) - (spacemacs/set-leader-keys - "hc" 'hl-unhighlight-all-local - "hC" 'hl-unhighlight-all-global - "hh" 'hl-highlight-thingatpt-local - "hH" 'hl-highlight-thingatpt-global - "hn" 'hl-find-next-thing - "hN" 'hl-find-prev-thing - "hr" 'hl-restore-highlights - "hs" 'hl-save-highlights)) - :config (spacemacs|hide-lighter hl-highlight-mode))) + (when (eq dotspacemacs-highlight-delimiters 'all) + (add-hook 'minibuffer-setup-hook #'highlight-parentheses-minibuffer-setup))) + :config (spacemacs|hide-lighter highlight-parentheses-mode))) (defun spacemacs-editing-visual/init-indent-guide () (use-package indent-guide :defer t + :custom + (indent-guide-delay 0.3) :init (progn - (setq indent-guide-delay 0.3) (spacemacs|add-toggle indent-guide :mode indent-guide-mode - ;; :documentation (concat "Highlight indentation level at point." - ;; " (alternative to highlight-indentation).") :documentation "Highlight indentation level at point. (alternative to highlight-indentation)." :evil-leader "ti") (spacemacs|add-toggle indent-guide-globally :mode indent-guide-global-mode - ;; :documentation (concat "Highlight indentation level at point globally." - ;; " (alternative to highlight-indentation).") :documentation "Highlight indentation level at point globally. (alternative to highlight-indentation)." :evil-leader "t TAB")) - :config - (spacemacs|diminish indent-guide-mode " ⓘ" " i"))) + :spacediminish (" ⓘ" " i"))) (defun spacemacs-editing-visual/init-rainbow-delimiters () (use-package rainbow-delimiters :defer t :init (progn - (spacemacs/set-leader-keys "tCd" 'rainbow-delimiters-mode) - (when (member dotspacemacs-highlight-delimiters '(any all)) - (spacemacs/add-to-hooks 'rainbow-delimiters-mode '(prog-mode-hook)))))) + (spacemacs|add-toggle rainbow-delimiters + :mode rainbow-delimiters-mode + :documentation "Highlight nested parentheses, brackets, and braces according to their depth." + :evil-leader "tCd") + (when (memq dotspacemacs-highlight-delimiters '(any all)) + (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))))) + +(defun spacemacs-editing-visual/init-term-cursor () + (use-package term-cursor + :if (not (display-graphic-p)) + :defer t + :init (global-term-cursor-mode))) (defun spacemacs-editing-visual/init-volatile-highlights () (use-package volatile-highlights - :defer (spacemacs/defer 2) + :defer t + :init + (progn + (spacemacs|add-toggle volatile-highlights + :mode volatile-highlights-mode + :documentation "Display visual feedback for some operations." + :evil-leader "thv") + (volatile-highlights-mode t)) :config (progn - (require 'volatile-highlights) ;; additional extensions ;; evil - (vhl/define-extension 'evil - 'evil-move - 'evil-paste-after - 'evil-paste-before - 'evil-paste-pop) (with-eval-after-load 'evil + (vhl/define-extension 'evil + 'evil-move + 'evil-paste-after + 'evil-paste-before + 'evil-paste-pop) (vhl/install-extension 'evil) (vhl/load-extension 'evil)) ;; undo-tree - (vhl/define-extension 'undo-tree - 'undo-tree-move - 'undo-tree-yank) (with-eval-after-load 'undo-tree + (vhl/define-extension 'undo-tree + 'undo-tree-move + 'undo-tree-yank) (vhl/install-extension 'undo-tree) (vhl/load-extension 'undo-tree)) - (volatile-highlights-mode) (spacemacs|hide-lighter volatile-highlights-mode)))) + +(defun spacemacs-editing-visual/init-writeroom-mode () + (use-package writeroom-mode + :defer t + :custom (writeroom-mode-line-toggle-position 'mode-line-format) + :init + (progn + (spacemacs|add-toggle centered-buffer + :status writeroom-mode + :on (let ((writeroom-maximize-window nil) + (writeroom-mode-line t)) + (writeroom-mode 1)) + :on-message "Centered-buffer is enabled." + :off (writeroom-mode -1) + :off-message "Centered-buffer is disabled." + :documentation "Centerize current buffer." + :evil-leader "wcc") + (spacemacs|add-toggle distraction-free + :status writeroom-mode + :on (let ((writeroom-maximize-window t) + (writeroom-mode-line nil)) + (writeroom-mode 1)) + :on-message "Distraction-free is enabled." + :off (writeroom-mode -1) + :off-message "Distraction-free is disabled." + :documentation "Centerize and maximize current buffer." + :evil-leader "wcC") + (spacemacs/set-leader-keys "wc." #'spacemacs/centered-buffer-transient-state) + (spacemacs|define-transient-state centered-buffer + :title "Centered Buffer Transient State" + :bindings + ("m" writeroom-toggle-mode-line "modeline") + ("[" writeroom-decrease-width "shrink") + ("]" writeroom-increase-width "enlarge") + ("=" writeroom-adjust-width "adjust width"))))) + +;;; packages.el ends here