init-powerline.el 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ;; Source: https://github.com/aaronbieber/dotfiles
  2. ;; init-powerline.el --- Powerline configuration
  3. ;;; Commentary:
  4. ;;; Code:
  5. (defface my-pl-segment1-active
  6. '((t (:foreground "#000000" :background "#E1B61A")))
  7. "Powerline first segment active face.")
  8. (defface my-pl-segment1-inactive
  9. '((t (:foreground "#CEBFF3" :background "#3A2E58")))
  10. "Powerline first segment inactive face.")
  11. (defface my-pl-segment2-active
  12. '((t (:foreground "#F5E39F" :background "#8A7119")))
  13. "Powerline second segment active face.")
  14. (defface my-pl-segment2-inactive
  15. '((t (:foreground "#CEBFF3" :background "#3A2E58")))
  16. "Powerline second segment inactive face.")
  17. (defface my-pl-segment3-active
  18. '((t (:foreground "#CEBFF3" :background "#3A2E58")))
  19. "Powerline third segment active face.")
  20. (defface my-pl-segment3-inactive
  21. '((t (:foreground "#CEBFF3" :background "#3A2E58")))
  22. "Powerline third segment inactive face.")
  23. (defun air--powerline-default-theme ()
  24. "Set up my custom Powerline with Evil indicators."
  25. (setq-default mode-line-format
  26. '("%e"
  27. (:eval
  28. (let* ((active (powerline-selected-window-active))
  29. (seg1 (if active 'my-pl-segment1-active 'my-pl-segment1-inactive))
  30. (seg2 (if active 'my-pl-segment2-active 'my-pl-segment2-inactive))
  31. (seg3 (if active 'my-pl-segment3-active 'my-pl-segment3-inactive))
  32. (separator-left (intern (format "powerline-%s-%s"
  33. (powerline-current-separator)
  34. (car powerline-default-separator-dir))))
  35. (separator-right (intern (format "powerline-%s-%s"
  36. (powerline-current-separator)
  37. (cdr powerline-default-separator-dir))))
  38. (lhs (list (let ((evil-face (powerline-evil-face)))
  39. (if evil-mode
  40. (powerline-raw (powerline-evil-tag) evil-face)
  41. ))
  42. (if evil-mode
  43. (funcall separator-left (powerline-evil-face) seg1))
  44. (powerline-buffer-id seg1 'l)
  45. (powerline-raw "[%*]" seg1 'l)
  46. (when (and (boundp 'which-func-mode) which-func-mode)
  47. (powerline-raw which-func-format seg1 'l))
  48. (powerline-raw " " seg1)
  49. (funcall separator-left seg1 seg2)
  50. (when (boundp 'erc-modified-channels-object)
  51. (powerline-raw erc-modified-channels-object seg2 'l))
  52. (powerline-major-mode seg2 'l)
  53. (powerline-process seg2)
  54. (powerline-minor-modes seg2 'l)
  55. (powerline-narrow seg2 'l)
  56. (powerline-raw " " seg2)
  57. (funcall separator-left seg2 seg3)
  58. (powerline-vc seg3 'r)
  59. (when (bound-and-true-p nyan-mode)
  60. (powerline-raw (list (nyan-create)) seg3 'l))))
  61. (rhs (list (powerline-raw global-mode-string seg3 'r)
  62. (funcall separator-right seg3 seg2)
  63. (unless window-system
  64. (powerline-raw (char-to-string #xe0a1) seg2 'l))
  65. (powerline-raw "%4l" seg2 'l)
  66. (powerline-raw ":" seg2 'l)
  67. (powerline-raw "%3c" seg2 'r)
  68. (funcall separator-right seg2 seg1)
  69. (powerline-raw " " seg1)
  70. (powerline-raw "%6p" seg1 'r)
  71. (when powerline-display-hud
  72. (powerline-hud seg1 seg3)))))
  73. (concat (powerline-render lhs)
  74. (powerline-fill seg3 (powerline-width rhs))
  75. (powerline-render rhs)))))))
  76. (use-package powerline
  77. :ensure t
  78. :config
  79. (setq powerline-default-separator (if (display-graphic-p) 'arrow
  80. nil))
  81. (air--powerline-default-theme))
  82. (use-package powerline-evil
  83. :ensure t)
  84. (provide 'init-powerline)
  85. ;;; init-powerline.el ends here