2018-03-05 01:36:40 +00:00
|
|
|
;;; packages.el --- Spacemacs Defaults Layer packages File
|
2015-09-08 01:16:15 +00:00
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2015-09-08 01:16:15 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
;; 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 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-09-08 01:16:15 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(setq spacemacs-defaults-packages
|
2015-09-08 01:16:15 +00:00
|
|
|
'(
|
2016-05-14 15:41:30 +00:00
|
|
|
(abbrev :location built-in)
|
2016-08-21 15:05:21 +00:00
|
|
|
(archive-mode :location built-in)
|
2016-04-03 04:28:47 +00:00
|
|
|
(bookmark :location built-in)
|
2021-03-31 10:44:00 +00:00
|
|
|
(buffer-menu :location built-in)
|
2016-09-03 05:39:54 +00:00
|
|
|
(conf-mode :location built-in)
|
2020-09-16 19:26:27 +00:00
|
|
|
(cus-edit :location built-in
|
|
|
|
:toggle (or (eq 'vim dotspacemacs-editing-style)
|
|
|
|
(eq 'hybrid dotspacemacs-editing-style)))
|
2016-04-05 11:04:51 +00:00
|
|
|
(dired :location built-in)
|
2016-03-26 01:14:53 +00:00
|
|
|
(dired-x :location built-in)
|
2018-05-10 17:10:31 +00:00
|
|
|
(display-line-numbers :location built-in
|
|
|
|
:toggle (version<= "26" emacs-version))
|
2015-09-24 02:02:39 +00:00
|
|
|
(electric-indent-mode :location built-in)
|
2016-04-03 04:28:47 +00:00
|
|
|
(ediff :location built-in)
|
|
|
|
(eldoc :location built-in)
|
2021-03-20 00:11:21 +00:00
|
|
|
(help-fns+ :location local)
|
2016-05-14 15:41:30 +00:00
|
|
|
(hi-lock :location built-in)
|
2016-06-07 17:12:54 +00:00
|
|
|
(image-mode :location built-in)
|
2016-08-26 00:42:01 +00:00
|
|
|
(imenu :location built-in)
|
2018-05-10 17:10:31 +00:00
|
|
|
(linum :location built-in :toggle (version< emacs-version "26"))
|
2016-03-13 06:10:13 +00:00
|
|
|
(occur-mode :location built-in)
|
2015-11-10 07:58:41 +00:00
|
|
|
(package-menu :location built-in)
|
2016-06-05 04:04:53 +00:00
|
|
|
;; page-break-lines is shipped with spacemacs core
|
|
|
|
(page-break-lines :location built-in)
|
2015-09-24 03:47:36 +00:00
|
|
|
(process-menu :location built-in)
|
2016-04-03 04:28:47 +00:00
|
|
|
(recentf :location built-in)
|
|
|
|
(savehist :location built-in)
|
|
|
|
(saveplace :location built-in)
|
|
|
|
(subword :location built-in)
|
2016-05-20 14:37:02 +00:00
|
|
|
(tar-mode :location built-in)
|
2015-09-24 03:47:36 +00:00
|
|
|
(uniquify :location built-in)
|
2015-10-11 03:54:09 +00:00
|
|
|
(url :location built-in)
|
2016-04-26 04:30:23 +00:00
|
|
|
(visual-line-mode :location built-in)
|
2016-04-03 04:28:47 +00:00
|
|
|
(whitespace :location built-in)
|
|
|
|
(winner :location built-in)
|
2021-03-19 05:29:19 +00:00
|
|
|
(zone :location built-in)))
|
2015-09-08 01:16:15 +00:00
|
|
|
|
2021-03-20 00:11:21 +00:00
|
|
|
|
2015-09-08 01:16:15 +00:00
|
|
|
;; Initialization of packages
|
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-abbrev ()
|
2016-05-14 15:41:30 +00:00
|
|
|
(spacemacs|hide-lighter abbrev-mode))
|
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-archive-mode ()
|
2016-08-21 15:05:21 +00:00
|
|
|
(evilified-state-evilify-map archive-mode-map
|
|
|
|
:mode archive-mode
|
|
|
|
:eval-after-load archive-mode))
|
|
|
|
|
2021-03-31 10:44:00 +00:00
|
|
|
(defun spacemacs-defaults/init-buffer-menu ()
|
2021-03-31 15:05:19 +00:00
|
|
|
(with-eval-after-load 'evil-collection
|
|
|
|
(add-to-list
|
|
|
|
'spacemacs-evil-collection-allowed-list '(buff-menu "buff-menu"))))
|
2021-03-31 10:44:00 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-bookmark ()
|
2015-09-08 01:16:15 +00:00
|
|
|
(use-package bookmark
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-09-08 01:16:15 +00:00
|
|
|
:init
|
2016-04-06 09:28:06 +00:00
|
|
|
(progn
|
|
|
|
(setq bookmark-default-file (concat spacemacs-cache-directory "bookmarks")
|
|
|
|
;; autosave each change
|
|
|
|
bookmark-save-flag 1)
|
|
|
|
(spacemacs/set-leader-keys "fb" 'bookmark-jump))))
|
2015-09-08 01:16:15 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-conf-mode ()
|
2016-09-03 05:39:54 +00:00
|
|
|
:init
|
|
|
|
;; explicitly derive conf-mode from text-mode major-mode
|
|
|
|
(add-hook 'conf-mode-hook 'spacemacs/run-text-mode-hooks))
|
|
|
|
|
2020-09-15 17:17:45 +00:00
|
|
|
(defun spacemacs-defaults/init-cus-edit ()
|
2020-09-16 19:26:27 +00:00
|
|
|
;; Arguably a Vim user's first expectation for such a buffer would be a kind
|
|
|
|
;; of normal mode; besides, `evilified' conflicts with text insertion for
|
|
|
|
;; search.
|
|
|
|
(evil-set-initial-state 'Custom-mode 'normal)
|
|
|
|
;; Notes on how this effects the default `custom-mode-map':
|
|
|
|
;; - `TAB' works as `widget-forward' without modification
|
2020-09-28 14:05:34 +00:00
|
|
|
;; - `<S-TAB>' works as `widget-backward' without modification
|
2020-09-16 19:26:27 +00:00
|
|
|
;; - `n' as `widget-forward' is redundant with `TAB' and collides with the
|
|
|
|
;; - `evil-ex-search-next' mapping which is useful here. Omitting
|
|
|
|
;; intensionally.
|
2020-09-28 14:05:34 +00:00
|
|
|
;; - `p' doesn't make any sense without `n' and is redundant with `<S-TAB>'.
|
2020-09-16 19:26:27 +00:00
|
|
|
;; Omitting intensionally.
|
|
|
|
;; - `q' as `Custom-buffer-done' conflicts with the Evil record macro
|
|
|
|
;; binding, which is, however, of questionable value in a Custom buffer;
|
|
|
|
;; and there is precedent in many other Spacemacs contexts to bind it to
|
|
|
|
;; quit actions rather than default evil one; choosing to restore.
|
|
|
|
;; - `SPC' as `scroll-up-command' conflicts with the all-important Spacemacs
|
|
|
|
;; menu. Omitting intensionally. Evil `C-u' works instead.
|
|
|
|
;; - `S-SPC' as `scroll-down-command' makes no sense without `SPC' as
|
2020-09-28 14:05:34 +00:00
|
|
|
;; `scroll-up-command'. Evil `C-d' works instead.
|
2020-09-16 19:26:27 +00:00
|
|
|
;; - `C-x' as a prefix command still works.
|
|
|
|
;; - `C-c' as a prefix command still works.
|
|
|
|
;; - `u' as `Custom-goto-parent' conflicts with Evil undo. However it is
|
|
|
|
;; questionable whether this will work properly in a Custom buffer;
|
|
|
|
;; choosing to restore this binding.
|
2020-09-18 17:36:40 +00:00
|
|
|
(evil-define-key 'normal custom-mode-map (kbd "q") 'Custom-buffer-done)
|
|
|
|
(evil-define-key 'normal custom-mode-map (kbd "u") 'Custom-goto-parent)
|
2020-09-16 19:26:27 +00:00
|
|
|
;; `RET' does not work well in the search field. Fix:
|
2020-09-18 17:36:40 +00:00
|
|
|
(evil-define-key '(insert normal) custom-mode-map (kbd "RET") 'spacemacs/custom-newline)
|
|
|
|
;; There is a separate map for links, oddly enough. Separate it from the
|
|
|
|
;; `custom-mode-map' bindings, which is its parent by default.
|
|
|
|
(set-keymap-parent custom-mode-link-map nil)
|
|
|
|
;; Evil doesn't seem to be properly in control of what is going on in these
|
|
|
|
;; widget-induced keymaps, so just use base bindings to sort this out
|
|
|
|
(define-key custom-mode-link-map (kbd "q") 'Custom-buffer-done)
|
|
|
|
(define-key custom-mode-link-map (kbd "u") 'Custom-goto-parent))
|
2020-09-15 17:17:45 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-dired ()
|
2016-04-05 11:04:51 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2018-05-29 20:57:17 +00:00
|
|
|
"ad" 'spacemacs/dired
|
2016-04-05 11:04:51 +00:00
|
|
|
"fj" 'dired-jump
|
|
|
|
"jd" 'dired-jump
|
2019-11-12 11:42:50 +00:00
|
|
|
"jD" 'dired-jump-other-window)
|
|
|
|
;; The search next/previous commands are different
|
|
|
|
;; because of the `evil-search-module' values:
|
|
|
|
;; vim = evil-search, hybrid = isearch
|
|
|
|
(when (eq 'vim dotspacemacs-editing-style)
|
|
|
|
(evil-define-key 'normal dired-mode-map (kbd "n") 'evil-ex-search-next)
|
|
|
|
(evil-define-key 'normal dired-mode-map (kbd "N") 'evil-ex-search-previous))
|
|
|
|
(when (eq 'hybrid dotspacemacs-editing-style)
|
|
|
|
(evil-define-key 'normal dired-mode-map (kbd "n") 'evil-search-next)
|
2021-01-30 08:57:38 +00:00
|
|
|
(evil-define-key 'normal dired-mode-map (kbd "N") 'evil-search-previous))
|
|
|
|
(add-hook 'spacemacs-post-user-config-hook
|
|
|
|
'spacemacs/dired-remove-evil-mc-gr-which-key-entry))
|
2016-04-05 11:04:51 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-dired-x ()
|
2016-04-07 22:32:06 +00:00
|
|
|
(use-package dired-x
|
|
|
|
:commands (dired-jump
|
|
|
|
dired-jump-other-window
|
|
|
|
dired-omit-mode)))
|
2016-03-26 01:14:53 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-electric-indent-mode ()
|
2015-09-08 01:16:15 +00:00
|
|
|
(electric-indent-mode))
|
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-visual-line-mode ()
|
2016-05-06 08:09:44 +00:00
|
|
|
(spacemacs|diminish visual-line-mode " Ⓛ" " L"))
|
2016-04-26 04:30:23 +00:00
|
|
|
|
2015-09-08 01:16:15 +00:00
|
|
|
;; notes from mijoharas
|
|
|
|
;; We currently just set a few variables to make it look nicer.
|
|
|
|
;; Here is my first attempt at evilifying the buffer, does not work correctly, help is very much welcome.
|
|
|
|
|
|
|
|
;; ```
|
|
|
|
;; (defun ediff/setup-ediff-keymaps ()
|
|
|
|
;; "setup the evil ediff keymap"
|
|
|
|
;; (progn
|
|
|
|
;; (add-to-list 'evil-emacs-state-modes 'Ediff)
|
2015-11-05 13:09:00 +00:00
|
|
|
;; (evilified-state-evilify ediff-mode-map)
|
2015-09-08 01:16:15 +00:00
|
|
|
;; (spacemacs/activate-evil-leader-for-map 'ediff-mode-map)
|
|
|
|
;; )
|
|
|
|
;; )
|
|
|
|
|
|
|
|
;; ;; inside the use-package function
|
|
|
|
;; (add-hook 'ediff-keymap-setup-hook 'ediff/setup-ediff-keymaps)
|
|
|
|
;; ```
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-ediff ()
|
2015-09-08 01:16:15 +00:00
|
|
|
(use-package ediff
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-09-08 01:16:15 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
;; first we set some sane defaults
|
|
|
|
(setq-default
|
|
|
|
ediff-window-setup-function 'ediff-setup-windows-plain
|
|
|
|
;; emacs is evil and decrees that vertical shall henceforth be horizontal
|
|
|
|
ediff-split-window-function 'split-window-horizontally
|
2016-01-30 23:00:50 +00:00
|
|
|
ediff-merge-split-window-function 'split-window-horizontally)
|
2016-07-07 12:34:22 +00:00
|
|
|
;; show org ediffs unfolded
|
|
|
|
(require 'outline)
|
|
|
|
(add-hook 'ediff-prepare-buffer-hook #'show-all)
|
2016-01-30 23:00:50 +00:00
|
|
|
;; restore window layout when done
|
|
|
|
(add-hook 'ediff-quit-hook #'winner-undo))))
|
2015-09-08 01:16:15 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-eldoc ()
|
2015-09-08 01:16:15 +00:00
|
|
|
(use-package eldoc
|
2018-03-31 05:10:20 +00:00
|
|
|
:defer (spacemacs/defer)
|
2020-09-20 21:56:32 +00:00
|
|
|
:init (spacemacs|require-when-dumping 'eldoc)
|
2015-09-08 01:16:15 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; enable eldoc in `eval-expression'
|
|
|
|
(add-hook 'eval-expression-minibuffer-setup-hook #'eldoc-mode)
|
|
|
|
;; enable eldoc in IELM
|
|
|
|
(add-hook 'ielm-mode-hook #'eldoc-mode)
|
|
|
|
;; don't display eldoc on modeline
|
2019-11-27 06:26:25 +00:00
|
|
|
(spacemacs|hide-lighter eldoc-mode)
|
|
|
|
|
|
|
|
;; eldoc-message-commands
|
|
|
|
(eldoc-add-command #'evil-insert)
|
|
|
|
(eldoc-add-command #'evil-insert-line)
|
|
|
|
(eldoc-add-command #'evil-append)
|
|
|
|
(eldoc-add-command #'evil-append-line)
|
|
|
|
(eldoc-add-command #'evil-force-normal-state))))
|
2015-09-08 01:16:15 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-help-fns+ ()
|
2015-11-18 16:37:54 +00:00
|
|
|
(use-package help-fns+
|
|
|
|
:commands (describe-keymap)
|
2015-11-23 03:31:29 +00:00
|
|
|
:init (spacemacs/set-leader-keys "hdK" 'describe-keymap)))
|
2015-11-18 16:37:54 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-hi-lock ()
|
2016-05-20 13:02:15 +00:00
|
|
|
(with-eval-after-load 'hi-lock
|
|
|
|
(spacemacs|hide-lighter hi-lock-mode)))
|
2015-09-24 03:47:36 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-image-mode ()
|
2016-06-07 17:12:54 +00:00
|
|
|
(use-package image-mode
|
2018-06-15 01:10:17 +00:00
|
|
|
:defer t
|
2017-10-22 19:47:41 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq image-animate-loop t)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'image-mode "ma" "animate")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'image-mode "mg" "goto file")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'image-mode "mt" "transform/resize")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'image-mode
|
|
|
|
"aa" 'image-toggle-animation
|
|
|
|
"a+" 'image-increase-speed
|
|
|
|
"a-" 'image-decrease-speed
|
|
|
|
"ar" 'image-reset-speed
|
|
|
|
"gn" 'image-next-file
|
|
|
|
"gN" 'image-previous-file
|
|
|
|
"t+" 'image-increase-size
|
|
|
|
"t-" 'image-decrease-size
|
|
|
|
"tf" 'image-mode-fit-frame
|
|
|
|
"tr" 'image-transform-reset
|
|
|
|
"th" 'image-transform-fit-to-height
|
|
|
|
"tw" 'image-transform-fit-to-width
|
|
|
|
"ts" 'image-transform-set-scale
|
|
|
|
"tr" 'image-transform-rotation))
|
2016-06-07 17:12:54 +00:00
|
|
|
:config (evilified-state-evilify-map image-mode-map
|
2017-10-22 19:47:41 +00:00
|
|
|
:mode image-mode
|
|
|
|
:bindings
|
|
|
|
"h" 'image-backward-hscroll
|
|
|
|
"j" 'image-next-line
|
|
|
|
"k" 'image-previous-line
|
|
|
|
"l" 'image-forward-hscroll)))
|
2016-06-07 17:12:54 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-imenu ()
|
2016-08-26 00:42:01 +00:00
|
|
|
(use-package imenu
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-08-26 00:42:01 +00:00
|
|
|
:init (spacemacs/set-leader-keys "ji" 'imenu)))
|
|
|
|
|
2018-05-10 17:10:31 +00:00
|
|
|
(defun spacemacs-defaults/init-display-line-numbers ()
|
|
|
|
(use-package display-line-numbers
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
Add support for visual line numbers
Emacs 26 added built-in support for line numbers, relative line numbers, and
visual line numbers. Spacemacs supports only absolute and relative, but there is
no way to access the visual mode. It's hard to get around this, since Spacemacs
abstracts line numbers to a reasonably high degree.
Arguably, `visual` is much more useful than `relative` as a display type. Visual
line numbers are like relative line numbers, but only lines that are actually
showing are counted. This means:
1. Hidden lines are not counted. If a large amount of text is folded, the line
numbers won't jump from "10" to "546". This is particularly useful in
buffers like `magit-status`, where a large amount of information is folded
by default.
2. Lines that are wrapped are counted as multiple lines, since they're being
displayed as multiple lines in the editor. Each visual line will be
numbered - unlike `relative`, where the entire thing is numbered... Once.
With standard relative line numbers, you can't actually navigate using the line
numbers in the sidebar as soon as folded or wrapped lines are introduced. Since
this is one of the main use cases for relative line numbers, this is a big
problem.
Visual mode fixes that problem. Every line that's being displayed is labelled.
Numbers always correspond to the actual number of lines you'd need to navigate
to reach that line.
This commit extends Spacemacs' line number interface to provide visual line
number support.
2019-06-17 22:32:37 +00:00
|
|
|
(cond ((spacemacs/visual-line-numbers-p)
|
|
|
|
(setq display-line-numbers-type 'visual))
|
|
|
|
((spacemacs/relative-line-numbers-p)
|
|
|
|
(setq display-line-numbers-type 'relative))
|
|
|
|
(t
|
|
|
|
(setq display-line-numbers-type t)))
|
2018-05-10 17:10:31 +00:00
|
|
|
|
2020-10-15 20:37:35 +00:00
|
|
|
(spacemacs/declare-prefix "tn" "line-numbers")
|
|
|
|
|
|
|
|
;; backwards compatibility of symbols:
|
|
|
|
;; keep the spacemacs/toggle-line-numbers & friends around
|
2018-05-10 17:10:31 +00:00
|
|
|
(spacemacs|add-toggle line-numbers
|
2020-10-15 20:37:35 +00:00
|
|
|
:status (and (featurep 'display-line-numbers)
|
|
|
|
display-line-numbers-mode
|
|
|
|
(eq display-line-numbers t))
|
|
|
|
:on (prog1 (display-line-numbers-mode)
|
|
|
|
(setq display-line-numbers t))
|
|
|
|
:off (display-line-numbers-mode -1)
|
|
|
|
:on-message "Absolute line numbers enabled."
|
|
|
|
:off-message "Line numbers disabled."
|
|
|
|
:documentation "Show the line numbers.")
|
|
|
|
(spacemacs|add-toggle absolute-line-numbers
|
2018-05-10 17:10:31 +00:00
|
|
|
:status (and (featurep 'display-line-numbers)
|
|
|
|
display-line-numbers-mode
|
|
|
|
(eq display-line-numbers t))
|
|
|
|
:on (prog1 (display-line-numbers-mode)
|
|
|
|
(setq display-line-numbers t))
|
|
|
|
:off (display-line-numbers-mode -1)
|
|
|
|
:on-message "Absolute line numbers enabled."
|
|
|
|
:off-message "Line numbers disabled."
|
|
|
|
:documentation "Show the line numbers."
|
2020-10-15 20:37:35 +00:00
|
|
|
:evil-leader "tna")
|
2018-05-10 17:10:31 +00:00
|
|
|
(spacemacs|add-toggle relative-line-numbers
|
|
|
|
:status (and (featurep 'display-line-numbers)
|
|
|
|
display-line-numbers-mode
|
|
|
|
(eq display-line-numbers 'relative))
|
|
|
|
:on (prog1 (display-line-numbers-mode)
|
|
|
|
(setq display-line-numbers 'relative))
|
|
|
|
:off (display-line-numbers-mode -1)
|
|
|
|
:documentation "Show relative line numbers."
|
|
|
|
:on-message "Relative line numbers enabled."
|
|
|
|
:off-message "Line numbers disabled."
|
2020-10-15 20:37:35 +00:00
|
|
|
:evil-leader "tnr")
|
|
|
|
|
Add support for visual line numbers
Emacs 26 added built-in support for line numbers, relative line numbers, and
visual line numbers. Spacemacs supports only absolute and relative, but there is
no way to access the visual mode. It's hard to get around this, since Spacemacs
abstracts line numbers to a reasonably high degree.
Arguably, `visual` is much more useful than `relative` as a display type. Visual
line numbers are like relative line numbers, but only lines that are actually
showing are counted. This means:
1. Hidden lines are not counted. If a large amount of text is folded, the line
numbers won't jump from "10" to "546". This is particularly useful in
buffers like `magit-status`, where a large amount of information is folded
by default.
2. Lines that are wrapped are counted as multiple lines, since they're being
displayed as multiple lines in the editor. Each visual line will be
numbered - unlike `relative`, where the entire thing is numbered... Once.
With standard relative line numbers, you can't actually navigate using the line
numbers in the sidebar as soon as folded or wrapped lines are introduced. Since
this is one of the main use cases for relative line numbers, this is a big
problem.
Visual mode fixes that problem. Every line that's being displayed is labelled.
Numbers always correspond to the actual number of lines you'd need to navigate
to reach that line.
This commit extends Spacemacs' line number interface to provide visual line
number support.
2019-06-17 22:32:37 +00:00
|
|
|
(spacemacs|add-toggle visual-line-numbers
|
|
|
|
:status (and (featurep 'display-line-numbers)
|
|
|
|
display-line-numbers-mode
|
|
|
|
(eq display-line-numbers 'visual))
|
|
|
|
:on (prog1 (display-line-numbers-mode)
|
|
|
|
(setq display-line-numbers 'visual))
|
|
|
|
:off (display-line-numbers-mode -1)
|
|
|
|
:documentation "Show relative visual line numbers."
|
|
|
|
:on-message "Visual line numbers enabled."
|
|
|
|
:off-message "Line numbers disabled."
|
2020-10-15 20:37:35 +00:00
|
|
|
:evil-leader "tnv")
|
2018-05-10 17:10:31 +00:00
|
|
|
|
|
|
|
(when (spacemacs//linum-backward-compabitility)
|
|
|
|
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
|
|
|
|
(add-hook 'text-mode-hook 'display-line-numbers-mode))
|
|
|
|
|
|
|
|
;; it's ok to add an advice before the function is defined, and we must
|
|
|
|
;; add this advice before calling `global-display-line-numbers-mode'
|
|
|
|
(advice-add #'display-line-numbers--turn-on :around #'spacemacs//linum-on)
|
|
|
|
(when dotspacemacs-line-numbers
|
2018-06-15 01:10:17 +00:00
|
|
|
;; delay the initialization of number lines when opening Spacemacs
|
|
|
|
;; normally. If opened via the command line with a file to visit then
|
2019-12-05 12:24:12 +00:00
|
|
|
;; load it immediately
|
2018-06-15 01:10:17 +00:00
|
|
|
(add-hook 'emacs-startup-hook
|
|
|
|
(lambda ()
|
|
|
|
(if (string-equal "*scratch*" (buffer-name))
|
|
|
|
(spacemacs|add-transient-hook window-configuration-change-hook
|
|
|
|
(lambda ()
|
|
|
|
(global-display-line-numbers-mode))
|
|
|
|
lazy-loading-line-numbers)
|
|
|
|
(global-display-line-numbers-mode))))))))
|
2018-05-10 17:10:31 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-linum ()
|
2016-11-04 18:33:40 +00:00
|
|
|
(use-package linum
|
2017-02-05 18:50:50 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq linum-format "%4d")
|
|
|
|
(spacemacs|add-toggle line-numbers
|
|
|
|
:mode linum-mode
|
|
|
|
:documentation "Show the line numbers."
|
|
|
|
:evil-leader "tn")
|
|
|
|
(advice-add #'linum-update-window
|
|
|
|
:after #'spacemacs//linum-update-window-scale-fix)
|
|
|
|
(advice-add #'linum-on
|
|
|
|
:around #'spacemacs//linum-on))
|
2016-11-04 18:33:40 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2017-02-05 18:50:50 +00:00
|
|
|
(when (spacemacs//linum-backward-compabitility)
|
|
|
|
(add-hook 'prog-mode-hook 'linum-mode)
|
|
|
|
(add-hook 'text-mode-hook 'linum-mode))
|
2016-11-04 18:33:40 +00:00
|
|
|
(when dotspacemacs-line-numbers
|
2017-02-05 18:50:50 +00:00
|
|
|
(global-linum-mode)))))
|
2016-05-12 15:12:13 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-occur-mode ()
|
2016-03-13 06:10:13 +00:00
|
|
|
(evilified-state-evilify-map occur-mode-map
|
|
|
|
:mode occur-mode))
|
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-package-menu ()
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state-evilify-map package-menu-mode-map
|
2015-11-10 07:58:41 +00:00
|
|
|
:mode package-menu-mode))
|
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-page-break-lines ()
|
2016-06-05 04:04:53 +00:00
|
|
|
(require 'page-break-lines)
|
|
|
|
(global-page-break-lines-mode t)
|
|
|
|
(spacemacs|hide-lighter page-break-lines-mode))
|
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-process-menu ()
|
2015-11-21 10:07:14 +00:00
|
|
|
(evilified-state-evilify process-menu-mode process-menu-mode-map))
|
2015-09-24 03:47:36 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-recentf ()
|
2015-09-08 01:16:15 +00:00
|
|
|
(use-package recentf
|
2018-03-31 05:10:20 +00:00
|
|
|
:defer (spacemacs/defer)
|
2019-05-05 07:21:21 +00:00
|
|
|
:commands (recentf-save-list)
|
2015-09-08 01:16:15 +00:00
|
|
|
:init
|
2015-11-03 04:08:22 +00:00
|
|
|
(progn
|
2020-09-20 21:56:32 +00:00
|
|
|
(spacemacs|require-when-dumping 'recentf)
|
2018-03-31 05:10:20 +00:00
|
|
|
(when (spacemacs/defer)
|
|
|
|
(add-hook 'find-file-hook (lambda () (unless recentf-mode
|
|
|
|
(recentf-mode)
|
|
|
|
(recentf-track-opened-file)))))
|
2015-11-03 04:08:22 +00:00
|
|
|
(setq recentf-save-file (concat spacemacs-cache-directory "recentf")
|
|
|
|
recentf-max-saved-items 1000
|
|
|
|
recentf-auto-cleanup 'never
|
|
|
|
recentf-auto-save-timer (run-with-idle-timer 600 t
|
|
|
|
'recentf-save-list)))
|
2015-11-03 00:13:06 +00:00
|
|
|
:config
|
2015-11-03 04:08:22 +00:00
|
|
|
(progn
|
|
|
|
(add-to-list 'recentf-exclude
|
2018-03-04 05:04:10 +00:00
|
|
|
(recentf-expand-file-name spacemacs-cache-directory))
|
|
|
|
(add-to-list 'recentf-exclude (recentf-expand-file-name package-user-dir))
|
2015-11-03 04:08:22 +00:00
|
|
|
(add-to-list 'recentf-exclude "COMMIT_EDITMSG\\'"))))
|
2015-09-08 01:16:15 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-savehist ()
|
2015-09-08 01:16:15 +00:00
|
|
|
(use-package savehist
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
;; Minibuffer history
|
|
|
|
(setq savehist-file (concat spacemacs-cache-directory "savehist")
|
|
|
|
enable-recursive-minibuffers t ; Allow commands in minibuffers
|
|
|
|
history-length 1000
|
|
|
|
savehist-additional-variables '(mark-ring
|
|
|
|
global-mark-ring
|
|
|
|
search-ring
|
|
|
|
regexp-search-ring
|
2021-01-26 10:11:54 +00:00
|
|
|
extended-command-history
|
|
|
|
kill-ring)
|
2015-09-08 01:16:15 +00:00
|
|
|
savehist-autosave-interval 60)
|
|
|
|
(savehist-mode t))))
|
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-saveplace ()
|
2015-09-08 01:16:15 +00:00
|
|
|
(use-package saveplace
|
|
|
|
:init
|
|
|
|
(progn
|
2015-10-09 13:46:10 +00:00
|
|
|
(if (fboundp 'save-place-mode)
|
|
|
|
;; Emacs 25 has a proper mode for `save-place'
|
|
|
|
(save-place-mode)
|
|
|
|
(setq save-place t))
|
2015-09-08 01:16:15 +00:00
|
|
|
;; Save point position between sessions
|
2015-10-09 13:46:10 +00:00
|
|
|
(setq save-place-file (concat spacemacs-cache-directory "places")))))
|
2015-09-08 01:16:15 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-subword ()
|
2016-03-15 03:17:09 +00:00
|
|
|
(use-package subword
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-03-15 03:17:09 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(unless (category-docstring ?U)
|
|
|
|
(define-category ?U "Uppercase")
|
|
|
|
(define-category ?u "Lowercase"))
|
|
|
|
(modify-category-entry (cons ?A ?Z) ?U)
|
|
|
|
(modify-category-entry (cons ?a ?z) ?u)
|
|
|
|
(make-variable-buffer-local 'evil-cjk-word-separating-categories)
|
|
|
|
(defun spacemacs//subword-enable-camel-case ()
|
|
|
|
"Add support for camel case to subword."
|
|
|
|
(if subword-mode
|
|
|
|
(push '(?u . ?U) evil-cjk-word-separating-categories)
|
|
|
|
(setq evil-cjk-word-separating-categories
|
|
|
|
(default-value 'evil-cjk-word-separating-categories))))
|
|
|
|
(add-hook 'subword-mode-hook 'spacemacs//subword-enable-camel-case)
|
|
|
|
(spacemacs|add-toggle camel-case-motion
|
|
|
|
:mode subword-mode
|
|
|
|
:documentation "Toggle CamelCase motions."
|
|
|
|
:evil-leader "tc")
|
|
|
|
(spacemacs|add-toggle camel-case-motion-globally
|
|
|
|
:mode global-subword-mode
|
|
|
|
:documentation "Globally toggle CamelCase motions."
|
|
|
|
:evil-leader "t C-c"))
|
|
|
|
:config
|
|
|
|
(spacemacs|diminish subword-mode " ⓒ" " c")))
|
2015-09-08 01:16:15 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-tar-mode ()
|
2016-05-20 14:37:02 +00:00
|
|
|
(evilified-state-evilify-map tar-mode-map
|
|
|
|
:mode tar-mode
|
|
|
|
:eval-after-load tar-mode))
|
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-uniquify ()
|
2015-09-24 03:47:36 +00:00
|
|
|
(require 'uniquify)
|
|
|
|
;; When having windows with repeated filenames, uniquify them
|
|
|
|
;; by the folder they are in rather those annoying <2>,<3>,.. etc
|
|
|
|
(setq uniquify-buffer-name-style 'post-forward-angle-brackets
|
|
|
|
;; don't screw special buffers
|
|
|
|
uniquify-ignore-buffers-re "^\\*"))
|
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-url ()
|
2015-10-11 03:54:09 +00:00
|
|
|
;; gravatars from magit use this to store their cache
|
|
|
|
(setq url-configuration-directory (concat spacemacs-cache-directory "url/")))
|
2015-10-10 00:04:37 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-whitespace ()
|
2015-09-08 01:16:15 +00:00
|
|
|
(use-package whitespace
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-09-08 01:16:15 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2021-01-19 11:34:14 +00:00
|
|
|
(when dotspacemacs-show-trailing-whitespace
|
|
|
|
(set-face-attribute
|
|
|
|
'trailing-whitespace nil
|
|
|
|
:background (face-attribute 'font-lock-comment-face :foreground)))
|
|
|
|
(add-hook 'prog-mode-hook 'spacemacs//trailing-whitespace)
|
2015-09-08 01:16:15 +00:00
|
|
|
|
|
|
|
(spacemacs|add-toggle whitespace
|
2016-05-31 13:11:00 +00:00
|
|
|
:mode whitespace-mode
|
2015-09-08 01:16:15 +00:00
|
|
|
:documentation "Display whitespace."
|
|
|
|
:evil-leader "tw")
|
|
|
|
(spacemacs|add-toggle whitespace-globally
|
2016-05-31 13:11:00 +00:00
|
|
|
:mode global-whitespace-mode
|
2015-09-08 01:16:15 +00:00
|
|
|
:documentation "Display whitespace globally."
|
|
|
|
:evil-leader "t C-w")
|
|
|
|
|
|
|
|
(add-hook 'diff-mode-hook 'whitespace-mode)
|
|
|
|
(add-hook 'diff-mode-hook 'spacemacs//set-whitespace-style-for-diff))
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(set-face-attribute 'whitespace-space nil
|
|
|
|
:background nil
|
|
|
|
:foreground (face-attribute 'font-lock-warning-face
|
|
|
|
:foreground))
|
|
|
|
(set-face-attribute 'whitespace-tab nil
|
|
|
|
:background nil)
|
|
|
|
(set-face-attribute 'whitespace-indentation nil
|
|
|
|
:background nil)
|
|
|
|
(spacemacs|diminish whitespace-mode " ⓦ" " w")
|
2016-06-03 00:57:15 +00:00
|
|
|
(spacemacs|diminish global-whitespace-mode " ⓦ" " w"))))
|
2015-09-08 01:16:15 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-winner ()
|
2015-09-08 01:16:15 +00:00
|
|
|
(use-package winner
|
2019-07-27 02:44:35 +00:00
|
|
|
:commands (winner-undo winner-redo)
|
2015-09-08 01:16:15 +00:00
|
|
|
:init
|
2018-03-31 05:16:43 +00:00
|
|
|
(with-eval-after-load 'winner
|
2015-09-08 01:16:15 +00:00
|
|
|
(setq spacemacs/winner-boring-buffers '("*Completions*"
|
|
|
|
"*Compile-Log*"
|
|
|
|
"*inferior-lisp*"
|
|
|
|
"*Fuzzy Completions*"
|
|
|
|
"*Apropos*"
|
|
|
|
"*Help*"
|
|
|
|
"*cvs*"
|
|
|
|
"*Buffer List*"
|
|
|
|
"*Ibuffer*"
|
2021-03-19 05:29:19 +00:00
|
|
|
"*esh command on file*"))
|
|
|
|
|
2015-09-08 01:16:15 +00:00
|
|
|
(setq winner-boring-buffers
|
2018-03-31 05:16:43 +00:00
|
|
|
(append winner-boring-buffers spacemacs/winner-boring-buffers)))))
|
2016-07-01 18:20:28 +00:00
|
|
|
|
2018-03-05 01:36:40 +00:00
|
|
|
(defun spacemacs-defaults/init-zone ()
|
2018-06-15 01:10:01 +00:00
|
|
|
(use-package zone
|
2018-07-29 19:42:32 +00:00
|
|
|
:commands (zone zone-when-idle)
|
2018-06-15 01:10:01 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2018-07-29 19:42:32 +00:00
|
|
|
(when (and dotspacemacs-zone-out-when-idle
|
2018-06-15 01:10:01 +00:00
|
|
|
(numberp dotspacemacs-zone-out-when-idle))
|
2018-07-29 19:42:32 +00:00
|
|
|
(zone-when-idle dotspacemacs-zone-out-when-idle))
|
2018-06-15 01:10:01 +00:00
|
|
|
;; remove not interesting programs
|
|
|
|
(setq zone-programs [
|
|
|
|
;; zone-pgm-jitter
|
|
|
|
zone-pgm-putz-with-case
|
|
|
|
zone-pgm-dissolve
|
|
|
|
;; zone-pgm-explode
|
|
|
|
zone-pgm-whack-chars
|
|
|
|
zone-pgm-rotate
|
|
|
|
zone-pgm-rotate-LR-lockstep
|
|
|
|
zone-pgm-rotate-RL-lockstep
|
|
|
|
zone-pgm-rotate-LR-variable
|
|
|
|
zone-pgm-rotate-RL-variable
|
|
|
|
zone-pgm-drip
|
|
|
|
;; zone-pgm-drip-fretfully
|
|
|
|
;; zone-pgm-five-oclock-swan-dive
|
|
|
|
;; zone-pgm-martini-swan-dive
|
|
|
|
zone-pgm-rat-race
|
2021-03-19 05:29:19 +00:00
|
|
|
zone-pgm-paragraph-spaz])
|
2021-03-19 23:17:46 +00:00
|
|
|
;; zone-pgm-stress
|
|
|
|
;; zone-pgm-stress-destress
|
|
|
|
;; zone-pgm-random-life
|
2018-07-29 19:42:32 +00:00
|
|
|
(spacemacs/set-leader-keys "TZ" 'zone))
|
|
|
|
:config
|
|
|
|
;; be sure to disable running zone if the user does not want it
|
|
|
|
(unless dotspacemacs-zone-out-when-idle
|
|
|
|
(zone-leave-me-alone))))
|