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