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-10-28 03:31:51 -04:00
|
|
|
(fringe-mode '(3 . 3))
|
2015-10-01 03:40:09 -04:00
|
|
|
(set-frame-font narf-default-font)
|
2015-10-15 14:01:53 -04:00
|
|
|
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
|
2015-10-26 01:29:38 -04:00
|
|
|
(setq initial-frame-alist '((width . 120) (height . 80))))
|
|
|
|
(unless window-system
|
|
|
|
(menu-bar-mode -1))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
2015-09-30 13:47:57 -04:00
|
|
|
;; Highlight matching parens
|
2015-10-03 04:57:24 -04:00
|
|
|
(setq show-paren-delay 0.075)
|
2015-06-04 18:23:21 -04:00
|
|
|
|
2015-09-30 13:47:57 -04:00
|
|
|
(global-hl-line-mode 1) ; do highlight line
|
2015-10-26 01:29:38 -04:00
|
|
|
(blink-cursor-mode -1) ; do blink cursor
|
2015-09-30 13:47:57 -04:00
|
|
|
(tooltip-mode -1) ; don't show tooltips
|
2015-06-04 18:23:21 -04:00
|
|
|
|
|
|
|
(setq-default
|
2015-10-08 01:46:19 -04:00
|
|
|
blink-matching-paren nil
|
2015-10-26 01:29:38 -04:00
|
|
|
|
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-10-12 04:31:55 -04:00
|
|
|
uniquify-buffer-name-style nil
|
|
|
|
|
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-10-26 01:29:38 -04:00
|
|
|
redisplay-dont-pause nil
|
2015-06-04 18:23:21 -04:00
|
|
|
indicate-buffer-boundaries nil
|
|
|
|
indicate-empty-lines nil
|
2015-10-15 14:01:53 -04:00
|
|
|
fringes-outside-margins t ; fringes on the other side of line numbers
|
2015-10-26 01:29:38 -04:00
|
|
|
left-margin 1
|
|
|
|
|
|
|
|
jit-lock-defer-time 0
|
|
|
|
jit-lock-stealth-time 3
|
2015-10-15 14:01:53 -04:00
|
|
|
|
|
|
|
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))
|
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
|
2015-07-28 13:13:20 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2015-10-15 14:01:53 -04:00
|
|
|
(use-package hl-todo
|
|
|
|
:commands hl-todo-mode
|
|
|
|
:init
|
2015-10-26 01:29:38 -04:00
|
|
|
(add-hook! (prog-mode puml-mode) 'hl-todo-mode)
|
2015-10-15 14:01:53 -04:00
|
|
|
(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)
|
|
|
|
|
2015-10-08 01:49:13 -04:00
|
|
|
(use-package popwin
|
|
|
|
:config
|
2015-10-15 14:01:53 -04:00
|
|
|
(setq popwin:popup-window-height 25)
|
2015-10-08 01:49:13 -04:00
|
|
|
(mapc (lambda (rule) (push rule popwin:special-display-config))
|
2015-10-23 04:41:27 -04:00
|
|
|
'(("*quickrun*" :position bottom :height 10 :stick t)
|
2015-10-08 01:49:13 -04:00
|
|
|
("*scratch*" :position bottom :height 20 :stick t :dedicated t)
|
|
|
|
("*helm-ag-edit*" :position bottom :height 20 :stick t)
|
2015-10-15 14:01:53 -04:00
|
|
|
(help-mode :position bottom :height 15 :stick t)
|
2015-10-08 01:49:13 -04:00
|
|
|
("^\\*[Hh]elm.*?\\*\\'" :regexp t :position bottom :height 15)
|
2015-10-13 00:46:17 -04:00
|
|
|
("*eshell*" :position left :width 80 :stick t :dedicated t)
|
|
|
|
("*Apropos*" :position bottom :height 40 :stick t :dedicated t)
|
2015-10-28 03:31:51 -04:00
|
|
|
("*Backtrace*" :position bottom :height 15 :stick t)
|
|
|
|
("^\\*Org-Babel.*\\*$" :regexp t :position bottom :height 15)
|
|
|
|
))
|
2015-10-08 01:49:13 -04:00
|
|
|
(popwin-mode 1))
|
|
|
|
|
2015-10-15 14:01:53 -04:00
|
|
|
(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
|
2015-10-26 01:29:38 -04:00
|
|
|
'undo-tree-undo 'undo-tree-redo)
|
2015-10-15 14:01:53 -04:00
|
|
|
(vhl/install-extension 'my-undo-tree-highlights)
|
|
|
|
(volatile-highlights-mode t))
|
|
|
|
|
2015-10-26 01:29:38 -04:00
|
|
|
(use-package nlinum
|
2015-10-28 03:31:51 -04:00
|
|
|
:commands nlinum-mode
|
2015-06-06 06:40:33 -04:00
|
|
|
:preface
|
|
|
|
(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
|
2015-10-03 04:56:33 -04:00
|
|
|
(defface linum-highlight-face '((t (:inherit linum))) "Face for line highlights")
|
2015-10-21 05:16:32 -04:00
|
|
|
|
2015-10-03 04:56:33 -04:00
|
|
|
(defun narf|nlinum-enable ()
|
|
|
|
(nlinum-mode +1)
|
|
|
|
(add-hook! post-command 'narf|nlinum-hl-line))
|
2015-10-21 05:16:32 -04:00
|
|
|
|
2015-10-03 04:56:33 -04:00
|
|
|
(defun narf|nlinum-disable ()
|
|
|
|
(nlinum-mode -1)
|
|
|
|
(remove-hook 'post-command-hook 'narf|nlinum-hl-line)
|
|
|
|
(narf|nlinum-unhl-line))
|
|
|
|
|
2015-10-28 17:27:26 -04:00
|
|
|
;; (add-hook! (markdown-mode prog-mode scss-mode web-mode) 'narf|nlinum-enable)
|
2015-10-03 04:56:33 -04:00
|
|
|
:config
|
2015-06-06 06:40:33 -04:00
|
|
|
(defun narf|nlinum-unhl-line ()
|
2015-09-30 13:47:57 -04:00
|
|
|
"Highlight line number"
|
2015-06-06 06:40:33 -04:00
|
|
|
(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)
|
2015-09-30 13:47:57 -04:00
|
|
|
"Unhighlight line number"
|
2015-06-06 06:40:33 -04:00
|
|
|
(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
|
2015-10-28 03:31:51 -04:00
|
|
|
(let ((max (point-max)))
|
|
|
|
(when (>= peol max)
|
|
|
|
(setq peol max)))
|
2015-06-06 06:40:33 -04:00
|
|
|
(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)
|
2015-10-26 01:29:38 -04:00
|
|
|
(let* ((disp (get-text-property 0 'display
|
|
|
|
(overlay-get ov 'before-string)))
|
2015-06-06 06:40:33 -04:00
|
|
|
(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))))))))
|
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
(add-hook! nlinum-mode
|
2015-10-26 01:29:38 -04:00
|
|
|
(setq nlinum--width
|
|
|
|
(length (int-to-string (count-lines (point-min) (point-max)))))))
|
|
|
|
|
2015-06-06 06:40:33 -04:00
|
|
|
|
2015-09-27 23:36:09 -04:00
|
|
|
;; Mode-line ;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2015-06-06 06:40:33 -04:00
|
|
|
|
2015-09-28 15:55:25 -04:00
|
|
|
(use-package spaceline-segments
|
2015-09-30 13:47:57 -04:00
|
|
|
:config
|
2015-09-28 15:55:25 -04:00
|
|
|
(setq-default
|
2015-10-15 14:01:53 -04:00
|
|
|
powerline-default-separator nil
|
2015-09-28 15:55:25 -04:00
|
|
|
powerline-height 18)
|
|
|
|
|
2015-10-01 03:40:09 -04:00
|
|
|
(defface mode-line-is-modified nil "Face for mode-line modified symbol")
|
2015-10-13 00:46:17 -04:00
|
|
|
(defface mode-line-buffer-file nil "Face for mode-line buffer file path")
|
2015-10-26 01:29:50 -04:00
|
|
|
(defface mode-line-buffer-dir nil "Face for mode-line buffer dirname")
|
2015-09-30 13:47:57 -04:00
|
|
|
|
|
|
|
;; Custom modeline segments
|
2015-09-28 15:55:25 -04:00
|
|
|
(spaceline-define-segment narf-buffer-path
|
2015-10-26 01:29:50 -04:00
|
|
|
(if buffer-file-name
|
|
|
|
(let* ((project-path (let (projectile-require-project-root) (projectile-project-root)))
|
|
|
|
(buffer-path (file-relative-name buffer-file-name project-path))
|
|
|
|
(max-length (/ (window-width) 2))
|
|
|
|
(path-len (length buffer-path)))
|
|
|
|
(concat (file-name-nondirectory (directory-file-name project-path))
|
|
|
|
"/"
|
|
|
|
(if (> path-len max-length)
|
|
|
|
(concat "…" (replace-regexp-in-string
|
|
|
|
"^.*?/" "/"
|
|
|
|
(substring buffer-path (- path-len max-length) path-len)))
|
|
|
|
buffer-path)))
|
|
|
|
"%b")
|
|
|
|
:face (if active 'mode-line-buffer-file 'mode-line-inactive)
|
|
|
|
:tight-right t)
|
|
|
|
|
|
|
|
(spaceline-define-segment narf-buffer-modified
|
|
|
|
(concat
|
2015-10-28 17:27:37 -04:00
|
|
|
(when buffer-file-name
|
|
|
|
(concat
|
|
|
|
(when (buffer-modified-p) "[+]")
|
|
|
|
(unless (file-exists-p buffer-file-name) "[!]")))
|
|
|
|
(if buffer-read-only "[RO]"))
|
2015-10-26 01:29:50 -04:00
|
|
|
:face mode-line-is-modified
|
2015-10-28 17:27:37 -04:00
|
|
|
:when (not (string-prefix-p "*" (buffer-name)))
|
2015-10-26 01:29:50 -04:00
|
|
|
:tight t)
|
2015-10-13 00:46:17 -04:00
|
|
|
|
2015-09-28 15:55:25 -04:00
|
|
|
(spaceline-define-segment narf-buffer-encoding-abbrev
|
|
|
|
"The line ending convention used in the buffer."
|
2015-10-28 17:27:37 -04:00
|
|
|
(symbol-name buffer-file-coding-system)
|
2015-10-29 02:44:10 -04:00
|
|
|
:when (not (string-match-p "utf-8" (symbol-name buffer-file-coding-system))))
|
2015-09-28 15:55:25 -04:00
|
|
|
|
|
|
|
(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")
|
2015-10-26 01:29:50 -04:00
|
|
|
(t (format ":%d%%%%" perc))))
|
|
|
|
:tight-right t)
|
2015-09-28 15:55:25 -04:00
|
|
|
|
|
|
|
(spaceline-define-segment narf-vc
|
|
|
|
"Version control info"
|
2015-10-01 03:40:09 -04:00
|
|
|
(let ((vc (vc-working-revision buffer-file-name)))
|
|
|
|
(when vc
|
2015-10-26 01:29:50 -04:00
|
|
|
(format "%s%s" vc (case (vc-state buffer-file-name)
|
|
|
|
('edited "+")
|
|
|
|
('conflict "!!!")
|
|
|
|
(t "")))))
|
|
|
|
:when (and active vc-mode))
|
2015-09-28 15:55:25 -04:00
|
|
|
|
2015-10-01 03:40:09 -04:00
|
|
|
;; Display version string
|
|
|
|
(defvar narf--env-version nil)
|
|
|
|
(defvar narf--env-command nil)
|
|
|
|
(make-variable-buffer-local 'narf--env-version)
|
|
|
|
(make-variable-buffer-local 'narf--env-command)
|
|
|
|
|
|
|
|
(spaceline-define-segment narf-env-version
|
|
|
|
"A HUD that shows which part of the buffer is currently visible."
|
2015-10-06 05:47:24 -04:00
|
|
|
(when (and narf--env-command (not narf--env-version))
|
2015-10-01 03:40:09 -04:00
|
|
|
(narf|spaceline-env-update))
|
|
|
|
narf--env-version
|
|
|
|
:when (and narf--env-version (memq major-mode '(ruby-mode enh-ruby-mode python-mode))))
|
|
|
|
|
2015-10-06 05:47:24 -04:00
|
|
|
(spaceline-define-segment narf-hud
|
|
|
|
"A HUD that shows which part of the buffer is currently visible."
|
|
|
|
(powerline-hud highlight-face default-face 1)
|
2015-10-26 01:29:50 -04:00
|
|
|
:tight-right t)
|
2015-10-06 05:47:24 -04:00
|
|
|
|
2015-10-15 14:01:53 -04:00
|
|
|
(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
|
2015-10-28 17:27:37 -04:00
|
|
|
(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)))))
|
2015-10-26 01:29:50 -04:00
|
|
|
:when (and active (bound-and-true-p anzu--state))
|
2015-10-28 17:27:37 -04:00
|
|
|
:face highlight-face
|
2015-10-26 01:29:50 -04:00
|
|
|
:tight t)
|
2015-10-08 01:49:13 -04:00
|
|
|
|
2015-09-30 13:47:57 -04:00
|
|
|
;; Initialize modeline
|
2015-09-28 15:55:25 -04:00
|
|
|
(spaceline-install
|
|
|
|
;; Left side
|
2015-10-26 01:29:50 -04:00
|
|
|
'(narf-anzu
|
2015-10-15 14:01:53 -04:00
|
|
|
(narf-buffer-path remote-host)
|
2015-10-26 01:29:50 -04:00
|
|
|
narf-buffer-modified
|
2015-10-03 04:56:52 -04:00
|
|
|
narf-vc
|
|
|
|
((flycheck-error flycheck-warning flycheck-info) :when active))
|
2015-09-28 15:55:25 -04:00
|
|
|
;; Right side
|
2015-10-15 14:01:53 -04:00
|
|
|
'((selection-info :face highlight-face)
|
2015-10-01 03:40:09 -04:00
|
|
|
narf-env-version
|
2015-09-28 15:55:25 -04:00
|
|
|
narf-buffer-encoding-abbrev
|
2015-10-26 01:29:50 -04:00
|
|
|
(major-mode (minor-modes :tight t :separator "")
|
2015-10-03 04:56:52 -04:00
|
|
|
process :when active)
|
2015-09-28 15:55:25 -04:00
|
|
|
(global :when active)
|
2015-10-15 14:01:53 -04:00
|
|
|
("%l/%c" narf-buffer-position)
|
|
|
|
narf-hud
|
2015-10-06 05:47:24 -04:00
|
|
|
)))
|
2015-06-04 18:23:21 -04:00
|
|
|
|
|
|
|
(provide 'core-ui)
|
|
|
|
;;; core-ui.el ends here
|