emacs - commit all stale emacs config
[dotfiles.git] / emacs.d / config / init-color-theme.el
1
2
3 ;(setq display-time-day-and-date t)
4 ;(display-time-mode t)
5
6
7 (setq ns-use-srgb-colorspace nil)
8
9 (require 'color-theme)
10
11 (load-theme 'cyberpunk t)
12
13 (require 'evil)
14 (require 'powerline)
15 ;(require 'powerline-evil)
16
17
18
19 ;(set-face-attribute 'mode-line nil :font "Source Code Pro for Powerline-10")
20
21 ;;; this variable should equal as height in mode-line
22 (custom-set-variables
23  '(powerline-height 14)
24  '(powerline-text-scale-factor 0.85)) ;; 100/140
25
26 (custom-set-faces
27 ;;; '(mode-line ((t (:foreground "#030303" :background "#bdbdbd" :box nil :height 0.8 ))))
28 ;;; '(mode-line-inactive ((t (:foreground "#f9f9f9" :background "#666666" :box nil :height 0.8)))))
29  '(mode-line ((t (:foreground "#030303" :background "#bdbdbd" :box nil  :family "Source Code Pro for Powerline" :height 100))))
30 ;; '(mode-line ((t (:foreground "#030303" :background "#bdbdbd" :box nil  :family "Source Code Pro for Powerline" :height 80))))
31  '(mode-line-inactive ((t (:foreground "#f9f9f9" :background "#666666" :box nil :family "Source Code Pro for Powerline" :height 100)))))
32
33 (defface powerline-active00 '((t (:foreground "#030303" :background "#bdbdbd" :box nil :inherit mode-line)))
34   "Powerline face 1."
35   :group 'powerline)
36
37 (defface powerline-inactive00 '((t (:foreground "#f9f9f9" :background "#666666" :box nil :inherit mode-line)))
38   "Powerline face 1."
39   :group 'powerline)
40
41 (defface powerline-active11 '((t (:background "grey22" :inherit mode-line)))
42   "Powerline face 1."
43   :group 'powerline)
44
45 (defface powerline-active22 '((t (:background "grey40" :inherit mode-line)))
46   "Powerline face 2."
47   :group 'powerline)
48
49 (defface powerline-inactive11   '((t (:background "grey11" :inherit mode-line)))
50   "Powerline face 1."
51   :group 'powerline)
52
53 (defface powerline-inactive22   '((t (:background "grey20" :inherit mode-line)))
54   "Powerline face 2."
55   :group 'powerline)
56
57
58 ;(defface powerline-active-yel '((t (:background "yellow" :inherit mode-line)))
59 (defface powerline-active-yel '((t (:background "yellow" :inherit mode-line)))
60   "Powerline face 1."
61   :group 'powerline)
62
63 (defface powerline-active-blue '((t (:background "blue" :inherit mode-line)))
64   "Powerline face 1."
65   :group 'powerline)
66
67 ;;;---------------- evil powerline
68 ; https://github.com/raugturi/powerline-evil/blob/master/powerline-evil.el
69 ; ;https://github.com/laynor/emacs-conf/blob/master/packages/sm-package-powerline.el
70 ;(defface powerline-evil-base-face '((t (:foreground "white" :inherit mode-line)))
71 ;(defface powerline-evil-base-face '((t (:foreground "black" :weight bold )))
72 (defface powerline-evil-base-face '((t (:foreground "black" :weight bold :inherit mode-line)))
73   "Base face for powerline evil faces."
74   :group 'powerline)
75
76 (defface powerline-evil-normal-face '((t (:background "green" :inherit powerline-evil-base-face)))
77   "Powerline face for evil NORMAL state."
78   :group 'powerline)
79
80 (defface powerline-evil-insert-face '((t (:background "blue" :inherit powerline-evil-base-face)))
81   "Powerline face for evil INSERT state."
82   :group 'powerline)
83
84 (defface powerline-evil-visual-face '((t (:background "orange" :inherit powerline-evil-base-face)))
85   "Powerline face for evil VISUAL state."
86   :group 'powerline)
87
88 (defface powerline-evil-operator-face   '((t (:background "cyan" :inherit powerline-evil-base-face)))
89   "Powerline face for evil OPERATOR state."
90   :group 'powerline)
91
92 (defface powerline-evil-replace-face    '((t (:background "red" :inherit powerline-evil-base-face)))
93   "Powerline face for evil REPLACE state."
94   :group 'powerline)
95
96 (defface powerline-evil-motion-face '((t (:background "magenta" :inherit powerline-evil-base-face)))
97   "Powerline face for evil MOTION state."
98   :group 'powerline)
99
100 (defface powerline-evil-emacs-face  '((t (:background "violet" :inherit powerline-evil-base-face)))
101   "Powerline face for evil EMACS state."
102   :group 'powerline)
103
104 (defun powerline-evil-face ()
105   "Function to select appropriate face based on `evil-state'."
106   (let* ((face (intern (concat "powerline-evil-" (symbol-name evil-state) "-face"))))
107     (if (facep face) face nil)))
108
109
110   (defun powerline-evil-face (active)
111     (let ((face (intern (concat "powerline-evil-" (symbol-name evil-state) "-face"))))
112       (cond ((and active (facep face))
113              face)
114             (active 'powerline-active22)
115             (t 'powerline-inactive22))))
116
117   (defun powerline-evil-face-22 (active)
118     (if (equal (symbol-name evil-state) "normal")
119
120         (let ((face (intern (concat "powerline-evil-emacs-face"))))
121           face)
122
123         (let ((face (intern (concat "powerline-evil-normal-face"))))
124           face)
125
126 ;;          (cond ((and active (facep face))
127 ;;                 face)
128 ;;                (active 'powerline-active22)
129 ;;                (t 'powerline-inactive22)))
130
131 ;;;;    (let ((face (intern (concat "powerline-evil-" (symbol-name evil-state) "-face"))))
132 ;;;;      (cond ((and active (facep face))
133 ;;;;             face)
134 ;;;;            (active 'powerline-active22)
135 ;;;;            (t 'powerline-inactive22)))
136     )
137     )
138
139
140
141   (defpowerline powerline-evil-tag
142     (concat " " (replace-regexp-in-string "[<> ]" "" (eval (evil-state-property evil-state :tag))) " "))
143
144
145
146
147
148 ;;
149 ;;http://emacser.com/mode-line.htm
150 (defun get-lines-4-mode-line ()
151   (let ((lines (count-lines (point-min) (point-max))))
152     (concat (propertize
153              (format "%d" lines)
154              'mouse-face 'mode-line-highlight
155              'face 'mode-line-lines-face
156              'help-echo (format "%d lines" lines)) " ")))
157
158
159
160 (defun powerline-simpler-vc-mode (s)
161   (if s
162       (replace-regexp-in-string "Git:" "" s)
163     s))
164
165 (defun powerline-simpler-minor-display (s)
166   (replace-regexp-in-string
167    (concat " "
168            (mapconcat 'identity '("Undo-Tree" "GitGutter" "Projectile"
169                                   "Abbrev" "ColorIds" "MRev" "ElDoc" "Paredit"
170                                   "+1" "+2" "FlyC" "Fly" ;; ":1/0"
171                                   "Fill" "AC" "FIC") "\\|")) "" s))
172
173 (defun powerline-format-default-directory (s)
174   (if s
175     (replace-regexp-in-string "/Users/peli3/"  "~/" s)
176     s))
177
178 (defun powerline-evil-tag-new ()
179   (concat (replace-regexp-in-string "[<>]" "" (powerline-evil-tag)) " ")
180   )
181
182 ;; -----------------------------------------------------------------------------
183
184 ;; -----------------------------------------------------------------------------
185 ;; |evil| buffer_name | major-mode | vc |            | position | pwd | time |
186 ;; -----------------------------------------------------------------------------
187 ;;
188 ;; ToDo:
189 ;; position and pwd only shows in some mode, such as programming mode
190 ;; using workgroup instead of pwd
191 ;; some other modes such as eshell, package, help, don't need the posittion and
192 ;; pwd
193 ;;
194
195 ;; -----------------------------------------------------------------------------
196
197 (defun powerline-ha-theme ()
198   "A powerline theme that removes many minor-modes that don't serve much purpose on the mode-line."
199   (interactive)
200   (setq-default mode-line-format
201                 '("%e"
202                   (:eval
203                    (let*
204                        ((active
205                          (powerline-selected-window-active))
206                         (mode-line
207                          (if active 'powerline-active00 'powerline-inactive00))
208                         (face1
209                          (if active 'powerline-active11 'powerline-inactive11))
210                         (face2
211                          (if active 'powerline-active22 'powerline-inactive22))
212                         (face-yel
213                          (if active 'powerline-active-yel 'powerline-inactive22))
214                         (face-blue
215                          (if active 'powerline-active-blue 'powerline-inactive22))
216                         (pl-evil-face (ignore-errors (powerline-evil-face active)))
217                         (pppp-face
218                            (intern (concat "powerline-evil-" (symbol-name evil-state) "-face")))
219
220                         (face-yel22
221                          (if active 'powerline-active-yel 'powerline-inactive22))
222                         (separator-left
223                          (intern
224                           (format "powerline-%s-%s" powerline-default-separator
225                                   (car powerline-default-separator-dir))))
226                         (separator-right
227                          (intern
228                           (format "powerline-%s-%s" powerline-default-separator
229                                   (cdr powerline-default-separator-dir))))
230                         (lhs
231                             (list
232 ;;                                (let ((evil-face (powerline-evil-face)))
233 ;;                                    (if evil-mode
234 ;;                                            (powerline-raw (powerline-evil-tag) evil-face)
235 ;;                                    )
236 ;;
237 ;;                                )
238                                 (if evil-mode
239                                 (powerline-raw (powerline-evil-tag) pl-evil-face))
240 ;;;                                (and evil-mode (funcall separator-left pppp-face face-yel))
241 ;;;;;;                                (funcall separator-left pppp-face pppp-face)
242 ;;;;                                (powerline-raw (powerline-evil-tag) pppp-face face-yel)
243 ;;                                (funcall separator-left (powerline-evil-face) face-yel)
244
245                                 (powerline-raw "%*" face-yel 'l)
246                                 (powerline-buffer-id face-yel 'l)
247                                 (powerline-raw " " face-yel)
248                                 (funcall separator-left face-yel face-blue )
249                                                 (powerline-raw " " face-blue)
250                                 (powerline-major-mode face-blue 'r)
251                                 (funcall separator-left face-blue mode-line)
252                                 (powerline-narrow mode-line 'l)
253 ;                                (powerline-vc mode-line 'r)
254                                 (powerline-simpler-vc-mode (powerline-vc mode-line 'r))
255                                 (funcall separator-left mode-line face1)))
256 ;                                (powerline-simpler-vc-mode (powerline-vc face2))))
257                         
258                         (rhs
259                             (list
260                                 (funcall separator-right face1 mode-line)
261                                 ;;  position
262 ;;                              (powerline-raw (concat " [" (powerline-format-default-directory default-directory) "] ") mode-line)
263                                 (powerline-raw (format " P:[%s] " (projectile-project-name))  mode-line)
264                                                 (funcall separator-right mode-line face-blue)
265                                 ;; pwd/workgroups
266                                 (powerline-raw (concat "%3c, %l/" (format "%d" (count-lines (point-min) (point-max))) " %4p ") face-blue)
267 ;                                               (funcall separator-right face-blue face1)
268                                 ;; date and time
269 ;;;                                         (powerline-raw (format-time-string " %m-%d") face1 'r)
270                                 (funcall separator-right face-blue face-yel)
271                                             (powerline-raw (format-time-string " %I:%M %p %m-%d %a ") face-yel 'r)))
272                         (center
273                             (list
274                                 (powerline-raw " " face1)
275                                 (funcall separator-left face1 face2)
276                                 (when
277                                     (boundp 'erc-modified-channels-object)
278                                 (powerline-raw erc-modified-channels-object face2 'l))
279                                 (powerline-major-mode face2 'l)
280                                 (powerline-process face2)
281                                 (powerline-raw " :" face2)
282
283                                 (powerline-simpler-minor-display (powerline-minor-modes face2 'l))
284
285                                 (powerline-raw " " face2)
286                                 (funcall separator-right face2 face1))))
287
288
289                      (concat
290                       (powerline-render lhs)
291                       (powerline-fill face1
292                                       (powerline-width rhs))
293                       (powerline-render rhs))
294                      ); let
295                    ); :eval
296                   ); '(
297                 ); setq
298   ); defun
299
300
301 (powerline-ha-theme)
302
303
304
305 ;;(let ((faces '(mode-line
306 ;;               powerline-active00
307 ;;               powerline-active11
308 ;;               powerline-active22
309 ;;               powerline-active-yel
310 ;;               powerline-active-blue
311 ;;               mode-line-buffer-id
312 ;;               mode-line-emphasis
313 ;;               mode-line-highlight
314 ;;               mode-line-inactive)))
315 ;;     (mapc
316 ;;;      (lambda (face) (set-face-attribute face nil :font "Source Code Pro for Powerline-10"))
317 ;;      (lambda (face) (set-face-attribute face nil :font "Courier"))
318 ;;      faces))
319
320
321
322 (provide 'init-color-theme)
323
324
325
326 ;; TODO
327 ;; 1. change color when buffer is modified
328 ;; 2. 
329 ;; show date and time in the right below minibuffer
330