Polish new mode-line

This commit is contained in:
Henrik Lissner 2015-09-28 15:55:25 -04:00
parent ba28a7d6fd
commit 16c5280c36
2 changed files with 83 additions and 41 deletions

View file

@ -91,28 +91,80 @@
;; Mode-line ;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq-default powerline-default-separator nil)
(require 'spaceline-segments)
(spaceline-install
;; Left side
'((buffer-size)
(buffer-id remote-host buffer-modified)
((flycheck-error flycheck-warning flycheck-info)
:when active)
(version-control :when active))
;; Right side
`((battery :when active)
selection-info
major-mode
(((minor-modes :separator spaceline-minor-modes-separator)
process)
:when active)
(buffer-encoding-abbrev
point-position
line-column)
(global :when active)
buffer-position
hud))
(use-package spaceline-segments
:init
(setq-default
powerline-default-separator 'wave
powerline-height 18)
:config
(require 'spaceline-segments)
;; (defface powerline-border '((t (:background "#05051e"))) "")
(spaceline-define-segment narf-buffer-path
"Name of buffer."
(concat (let ((buffer-path (buffer-file-name)))
(if (and buffer-path (file-exists-p buffer-path))
(progn
(setq buffer-path (abbreviate-file-name buffer-path))
(let ((path (file-relative-name buffer-path (file-name-directory (narf/project-root))))
(max-length (/ (window-width) 2)))
(if (> (length path) max-length)
(concat "" (replace-regexp-in-string
"^.*?/" "/"
(let ((l (length path))) (substring path (- l max-length) l))))
path)))
(powerline-buffer-id)))
(if (buffer-modified-p) (propertize "*" 'font-lock-face '(:inherit powerline-active1 :foreground "orange")))
" ")
:tight-right t)
(spaceline-define-segment narf-buffer-modified
"Buffer modified marker."
(if (buffer-modified-p) "*")
:face highlight-face
:tight t)
(spaceline-define-segment narf-buffer-encoding-abbrev
"The line ending convention used in the buffer."
(let ((buf-coding (format "%s" buffer-file-coding-system)))
(if (string-match "\\(dos\\|unix\\|mac\\)" buf-coding)
(match-string 1 buf-coding)
buf-coding))
:when (not (string-match "unix" (symbol-name buffer-file-coding-system))))
(spaceline-define-segment narf-line-column
"The current line and column numbers."
"%l/%c")
(spaceline-define-segment narf-buffer-position
"A more vim-like buffer position."
(let ((perc (/ (window-end) 0.01 (point-max))))
(cond ((eq (window-start) 1) ":Top")
((>= perc 100) ":Bot")
(t (format ":%d%%%%" perc)))))
(spaceline-define-segment narf-vc
"Version control info"
(replace-regexp-in-string (regexp-quote (symbol-name (vc-deduce-backend))) "" (s-trim (powerline-vc)) t t)
:when (powerline-vc))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(spaceline-install
;; Left side
'(((narf-buffer-path :face other-face) remote-host)
((flycheck-error flycheck-warning flycheck-info)
:when active)
(narf-vc :face other-face :when active))
;; Right side
'((battery :when active)
selection-info
narf-buffer-encoding-abbrev
(major-mode (minor-modes process :when active))
(global :when active)
(narf-line-column narf-buffer-position :face powerline-border)
hud)))
(provide 'core-ui)
;;; core-ui.el ends here

View file

@ -35,7 +35,9 @@
(git-modified "#55616A")
(git-added "#436b3b")
(git-deleted "#714243"))
(git-deleted "#714243")
(dark-bg "#05051e"))
(custom-theme-set-faces
'narf-dark
@ -50,25 +52,13 @@
`(vertical-border ((t (:foreground "#000000") )))
`(mode-line ((t (:foreground ,white
:background ,gutter-light
:box (:line-width 3 :color ,gutter-light)
))))
`(mode-line-inactive ((t (:foreground ,gutter-fg
:background ,gutters-active
:box (:line-width 3 :color ,gutters-active)
))))
`(mode-line ((t (:foreground ,white :background ,gutter-light))))
`(mode-line-inactive ((t (:foreground ,gutter-fg :background ,gutters-active))))
`(mode-line-modified-face ((t (:foreground ,builtin))))
`(sml/folder ((t nil)))
`(sml/modified ((t (:foreground ,highlight))))
`(flyspell-incorrect ((t (:underline "#ff5555" :inherit unspecified))))
`(helm-source-header ((t (:background ,gutters-active :foreground ,strings :weight bold :height 1.0))))
`(helm-selection ((t (:background ,selection))))
`(powerline-active1 ((t (:background "#343A4D"))))
`(powerline-active2 ((t (:background "#3B435C"))))
`(powerline-inactive2 ((t (:background ,gutters-active))))
`(powerline-inactive2 ((t (:background ,gutters-active))))
;; Font lock faces
`(linum-highlight-face ((t (:foreground ,text :background ,line-hl :inherit linum))))