maybe fix linum-relative?

This commit is contained in:
MitchMarq42 2022-07-27 07:09:43 -08:00
parent 758506cdbc
commit 30b71fe441

View File

@ -233,27 +233,27 @@ targets."
(use-package embark-consult (use-package embark-consult
:after (embark consult)) :after (embark consult))
;; 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 "")
(defvar total-lines (count-lines (point-min) (point-max))) (defun mitch/get-total-width ()
(defvar total-width 4) "set up linum relative variables per buffer."
;; (defun mitch/get-total-width () (let ((total-lines (count-lines (point-min) (point-max))))
;; (+ 2 (round (log total-lines 10)))) (setq-local total-width (ceiling (log total-lines 10)))))
;; (defvar total-width 4)
(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)))
(- total-width symbol-width))) (- (mitch/get-total-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* ( (let* ((spacing (- (mitch/get-total-width) (mitch/symbol-width line-number)))
(spacing (- total-width (mitch/symbol-width line-number)))
(spacer (make-string spacing (string-to-char " ")))) (spacer (make-string spacing (string-to-char " "))))
(format (concat "%s" spacer) line-number))) (format (concat "%s" spacer) line-number)))
(defun mitch/left-pad (line-number) (defun mitch/left-pad (line-number)
@ -276,6 +276,8 @@ targets."
(face (if current-p 'linum-relative-current-face 'linum))) (face (if current-p 'linum-relative-current-face 'linum)))
(propertize (format linum-relative-format current-symbol) 'face face))) (propertize (format linum-relative-format current-symbol) 'face face)))
(linum-relative-global-mode 1) (linum-relative-global-mode 1)
;; (mitch/linum-rel-setup)
; (linum-relative 282)
:custom :custom
(linum-relative-current-symbol "") (linum-relative-current-symbol "")
) )
@ -732,7 +734,8 @@ targets."
))) )))
(use-package magit (use-package magit
:commands magit) :commands magit
:hook (magit-mode . turn-off-line-numbers))
(use-package hyperbole (use-package hyperbole
:diminish :diminish
@ -754,7 +757,6 @@ targets."
:config :config
(add-hook 'Info-mode-hook #'info-variable-pitch-mode)) (add-hook 'Info-mode-hook #'info-variable-pitch-mode))
;; (use-package empv ;; (use-package empv
;; :straight ;; :straight
;; (:type git :host github ;; (:type git :host github