linum-relative works again

This commit is contained in:
MitchMarq42 2022-08-11 06:26:14 -08:00
parent 7cc736abfa
commit 55da62fbd6

View File

@ -235,54 +235,57 @@ targets."
:after (embark consult)) :after (embark consult))
;; SORTA WORKING: Relative line numbers with stuff ;; SORTA WORKING: Relative line numbers with stuff
; (use-package linum-relative (use-package linum-relative
; :diminish :diminish
; :init :init
; (require 'cl-lib) (require 'cl-lib)
; (require 'linum-relative) (require 'linum-relative)
; (setq linum-relative-current-symbol "") (setq linum-relative-current-symbol "")
; (defun mitch/get-total-width () (defun display-line-numbers-equalize ()
; "set up linum relative variables per buffer." "Equalize The width. Taken from https://emacs.stackexchange.com/questions/55165/uneven-line-numbers-with-display-line-numbers/55166#55166"
; (let ((total-lines (count-lines (point-min) (point-max)))) (setq display-line-numbers-width
; (setq-local total-width (ceiling (log total-lines 10))))) (1+ (length (number-to-string (line-number-at-pos (point-max)))))))
; ;; (defvar total-width 4) (add-hook 'prog-mode-hook #'display-line-numbers-equalize)
; (defun mitch/symbol-width (symbol) (defun mitch/symbol-width (symbol)
; (+ 1 (floor (log symbol 10)))) (+ 1 (floor (log symbol 10))))
; (defun mitch/linum-get-left-pad (symbol) (defun mitch/linum-get-left-pad (symbol)
; "Get the number of spaces to add before the current relative line number." "Get the number of spaces to add before the current relative line number."
; (let* ((symbol-width (mitch/symbol-width line-number))) (let* ((symbol-width (mitch/symbol-width line-number)))
; (- (mitch/get-total-width) symbol-width))) (- display-line-numbers-width symbol-width)))
; (defun mitch/right-pad (line-number) (defun mitch/right-pad (line-number)
; "Pad the line number to the right." "Pad the line number to the right."
; (let* ((spacing (- (mitch/get-total-width) (mitch/symbol-width line-number))) (let* ((spacing (- (display-line-numbers-equalize)
; (spacer (make-string spacing (string-to-char " ")))) (mitch/symbol-width line-number)))
; (format (concat "%s" spacer) line-number))) (spacer (make-string spacing (string-to-char " "))))
; (defun mitch/left-pad (line-number) (format (concat "%s" spacer) line-number)))
; "Pad the line number to the left." (defun mitch/left-pad (line-number)
; (let ((spacing "Pad the line number to the left."
; (make-string (mitch/linum-get-left-pad line-number) (let ((spacing
; (string-to-char " ")))) (make-string (mitch/linum-get-left-pad line-number)
; (format (concat spacing "%s") line-number))) (string-to-char " "))))
; (defun linum-relative (line-number) (format (concat spacing "%s") line-number)))
; (let* ((diff1 (abs (- line-number linum-relative-last-pos))) (defun linum-relative (line-number)
; (diff (if (cl-minusp diff1) (let* ((diff1 (abs (- line-number linum-relative-last-pos)))
; diff1 (diff (if (cl-minusp diff1)
; (+ diff1 linum-relative-plusp-offset))) diff1
; (current-p (= diff linum-relative-plusp-offset)) (+ diff1 linum-relative-plusp-offset)))
; (current-symbol (if (and linum-relative-current-symbol current-p) (current-p (= diff linum-relative-plusp-offset))
; (if (string= "" linum-relative-current-symbol) (current-symbol (if (and linum-relative-current-symbol current-p)
; (mitch/right-pad line-number) (if (string= "" linum-relative-current-symbol)
; linum-relative-current-symbol) (mitch/right-pad line-number)
; (mitch/left-pad diff))) linum-relative-current-symbol)
; (face (if current-p 'linum-relative-current-face 'linum))) (mitch/left-pad diff)))
; (propertize (format linum-relative-format current-symbol) 'face face))) (face (if current-p 'linum-relative-current-face 'linum)))
; (linum-relative-global-mode 1) (propertize (format linum-relative-format current-symbol) 'face face)))
; ;; (mitch/linum-rel-setup) ;; (linum-relative-global-mode 1)
; ; (linum-relative 282) ;; (mitch/linum-rel-setup)
; :custom ;; (linum-relative 282)
; (linum-relative-current-symbol "") (add-hook 'prog-mode-hook #'linum-relative-mode)
; ) (add-hook 'minibuffer-exit-hook #'linum-relative-on)
(setq display-line-numbers-mode 'relative) :custom
(linum-relative-current-symbol "")
)
;; (setq display-line-numbers-mode 'relative)
;; broken terminal that doesn't compile but at least it's fast when it does ;; broken terminal that doesn't compile but at least it's fast when it does
(use-package vterm (use-package vterm