2015-06-06 06:40:33 -04:00
|
|
|
;;; core-ui.el --- interface settings
|
2015-06-15 09:05:52 +02:00
|
|
|
;; see lib/ui-defuns.el
|
|
|
|
|
2015-06-24 15:36:05 +02:00
|
|
|
(when window-system
|
2015-06-15 09:05:52 +02:00
|
|
|
(fringe-mode '(2 . 8))
|
2015-08-10 22:28:35 +02:00
|
|
|
;; (setq frame-title-format '(buffer-file-name "%f" ("%b")))
|
|
|
|
)
|
2015-06-06 06:40:33 -04:00
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
(setq show-paren-delay 0)
|
|
|
|
|
|
|
|
(global-hl-line-mode 1) ; do highlight line
|
|
|
|
(blink-cursor-mode 1) ; do blink cursor
|
|
|
|
(line-number-mode 1) ; do show line no in modeline
|
|
|
|
(column-number-mode 1) ; do show col no in modeline
|
|
|
|
(size-indication-mode 1) ; do show file size
|
|
|
|
(tooltip-mode -1) ; don't show tooltips
|
|
|
|
|
|
|
|
(setq-default
|
2015-07-28 13:13:20 +02:00
|
|
|
;; Multiple cursors across buffers cause a strange redraw delay for
|
|
|
|
;; some things, like auto-complete or evil-mode's cursor color
|
|
|
|
;; switching.
|
2015-06-04 18:23:21 -04:00
|
|
|
cursor-in-non-selected-windows nil
|
2015-07-28 13:13:20 +02:00
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
visible-bell nil ; silence of the bells
|
2015-06-06 06:40:33 -04:00
|
|
|
use-dialog-box nil ; avoid GUI
|
2015-06-04 18:23:21 -04:00
|
|
|
redisplay-dont-pause t
|
|
|
|
indicate-buffer-boundaries nil
|
|
|
|
indicate-empty-lines nil
|
2015-06-06 06:40:33 -04:00
|
|
|
fringes-outside-margins t) ; fringes on the other side of line numbers
|
2015-06-04 18:23:21 -04:00
|
|
|
|
2015-07-28 13:13:20 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
(use-package nlinum ; line numbers
|
|
|
|
:defer t
|
2015-06-06 06:40:33 -04:00
|
|
|
:defines nlinum--width
|
|
|
|
:preface
|
|
|
|
(defface linum '((t (:inherit default)))
|
|
|
|
"Face for line numbers" :group 'nlinum-mode)
|
|
|
|
(defface linum-highlight-face '((t (:inherit linum)))
|
|
|
|
"Face for line highlights" :group 'nlinum-mode)
|
|
|
|
(defvar narf--hl-nlinum-overlay nil)
|
|
|
|
(defvar narf--hl-nlinum-line nil)
|
2015-08-06 12:46:39 +02:00
|
|
|
(defvar nlinum-format " %3d ")
|
2015-06-06 06:40:33 -04:00
|
|
|
:init
|
|
|
|
;; Highlight line number
|
|
|
|
(defun narf|nlinum-unhl-line ()
|
|
|
|
(when narf--hl-nlinum-overlay
|
|
|
|
(let* ((ov narf--hl-nlinum-overlay)
|
|
|
|
(disp (get-text-property 0 'display (overlay-get ov 'before-string)))
|
|
|
|
(str (nth 1 disp)))
|
|
|
|
(put-text-property 0 (length str) 'face 'linum str)
|
|
|
|
(setq narf--hl-nlinum-overlay nil
|
2015-06-15 09:05:52 +02:00
|
|
|
narf--hl-nlinum-line nil))))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
|
|
|
(defun narf|nlinum-hl-line (&optional line)
|
|
|
|
(let ((line-no (or line (line-number-at-pos (point)))))
|
|
|
|
(when (and nlinum-mode (not (eq line-no narf--hl-nlinum-line)))
|
|
|
|
(let* ((pbol (if line (save-excursion (goto-char (point-min))
|
|
|
|
(forward-line line-no)
|
|
|
|
(point-at-bol))
|
|
|
|
(point-at-bol)))
|
|
|
|
(peol (1+ pbol)))
|
|
|
|
;; Handle EOF case
|
|
|
|
(when (>= peol (point-max))
|
|
|
|
(setq peol (point-max)))
|
|
|
|
(jit-lock-fontify-now pbol peol)
|
|
|
|
(let* ((overlays (overlays-in pbol peol))
|
|
|
|
(ov (-first (lambda (item) (overlay-get item 'nlinum)) overlays)))
|
|
|
|
(when ov
|
|
|
|
(narf|nlinum-unhl-line)
|
|
|
|
(let* ((disp (get-text-property 0 'display (overlay-get ov 'before-string)))
|
|
|
|
(str (nth 1 disp)))
|
|
|
|
(put-text-property 0 (length str) 'face 'linum-highlight-face str)
|
|
|
|
(put-text-property 0 (length str) 'face 'linum-highlight-face str)
|
|
|
|
(setq narf--hl-nlinum-overlay ov
|
|
|
|
narf--hl-nlinum-line line-no))))))))
|
|
|
|
|
|
|
|
(defun narf|nlinum-enable ()
|
|
|
|
(nlinum-mode +1)
|
|
|
|
(add-hook 'post-command-hook 'narf|nlinum-hl-line))
|
|
|
|
|
|
|
|
(defun narf|nlinum-disable ()
|
|
|
|
(nlinum-mode -1)
|
|
|
|
(remove-hook 'post-command-hook 'narf|nlinum-hl-line)
|
|
|
|
(narf|nlinum-unhl-line))
|
|
|
|
|
|
|
|
;; Preset width nlinum
|
2015-07-24 13:04:46 +02:00
|
|
|
(add-hook! (text-mode prog-mode scss-mode web-mode) 'narf|nlinum-enable)
|
|
|
|
(add-hook! org-mode 'narf|nlinum-disable)
|
2015-06-15 09:05:52 +02:00
|
|
|
(add-hook! nlinum-mode
|
2015-06-06 06:40:33 -04:00
|
|
|
(setq nlinum--width (length (number-to-string (count-lines (point-min) (point-max)))))))
|
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
(use-package smart-mode-line ; customized modeline
|
2015-06-06 06:40:33 -04:00
|
|
|
:init (setq-default
|
|
|
|
sml/no-confirm-load-theme t
|
|
|
|
sml/mode-width 'full
|
2015-07-28 13:13:20 +02:00
|
|
|
sml/extra-filler -6
|
2015-06-06 06:40:33 -04:00
|
|
|
sml/show-remote nil
|
|
|
|
sml/encoding-format nil
|
|
|
|
sml/modified-char "*"
|
|
|
|
sml/numbers-separator "/"
|
2015-07-28 13:13:20 +02:00
|
|
|
sml/line-number-format "%l"
|
|
|
|
sml/col-number-format "%c"
|
|
|
|
sml/position-percentage-format "%P"
|
|
|
|
sml/pre-modes-separator " ["
|
2015-06-06 06:40:33 -04:00
|
|
|
sml/pre-minor-modes-separator " "
|
2015-07-28 13:13:20 +02:00
|
|
|
sml/pos-minor-modes-separator "] "
|
2015-06-20 22:23:42 +02:00
|
|
|
sml/replacer-regexp-list '(("^~/.emacs.d/" "EMACS.D:")
|
|
|
|
("^~/Dropbox/Projects/" "PROJECTS:")
|
2015-06-06 06:40:33 -04:00
|
|
|
("^~/Dropbox/notes/" "NOTES:")
|
2015-06-15 09:05:52 +02:00
|
|
|
("^/usr/local/Cellar/" "HOMEBREW:")))
|
2015-06-04 18:23:21 -04:00
|
|
|
:config
|
2015-06-06 06:40:33 -04:00
|
|
|
;; Hack modeline to be more vim-like, and right-aligned
|
|
|
|
(defun sml/generate-minor-modes ()
|
|
|
|
(if sml/simplified
|
|
|
|
""
|
|
|
|
(let* ((nameList (rm--mode-list-as-string-list))
|
|
|
|
(last nil)
|
|
|
|
(concatList (mapconcat (lambda (mode)
|
|
|
|
(setq mode (s-trim mode))
|
|
|
|
(if (> (length mode) 1)
|
|
|
|
(prog1 (concat (if last " ") mode " ")
|
|
|
|
(setq last nil))
|
|
|
|
(prog1 mode
|
|
|
|
(setq last t))))
|
|
|
|
nameList ""))
|
|
|
|
(size (sml/fill-width-available))
|
|
|
|
(finalNameList concatList)
|
|
|
|
needs-removing filling)
|
|
|
|
(when (and sml/shorten-modes (> (length finalNameList) size))
|
|
|
|
(setq needs-removing
|
|
|
|
(1+ (sml/count-occurrences-starting-at
|
|
|
|
" " finalNameList
|
|
|
|
(- size (string-width sml/full-mode-string))))))
|
|
|
|
(when needs-removing
|
|
|
|
(setcdr (last nameList (1+ needs-removing))
|
|
|
|
(list t sml/propertized-full-mode-string)))
|
|
|
|
(unless sml/shorten-modes
|
|
|
|
(add-to-list 'nameList sml/propertized-shorten-mode-string t))
|
|
|
|
(setq filling (- size (+ (length (format-mode-line concatList)) (length mode-name) (length vc-mode))))
|
|
|
|
(setq filling (make-string (max 0 filling) sml/fill-char))
|
|
|
|
(list (propertize filling 'face 'sml/modes)
|
|
|
|
(propertize (or vc-mode "") 'face 'sml/vc)
|
|
|
|
(propertize sml/pre-modes-separator 'face 'font-lock-comment-delimiter-face)
|
|
|
|
(propertize mode-name)
|
|
|
|
'sml/pre-minor-modes-separator
|
|
|
|
concatList
|
|
|
|
(propertize sml/pos-minor-modes-separator 'face
|
|
|
|
'font-lock-comment-delimiter-face)))))
|
|
|
|
|
2015-07-28 13:13:20 +02:00
|
|
|
;; Hide evil state indicator
|
|
|
|
(after! evil (setq evil-mode-line-format nil))
|
|
|
|
;; Add small gap for anzu display
|
|
|
|
(after! anzu
|
|
|
|
(defun narf--anzu-update-mode-line (here total)
|
|
|
|
(concat (anzu--update-mode-line-default here total) " "))
|
|
|
|
(setq anzu-mode-line-update-function 'narf--anzu-update-mode-line))
|
|
|
|
(sml/setup)
|
|
|
|
(sml/apply-theme 'respectful)
|
2015-06-06 06:40:33 -04:00
|
|
|
;; Remove extra spaces in format lists
|
|
|
|
(pop mode-line-modes)
|
|
|
|
(nbutlast mode-line-modes)
|
|
|
|
;; Remove spacing in mode-line position so we can put it elsewhere
|
|
|
|
(setq mode-line-position
|
2015-07-28 13:13:20 +02:00
|
|
|
'(":" (sml/position-percentage-format
|
|
|
|
(-3 (:propertize (:eval sml/position-percentage-format) face sml/position-percentage)))))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
|
|
|
;; Rearrange and cleanup
|
|
|
|
(setq-default mode-line-format
|
2015-06-15 09:05:52 +02:00
|
|
|
'("%e"
|
2015-06-06 06:40:33 -04:00
|
|
|
mode-line-mule-info
|
|
|
|
mode-line-client
|
|
|
|
;; mode-line-remote
|
|
|
|
mode-line-frame-identification
|
|
|
|
mode-line-buffer-identification
|
|
|
|
mode-line-modified
|
|
|
|
mode-line-misc-info
|
|
|
|
mode-line-modes
|
|
|
|
mode-line-front-space
|
|
|
|
mode-line-end-spaces
|
|
|
|
" "
|
2015-07-28 13:13:20 +02:00
|
|
|
mode-line-position)))
|
2015-06-04 18:23:21 -04:00
|
|
|
|
|
|
|
(provide 'core-ui)
|
|
|
|
;;; core-ui.el ends here
|