Add nlinum-hl
This commit is contained in:
parent
60a02b4792
commit
861cc537cc
3 changed files with 15 additions and 37 deletions
|
@ -234,47 +234,24 @@ file."
|
||||||
(add-hook! (prog-mode text-mode)
|
(add-hook! (prog-mode text-mode)
|
||||||
(unless (eq major-mode 'org-mode)
|
(unless (eq major-mode 'org-mode)
|
||||||
(nlinum-mode +1)))
|
(nlinum-mode +1)))
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(defun doom-nlinum-flush-window (&optional window)
|
|
||||||
(let ((window (or window (selected-window)))
|
|
||||||
(orig-win (selected-window)))
|
|
||||||
(with-selected-window window
|
|
||||||
(when nlinum-mode
|
|
||||||
(if (not (eq window orig-win))
|
|
||||||
(nlinum--flush)
|
|
||||||
;; done in two steps to leave current line number highlighting alone
|
|
||||||
(nlinum--region (point-min) (max 1 (1- (line-beginning-position))))
|
|
||||||
(nlinum--region (min (point-max) (1+ (line-end-position))) (point-max)))))))
|
|
||||||
|
|
||||||
;; nlinum has a tendency to lose line numbers over time; a known issue. These
|
|
||||||
;; hooks/advisors attempt to stave off these glitches.
|
|
||||||
(defun doom*nlinum-flush-all-windows (&rest _)
|
|
||||||
"Fix nlinum margins after major UI changes (like a change of font)."
|
|
||||||
(mapc #'doom-nlinum-flush-window (doom-visible-windows))
|
|
||||||
nil)
|
|
||||||
(advice-add #'set-frame-font :after #'doom*nlinum-flush-all-windows)
|
|
||||||
|
|
||||||
(defun doom*nlinum-flush (&optional _ norecord)
|
|
||||||
;; norecord check is necessary to prevent infinite recursion in
|
|
||||||
;; `select-window'
|
|
||||||
(when (not norecord) (doom-nlinum-flush-window)))
|
|
||||||
(advice-add #'select-window :before #'doom*nlinum-flush)
|
|
||||||
(advice-add #'select-window :after #'doom*nlinum-flush)
|
|
||||||
(add-hook '+evil-esc-hook #'doom*nlinum-flush-all-windows t)
|
|
||||||
(add-hook 'focus-in-hook #'doom*nlinum-flush-all-windows)
|
|
||||||
(add-hook 'focus-out-hook #'doom*nlinum-flush-all-windows)
|
|
||||||
|
|
||||||
;;
|
|
||||||
(after! web-mode
|
|
||||||
(advice-add #'web-mode-fold-or-unfold :after #'doom*nlinum-flush))
|
|
||||||
|
|
||||||
;; Optimization: calculate line number column width beforehand
|
;; Optimization: calculate line number column width beforehand
|
||||||
(add-hook! nlinum-mode
|
(add-hook! nlinum-mode
|
||||||
(setq nlinum--width
|
(setq nlinum--width
|
||||||
(length (save-excursion (goto-char (point-max))
|
(length (save-excursion (goto-char (point-max))
|
||||||
(format-mode-line "%l"))))))
|
(format-mode-line "%l"))))))
|
||||||
|
|
||||||
|
;; Highlight current line, and other nlinum tweaks/fixes
|
||||||
|
(def-package! nlinum-hl
|
||||||
|
:after nlinum
|
||||||
|
:init (add-hook 'nlinum-mode-hook #'nlinum-hl-mode)
|
||||||
|
:config
|
||||||
|
;; nlinum has a tendency to lose line numbers over time; a known issue. These
|
||||||
|
;; hooks/advisors attempt to stave off these glitches.
|
||||||
|
(advice-add #'select-window :before #'nlinum-hl-do-flush)
|
||||||
|
(advice-add #'select-window :after #'nlinum-hl-do-flush)
|
||||||
|
(add-hook '+evil-esc-hook #'nlinum-hl-flush-all-windows t))
|
||||||
|
|
||||||
;; Helps us distinguish stacked delimiter pairs. Especially in parentheses-drunk
|
;; Helps us distinguish stacked delimiter pairs. Especially in parentheses-drunk
|
||||||
;; languages like Lisp.
|
;; languages like Lisp.
|
||||||
(def-package! rainbow-delimiters
|
(def-package! rainbow-delimiters
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
(package! highlight-indentation)
|
(package! highlight-indentation)
|
||||||
(package! highlight-numbers)
|
(package! highlight-numbers)
|
||||||
(package! nlinum)
|
(package! nlinum)
|
||||||
|
(package! nlinum-hl)
|
||||||
(package! rainbow-delimiters)
|
(package! rainbow-delimiters)
|
||||||
(package! vi-tilde-fringe)
|
(package! vi-tilde-fringe)
|
||||||
(package! visual-fill-column)
|
(package! visual-fill-column)
|
||||||
|
|
|
@ -30,12 +30,12 @@
|
||||||
|
|
||||||
;; doom-one: gives Emacs a look inspired by Dark One in Atom.
|
;; doom-one: gives Emacs a look inspired by Dark One in Atom.
|
||||||
;; <https://github.com/hlissner/emacs-doom-theme>
|
;; <https://github.com/hlissner/emacs-doom-theme>
|
||||||
(def-package! doom-themes :demand t
|
(def-package! doom-themes
|
||||||
|
:load-path "~/work/plugins/emacs-doom-themes/"
|
||||||
|
:demand t
|
||||||
:config
|
:config
|
||||||
(load-theme +doom-theme t)
|
(load-theme +doom-theme t)
|
||||||
|
|
||||||
;; nlinum line highlighting
|
|
||||||
(doom-themes-nlinum-config)
|
|
||||||
|
|
||||||
;; Add file icons to doom-neotree
|
;; Add file icons to doom-neotree
|
||||||
(doom-themes-neotree-config)
|
(doom-themes-neotree-config)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue