0.4 bump; refactor + new plugins + level up emacsfu

This commit is contained in:
Henrik Lissner 2015-10-15 14:01:53 -04:00
parent d073d61531
commit c7db4e0096
12 changed files with 259 additions and 208 deletions

View file

@ -2,13 +2,12 @@
;; see lib/ui-defuns.el
(when window-system
(fringe-mode '(2 . 3))
(set-frame-font narf-default-font)
(setq frame-title-format '(buffer-file-name "%f" ("%b"))))
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
(fringe-mode '(2 . 3)))
;; Highlight matching parens
(setq show-paren-delay 0.075)
(show-paren-mode 1)
(global-hl-line-mode 1) ; do highlight line
(blink-cursor-mode 1) ; do blink cursor
@ -20,7 +19,6 @@
(setq-default
blink-matching-paren nil
line-spacing 1
;; Multiple cursors across buffers cause a strange redraw delay for
;; some things, like auto-complete or evil-mode's cursor color
;; switching.
@ -33,56 +31,62 @@
redisplay-dont-pause t
indicate-buffer-boundaries nil
indicate-empty-lines nil
fringes-outside-margins t) ; fringes on the other side of line numbers
fringes-outside-margins t ; fringes on the other side of line numbers
resize-mini-windows t)
;; hl-line-mode breaks minibuffer in TTY
(add-hook! minibuffer-setup
(make-variable-buffer-local 'global-hl-line-mode)
(setq global-hl-line-mode nil))
;; Hide modeline in help windows
(add-hook! help-mode (setq-local mode-line-format nil))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package hl-todo
:commands hl-todo-mode
:init
(add-hook! prog-mode 'hl-todo-mode)
(defvar hl-todo-keyword-faces
'(("TODO" . "#cc9393")
("NOTE" . "#d0bf8f")
("FIXME" . "#cc9393"))))
(use-package hideshow
:commands (hs-minor-mode hs-toggle-hiding hs-already-hidden-p)
:diminish hs-minor-mode
:init
(after! evil
(defun narf-load-hs-minor-mode ()
(advice-remove 'evil-toggle-fold 'narf-load-hs-minor-mode)
(hs-minor-mode 1))
(advice-add 'evil-toggle-fold :before 'narf-load-hs-minor-mode)))
(use-package rainbow-delimiters
:commands rainbow-delimiters-mode
:when (display-graphic-p)
:init (add-hook! (emacs-lisp-mode js2-mode scss-mode) 'rainbow-delimiters-mode)
:config (setq rainbow-delimiters-outermost-only-face-count 1))
(use-package rainbow-mode :defer t)
(use-package popwin
:config
(setq popwin:popup-window-height 25)
(mapc (lambda (rule) (push rule popwin:special-display-config))
'(("*quickrun*" :position bottom :height 15)
("*scratch*" :position bottom :height 20 :stick t :dedicated t)
("*helm-ag-edit*" :position bottom :height 20 :stick t)
(help-mode :position bottom :height 15 :stick t)
("^\\*[Hh]elm.*?\\*\\'" :regexp t :position bottom :height 15)
("*eshell*" :position left :width 80 :stick t :dedicated t)
("*Apropos*" :position bottom :height 40 :stick t :dedicated t)
("*Backtrace*" :position bottom :height 15 :stick t)))
(popwin-mode 1))
(use-package yascroll
:config
(add-hook! evil-insert-state-exit 'yascroll:update-scroll-bar)
(defun yascroll:show-scroll-bar ()
"Show scroll bar in BUFFER."
(interactive)
(yascroll:hide-scroll-bar)
(let ((window-lines (window-height))
(buffer-lines (count-lines (point-min) (point-max))))
(when (< window-lines buffer-lines)
(let* ((scroll-top (count-lines (point-min) (window-start)))
(thumb-window-line (yascroll:compute-thumb-window-line window-lines buffer-lines scroll-top))
(thumb-buffer-line (+ scroll-top thumb-window-line))
(thumb-size (yascroll:compute-thumb-size window-lines buffer-lines))
(make-thumb-overlay 'yascroll:make-thumb-overlay-right-fringe))
(when (<= thumb-buffer-line buffer-lines)
(yascroll:make-thumb-overlays make-thumb-overlay
thumb-window-line
thumb-size))))))
(defun yascroll:compute-thumb-size (window-lines buffer-lines)
"Return the proper size (height) of scroll bar thumb."
(let ((window-lines (* window-lines 0.93)))
(if (zerop buffer-lines)
1
(max 1 (floor (* (/ window-lines buffer-lines) window-lines))))))
(setq yascroll:scroll-bar 'right-fringe
yascroll:delay-to-hide nil)
(add-to-list 'yascroll:enabled-window-systems 'mac)
(defun yascroll:before-change (beg end))
(global-yascroll-bar-mode 1))
(use-package fill-column-indicator
:commands fci-mode
:init
@ -91,6 +95,23 @@
:config
(setq fci-rule-color "#2b303f"))
(use-package volatile-highlights
:diminish volatile-highlights-mode
:config
(vhl/define-extension 'my-evil-highlights
'evil-yank
'evil-paste-pop-proxy
'evil-paste-pop-next
'evil-paste-after
'evil-paste-before)
(vhl/install-extension 'my-evil-highlights)
(vhl/define-extension 'my-undo-tree-highlights
'undo-tree-undo
'undo-tree-redo)
(vhl/install-extension 'my-undo-tree-highlights)
(volatile-highlights-mode t))
(use-package nlinum ; line numbers
:preface
(defvar narf--hl-nlinum-overlay nil)
@ -152,7 +173,7 @@
(use-package spaceline-segments
:config
(setq-default
powerline-default-separator 'wave
powerline-default-separator nil
powerline-height 18)
;; Modeline cache
@ -171,32 +192,34 @@
(if (powerline-selected-window-active)
'mode-line-buffer-file
'mode-line-inactive))))
(concat (if buffer-file-name
(concat (propertize
(let* ((max-length (/ (window-width) 2))
(project-path (let ((p (narf/project-root)))
(if (string-match "/+\\'" p)
(replace-match "" t t p)
p)))
(path (f-dirname (f-relative buffer-file-truename (f-dirname project-path))))
(path-len (length path)))
(if (> path-len max-length)
(concat "" (replace-regexp-in-string
"^.*?/" "/"
(substring path (- path-len max-length) path-len)))
path))
'face (if (powerline-selected-window-active)
'mode-line-buffer-dir
'mode-line-inactive)
)
buffer
(if (and buffer-file-name (buffer-modified-p))
(propertize "%+" 'face 'mode-line-is-modified)))
buffer)
" "))
;; Causes right side of this segment to be square
:face line-face
:tight-right t)
(if buffer-file-name
(concat (propertize
(or narf--spaceline-file-path
(setq narf--spaceline-file-path
(let* ((max-length (/ (window-width) 2))
(project-path (let ((p (narf/project-root)))
(if (string-match "/+\\'" p)
(replace-match "" t t p)
p)))
(path (f-dirname (f-relative buffer-file-truename (f-dirname project-path))))
(path-len (length path)))
(if (> path-len max-length)
(concat "" (replace-regexp-in-string
"^.*?/" "/"
(substring path (- path-len max-length) path-len)))
path))))
'face (if (powerline-selected-window-active)
'mode-line-buffer-dir
'mode-line-inactive))
buffer
(when buffer-file-name
(propertize
(concat
(when (buffer-modified-p) "[+]")
(when buffer-read-only "[RO]")
(unless (file-exists-p buffer-file-name) "[!]"))
'face (if active 'mode-line-is-modified 'mode-line-inactive))))
buffer)))
(spaceline-define-segment narf-buffer-project-name
"The project name."
@ -210,7 +233,8 @@
(if (string-match "\\(dos\\|unix\\|mac\\)" buf-coding)
(match-string 1 buf-coding)
buf-coding))
:when (not (string-match-p "unix" (symbol-name buffer-file-coding-system))))
:when (and buffer-file-name
(not (string-match-p "unix" (symbol-name buffer-file-coding-system)))))
(spaceline-define-segment narf-buffer-position
"A more vim-like buffer position."
@ -226,7 +250,6 @@
(format " %s %s%s " (char-to-string #xe0a0) vc
(case (vc-state buffer-file-name) ('edited "+") ('conflict "!!!") (t "")))))
:when (and active vc-mode)
:face other-face
:tight t)
;; Display version string
@ -247,33 +270,38 @@
(powerline-hud highlight-face default-face 1)
:tight t)
(spaceline-define-segment narf-line-column
"The current line and column numbers."
"%l/%c")
(spaceline-define-segment narf-evil-state
"The current evil state. Requires `evil-mode' to be enabled."
(concat (substring (evil-state-property evil-state :tag t) 2 3) " ")
:when (and active (bound-and-true-p evil-local-mode))
:tight-right t)
(spaceline-define-segment narf-anzu
"Show the current match number and the total number of matches. Requires anzu
to be enabled."
(let ((here anzu--current-position)
(total anzu--total-matched))
(when anzu--state
(cl-case anzu--state
(search (format "%s/%d%s"
(anzu--format-here-position here total)
total (if anzu--overflow-p "+" "")))
(replace-query (format "%d replace" total))
(replace (format "%d/%d" here total)))))
:when (and active (bound-and-true-p anzu--state)))
;; Initialize modeline
(spaceline-install
;; Left side
'((narf-buffer-path remote-host)
'((narf-anzu :face highlight-face)
(narf-buffer-path remote-host)
narf-vc
narf-buffer-project-name
((flycheck-error flycheck-warning flycheck-info) :when active))
;; Right side
'(selection-info
anzu
'((selection-info :face highlight-face)
narf-env-version
narf-buffer-encoding-abbrev
((" " :tight t)
major-mode (minor-modes :separator " ")
major-mode (minor-modes :tight t :separator " ")
process :when active)
(global :when active)
(narf-line-column narf-buffer-position)
("%l/%c" narf-buffer-position)
narf-hud
)))
(provide 'core-ui)