doomemacs/core/core-ui.el

119 lines
4.1 KiB
EmacsLisp
Raw Normal View History

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-11 15:10:37 +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-09-27 23:36:09 -04:00
;; Mode-line ;;;;;;;;;;;;;;;;;;;;;;;;;;;
2015-06-06 06:40:33 -04:00
2015-09-27 23:36:09 -04:00
(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))
2015-06-04 18:23:21 -04:00
(provide 'core-ui)
;;; core-ui.el ends here