Add nyan-mode to colors layer

This commit is contained in:
syl20bnr 2015-02-01 01:31:39 -05:00
parent 975fb17f0c
commit 065b2493f9
4 changed files with 96 additions and 40 deletions

View file

@ -9,6 +9,7 @@
- [Description](#description)
- [Install](#install)
- [Enable rainbow-identifiers](#enable-rainbow-identifiers)
- [Enable Nyan cat](#enable-nyan-cat)
- [Key bindings](#key-bindings)
- [Rainbow Identifiers](#rainbow-identifiers)
- [Rainbow Mode](#rainbow-mode)
@ -20,6 +21,7 @@
This layer colors your life with:
- [rainbow identifiers][]
- [rainbow mode][]
- [nyan mode][]
[rainbow identifiers][] mode will colorize each variables and functions with an
almost unique color. The keywords and the declaration of function colors are
@ -28,6 +30,8 @@ disabled in order to make the colorized variables and functions stand out.
[rainbow mode][] displays strings representing colors with the color they
represent as background.
[nyan mode][] display a Nyan cat progress bar in the mode-line.
## Install
To use this contribution add it to your `~/.spacemacs`
@ -45,8 +49,19 @@ To enable the package `rainbow-identifiers` set the variable
```elisp
(setq-default dotspacemacs-configuration-layers '(
(colors :variables
colors-enable-rainbow-identifiers t))
(colors :variables colors-enable-rainbow-identifiers t))
"List of contribution to load."
)
```
### Enable Nyan cat
To enable the package `nyan-mode` set the variable
`colors-enable-nyan-cat` to `t`:
```elisp
(setq-default dotspacemacs-configuration-layers '(
(colors :variables colors-enable-nyan-cat t))
"List of contribution to load."
)
```

View file

@ -17,7 +17,10 @@
;; Variables
(defvar colors-enable-rainbow-identifiers nil
"If non nil the `rainbow-identifers' package is enabled.")
"if non nil the `rainbow-identifers' package is enabled.")
(defvar colors-enable-nyan-cat nil
"if non nil all nyan cat packges are enabled (for now only `nyan-mode').")
;; Command prefixes

View file

@ -12,6 +12,7 @@
(defvar colors-packages
'(
nyan-mode
;; not working well for now
;; rainbow-blocks
rainbow-identifiers
@ -20,6 +21,41 @@
"List of all packages to install and/or initialize. Built-in packages
which require an initialization must be listed explicitly in the list.")
(defun colors/init-nyan-mode ()
(use-package nyan-mode
:if colors-enable-nyan-cat
:init
(progn
(nyan-mode)
(spacemacs|add-toggle nyan-cat-mode-line
:status nyan-mode
:on (nyan-mode)
:off (nyan-mode -1)
:documentation "Show a nyan cat progress bar in the mode-line."
:evil-leader "tmn")
(defun spacemacs/powerline-nyan-cat ()
"Construct a powerline segment for nyan cat."
(let* ((active (powerline-selected-window-active))
(l (1+ (truncate (powerline-width lhs))))
(r (1+ (truncate (powerline-width rhs))))
(face1 (if active 'powerline-active1 'powerline-inactive1))
(face2 (if active 'powerline-active2 'powerline-inactive2))
(separator-left
(intern (format "powerline-%s-%s"
powerline-default-separator
(car powerline-default-separator-dir))))
(separator-right
(intern (format "powerline-%s-%s"
powerline-default-separator
(cdr powerline-default-separator-dir)))))
(setq nyan-bar-length (min 32 (/ (- (window-total-width) l r) 2)))
(list
(funcall separator-right face2 face1)
(powerline-raw (nyan-create) face1)
(funcall separator-left face1 face2)))))))
(defun colors/init-rainbow-blocks ()
(use-package rainbow-blocks
:disabled t

View file

@ -1695,10 +1695,9 @@ which require an initialization must be listed explicitly in the list.")
(list (powerline-raw (spacemacs/window-number) state-face))
(list (powerline-raw (evil-state-property evil-state :tag t) state-face)))
(if (and active anzup)
(list
(funcall separator-right state-face face1)
(powerline-raw (anzu--update-mode-line) face1)
(funcall separator-right face1 line-face))
(list (funcall separator-right state-face face1)
(powerline-raw (anzu--update-mode-line) face1)
(funcall separator-right face1 line-face))
(list (funcall separator-right state-face line-face)))
;; evil state
;; (powerline-raw evil-mode-line-tag state-face)
@ -1713,35 +1712,34 @@ which require an initialization must be listed explicitly in the list.")
(funcall separator-left line-face face1)
(powerline-major-mode face1 'l)
(powerline-raw " " face1)
(if active (funcall separator-right face1 line-face)))
(when active
(funcall separator-right face1 line-face)))
;; flycheck
(if (and active flycheckp)
(list
(powerline-raw " " line-face)
(powerline-raw (spacemacs|custom-flycheck-lighter error)
'spacemacs-mode-line-flycheck-error-face)
(powerline-raw (spacemacs|custom-flycheck-lighter warning)
'spacemacs-mode-line-flycheck-warning-face)
(powerline-raw (spacemacs|custom-flycheck-lighter info)
'spacemacs-mode-line-flycheck-info-face)))
(when (and active flycheckp)
(list (powerline-raw " " line-face)
(powerline-raw (spacemacs|custom-flycheck-lighter error)
'spacemacs-mode-line-flycheck-error-face)
(powerline-raw (spacemacs|custom-flycheck-lighter warning)
'spacemacs-mode-line-flycheck-warning-face)
(powerline-raw (spacemacs|custom-flycheck-lighter info)
'spacemacs-mode-line-flycheck-info-face)))
;; separator between flycheck and minor modes
(if (and active flycheckp spacemacs-mode-line-minor-modesp)
(list
(funcall separator-left line-face face1)
(powerline-raw " " face1)
(funcall separator-right face1 line-face)))
(when (and active flycheckp spacemacs-mode-line-minor-modesp)
(list (funcall separator-left line-face face1)
(powerline-raw " " face1)
(funcall separator-right face1 line-face)))
;; minor modes
(if (and active spacemacs-mode-line-minor-modesp)
(list
(spacemacs-powerline-minor-modes line-face 'l)
(powerline-raw mode-line-process line-face 'l)
(powerline-raw " " line-face)))
(when (and active spacemacs-mode-line-minor-modesp)
(list (spacemacs-powerline-minor-modes line-face 'l)
(powerline-raw mode-line-process line-face 'l)
(powerline-raw " " line-face)))
;; version control
(if (and active (or flycheckp spacemacs-mode-line-minor-modesp))
(list (funcall separator-left (if vc-face line-face face1) vc-face)))
(if active (list (powerline-vc vc-face)
(powerline-raw " " vc-face)
(funcall separator-right vc-face face2))
(when (and active (or flycheckp spacemacs-mode-line-minor-modesp))
(list (funcall separator-left (if vc-face line-face face1) vc-face)))
(if active
(list (powerline-vc vc-face)
(powerline-raw " " vc-face)
(funcall separator-right vc-face face2))
(list (funcall separator-right face1 face2))))))
(defun spacemacs/mode-line-prepare-right ()
@ -1750,6 +1748,7 @@ which require an initialization must be listed explicitly in the list.")
(face1 (if active 'powerline-active1 'powerline-inactive1))
(face2 (if active 'powerline-active2 'powerline-inactive2))
(state-face (if active (spacemacs/current-state-face) face2))
(nyancatp (and (boundp 'nyan-mode) nyan-mode))
(batteryp (and (boundp 'fancy-battery-mode)
(symbol-value fancy-battery-mode)))
(battery-face (if batteryp (fancy-battery-powerline-face)))
@ -1785,13 +1784,13 @@ which require an initialization must be listed explicitly in the list.")
(spacemacs-powerline-new-version
(spacemacs/get-new-version-lighter-face
spacemacs-version spacemacs-new-version) 'r)))
(list
;; percentage in the file
(powerline-raw "%p" line-face 'r)
(when active
;; display hud only if necessary
(powerline-chamfer-left line-face face1)
(let ((progress (format-mode-line "%p")))
(when (and active (not nyancatp))
(let ((progress (format-mode-line "%p")))
(list
;; percentage in the file
(powerline-raw "%p" line-face 'r)
;; display hud
(powerline-chamfer-left line-face face1)
(if (string-match "\%" progress)
(powerline-hud state-face face1))))))))
@ -1799,8 +1798,11 @@ which require an initialization must be listed explicitly in the list.")
(let* ((active (powerline-selected-window-active))
(face2 (if active 'powerline-active2 'powerline-inactive2))
(lhs (spacemacs/mode-line-prepare-left))
(rhs (spacemacs/mode-line-prepare-right)))
(rhs (spacemacs/mode-line-prepare-right))
(nyancatp (and (boundp 'nyan-mode) nyan-mode)))
(concat (powerline-render lhs)
(when (and active nyancatp)
(powerline-render (spacemacs/powerline-nyan-cat)))
(powerline-fill face2 (powerline-width rhs))
(powerline-render rhs))))