Fix line numbers! They are relative, they work, do not mess with them!
(also switch back to vertico because ivy does too much)
This commit is contained in:
parent
5e656cf5b4
commit
d268caa38a
@ -90,10 +90,11 @@ Made solely to reduce lines in the init file."
|
|||||||
"A tiny wrapper around `display-line-numbers-mode' or `linum'.
|
"A tiny wrapper around `display-line-numbers-mode' or `linum'.
|
||||||
For use in hooks."
|
For use in hooks."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if display-line-numbers-mode
|
(if (bound-and-true-p display-line-numbers-mode)
|
||||||
(display-line-numbers-mode -1))
|
(display-line-numbers-mode -1))
|
||||||
(linum-mode -1)
|
(linum-mode -1)
|
||||||
(linum-relative-mode -1))
|
(if (fboundp #'linum-relative-mode)
|
||||||
|
(linum-relative-mode -1)))
|
||||||
|
|
||||||
(defun mitch/terminal-setup ()
|
(defun mitch/terminal-setup ()
|
||||||
"A batch of commands to run when opening anything that looks like a terminal.
|
"A batch of commands to run when opening anything that looks like a terminal.
|
||||||
@ -111,6 +112,7 @@ For instance:
|
|||||||
For use with `vterm'."
|
For use with `vterm'."
|
||||||
(setq default-directory path))
|
(setq default-directory path))
|
||||||
|
|
||||||
|
|
||||||
;; This one line cost me over an hour of frustration...
|
;; This one line cost me over an hour of frustration...
|
||||||
(provide 'mitch-defuns)
|
(provide 'mitch-defuns)
|
||||||
|
|
||||||
|
@ -114,52 +114,88 @@
|
|||||||
:diminish)
|
:diminish)
|
||||||
|
|
||||||
;; Completion framework...
|
;; Completion framework...
|
||||||
(use-package ivy
|
;; (use-package ivy
|
||||||
:diminish
|
;; :diminish
|
||||||
:custom
|
;; :custom
|
||||||
(ivy-auto-shrink-minibuffer-alist '((t . t)))
|
;; (ivy-auto-shrink-minibuffer-alist '((t . t)))
|
||||||
:config (ivy-mode t)
|
;; :config (ivy-mode t)
|
||||||
:general
|
;; :general
|
||||||
(general-define-key
|
;; (general-define-key
|
||||||
:keymaps 'ivy-minibuffer-map
|
;; :keymaps 'ivy-minibuffer-map
|
||||||
"TAB" 'ivy-alt-done))
|
;; "TAB" 'ivy-alt-done))
|
||||||
(use-package counsel
|
;; (use-package counsel
|
||||||
:diminish
|
;; :diminish
|
||||||
:config (counsel-mode))
|
;; :config (counsel-mode))
|
||||||
;; (use-package vertico
|
(use-package vertico
|
||||||
;; :custom (vertico-resize t)
|
:custom (vertico-resize t)
|
||||||
;; :config (vertico-mode))
|
:config (vertico-mode)
|
||||||
;; (use-package consult
|
(add-hook 'minibuffer-setup-hook 'turn-off-line-numbers))
|
||||||
;; :after vertico)
|
(use-package consult
|
||||||
|
:after vertico)
|
||||||
;; Minibuffer generic stuff
|
;; Minibuffer generic stuff
|
||||||
(use-package savehist
|
|
||||||
:straight (:type built-in)
|
|
||||||
:after ivy
|
|
||||||
:init (savehist-mode))
|
|
||||||
(use-package marginalia
|
(use-package marginalia
|
||||||
:after ivy
|
;; :after ivy
|
||||||
:custom (marginalia-separator " ")
|
:custom (marginalia-separator " ")
|
||||||
:init (marginalia-mode))
|
:init (marginalia-mode))
|
||||||
;; (use-package orderless
|
(use-package orderless
|
||||||
;; ;; :after vertico
|
;; :after vertico
|
||||||
;; ;; :config
|
;; :config
|
||||||
;; ;; (setq completion-category-defaults nil
|
;; (setq completion-category-defaults nil
|
||||||
;; ;; completion-category-overrides nil)
|
;; completion-category-overrides nil)
|
||||||
;; :commands 'execute-extended-command
|
;; :commands 'execute-extended-command
|
||||||
;; :custom
|
:custom
|
||||||
;; (completion-styles '(orderless partial-completion basic))
|
(completion-styles '(orderless partial-completion basic))
|
||||||
;; (completion-category-defaults nil)
|
(completion-category-defaults nil)
|
||||||
;; ;; (completion-category-overrides '((file (styles basic partial-completion))))
|
;; (completion-category-overrides '((file (styles basic partial-completion))))
|
||||||
;; (completion-category-overrides nil)
|
(completion-category-overrides nil)
|
||||||
;; )
|
)
|
||||||
|
|
||||||
|
;; BROKEN: Relative line numbers with stuff
|
||||||
(use-package linum-relative
|
(use-package linum-relative
|
||||||
:diminish
|
:diminish
|
||||||
|
:init
|
||||||
|
(require 'cl-lib)
|
||||||
|
(require 'linum-relative)
|
||||||
|
(setq linum-relative-current-symbol "")
|
||||||
|
(defvar total-lines (count-lines (point-min) (point-max)))
|
||||||
|
(defvar total-width 4)
|
||||||
|
;; (defun mitch/get-total-width ()
|
||||||
|
;; (+ 2 (round (log total-lines 10))))
|
||||||
|
(defun mitch/symbol-width (symbol)
|
||||||
|
(+ 1 (floor (log symbol 10))))
|
||||||
|
(defun mitch/linum-get-left-pad (symbol)
|
||||||
|
"Get the number of spaces to add before the current relative line number."
|
||||||
|
(let* ((symbol-width (mitch/symbol-width line-number)))
|
||||||
|
(- total-width symbol-width)))
|
||||||
|
(defun mitch/right-pad (line-number)
|
||||||
|
"Pad the line number to the right."
|
||||||
|
(let* (
|
||||||
|
(spacing (- total-width (mitch/symbol-width line-number)))
|
||||||
|
(spacer (make-string spacing (string-to-char " "))))
|
||||||
|
(format (concat "%s" spacer) line-number)))
|
||||||
|
(defun mitch/left-pad (line-number)
|
||||||
|
"Pad the line number to the left."
|
||||||
|
(let ((spacing
|
||||||
|
(make-string (mitch/linum-get-left-pad line-number)
|
||||||
|
(string-to-char " "))))
|
||||||
|
(format (concat spacing "%s") line-number)))
|
||||||
|
(defun linum-relative (line-number)
|
||||||
|
(let* ((diff1 (abs (- line-number linum-relative-last-pos)))
|
||||||
|
(diff (if (cl-minusp diff1)
|
||||||
|
diff1
|
||||||
|
(+ diff1 linum-relative-plusp-offset)))
|
||||||
|
(current-p (= diff linum-relative-plusp-offset))
|
||||||
|
(current-symbol (if (and linum-relative-current-symbol current-p)
|
||||||
|
(if (string= "" linum-relative-current-symbol)
|
||||||
|
(mitch/right-pad line-number)
|
||||||
|
linum-relative-current-symbol)
|
||||||
|
(mitch/left-pad diff)))
|
||||||
|
(face (if current-p 'linum-relative-current-face 'linum)))
|
||||||
|
(propertize (format linum-relative-format current-symbol) 'face face)))
|
||||||
|
(linum-relative-global-mode 1)
|
||||||
:custom
|
:custom
|
||||||
(linum-relative-current-symbol "")
|
(linum-relative-current-symbol "")
|
||||||
(linum-relative-backend 'display-line-numbers-mode)
|
)
|
||||||
:init
|
|
||||||
(linum-relative-global-mode 1))
|
|
||||||
|
|
||||||
;; 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
|
||||||
@ -486,15 +522,15 @@
|
|||||||
((t (:background "#afafaf" :extend t)))))
|
((t (:background "#afafaf" :extend t)))))
|
||||||
|
|
||||||
;; epic drop-down completion
|
;; epic drop-down completion
|
||||||
(use-package company
|
;; (use-package company
|
||||||
:diminish
|
;; :diminish
|
||||||
:custom ;(company-require-match nil)
|
;; :custom ;(company-require-match nil)
|
||||||
(company-tooltip-align-annotations t)
|
;; (company-tooltip-align-annotations t)
|
||||||
:hook (prog-mode . company-mode))
|
;; :hook (prog-mode . company-mode))
|
||||||
(use-package company-lsp
|
;; (use-package company-lsp
|
||||||
:after (lsp company)
|
;; :after (lsp company)
|
||||||
:config
|
;; :config
|
||||||
(push 'company-lsp company-backends))
|
;; (push 'company-lsp company-backends))
|
||||||
;; (use-package company-fuzzy
|
;; (use-package company-fuzzy
|
||||||
;; :diminish
|
;; :diminish
|
||||||
;; :hook (company-mode . company-fuzzy-mode)
|
;; :hook (company-mode . company-fuzzy-mode)
|
||||||
@ -505,46 +541,46 @@
|
|||||||
;; (company-fuzzy-history-backends '(company-yasnippet))
|
;; (company-fuzzy-history-backends '(company-yasnippet))
|
||||||
;; (company-fuzzy-trigger-symbols '("." "->" "<" "\"" "'" "@"))
|
;; (company-fuzzy-trigger-symbols '("." "->" "<" "\"" "'" "@"))
|
||||||
;; (company-fuzzy-passthrough-backends '(company-capf)))
|
;; (company-fuzzy-passthrough-backends '(company-capf)))
|
||||||
;; (use-package corfu
|
(use-package corfu
|
||||||
;; :custom
|
:custom
|
||||||
;; (completion-cycle-threshold 3)
|
(completion-cycle-threshold 3)
|
||||||
;; (tab-always-indent 'complete)
|
(tab-always-indent 'complete)
|
||||||
;; (corfu-auto t)
|
(corfu-auto t)
|
||||||
;; (corfu-quit-no-match t)
|
(corfu-quit-no-match t)
|
||||||
;; (corfu-count (- (window-total-height) 10))
|
(corfu-count (- (window-total-height) 10))
|
||||||
;; ;; (corfu-separator ";")
|
;; (corfu-separator ";")
|
||||||
;; :init (global-corfu-mode)
|
:init (global-corfu-mode)
|
||||||
;; ;; (defun corfu-enable-always-in-minibuffer ()
|
;; (defun corfu-enable-always-in-minibuffer ()
|
||||||
;; ;; "Enable Corfu in the minibuffer if Vertico/Mct are not active."
|
;; "Enable Corfu in the minibuffer if Vertico/Mct are not active."
|
||||||
;; ;; (unless (or (bound-and-true-p mct--active)
|
;; (unless (or (bound-and-true-p mct--active)
|
||||||
;; ;; (bound-and-true-p vertico--input))
|
;; (bound-and-true-p vertico--input))
|
||||||
;; ;; (setq-local corfu-auto nil) ;; Enable/disable auto completion
|
;; (setq-local corfu-auto nil) ;; Enable/disable auto completion
|
||||||
;; ;; (corfu-mode 1)
|
;; (corfu-mode 1)
|
||||||
;; ;; (minibuffer-complete)))
|
;; (minibuffer-complete)))
|
||||||
;; ;; (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
|
;; (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
|
||||||
;; ;; (defun corfu-kill-in-minibuffer ()
|
;; (defun corfu-kill-in-minibuffer ()
|
||||||
;; ;; "Kill corfu and minibuffer. To be bound to Esc."
|
;; "Kill corfu and minibuffer. To be bound to Esc."
|
||||||
;; ;; (interactive)
|
;; (interactive)
|
||||||
;; ;; (setq-local inhibit-debugger t)
|
;; (setq-local inhibit-debugger t)
|
||||||
;; ;; (corfu-quit)
|
;; (corfu-quit)
|
||||||
;; ;; (exit-minibuffer)
|
;; (exit-minibuffer)
|
||||||
;; ;; )
|
|
||||||
;; (defun corfu-send-shell (&rest _)
|
|
||||||
;; "Send completion candidate when inside comint/eshell."
|
|
||||||
;; (cond
|
|
||||||
;; ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
|
|
||||||
;; (eshell-send-input))
|
|
||||||
;; ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
|
|
||||||
;; (comint-send-input))))
|
|
||||||
;; :general
|
|
||||||
;; (general-define-key
|
|
||||||
;; :prefix-map 'corfu-map
|
|
||||||
;; "C-n" 'corfu-next
|
|
||||||
;; "C-p" 'corfu-previous
|
|
||||||
;; "RET" 'corfu-insert
|
|
||||||
;; "ESC" 'corfu-kill-in-minibuffer
|
|
||||||
;; )
|
|
||||||
;; )
|
;; )
|
||||||
|
(defun corfu-send-shell (&rest _)
|
||||||
|
"Send completion candidate when inside comint/eshell."
|
||||||
|
(cond
|
||||||
|
((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
|
||||||
|
(eshell-send-input))
|
||||||
|
((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
|
||||||
|
(comint-send-input))))
|
||||||
|
:general
|
||||||
|
(general-define-key
|
||||||
|
:prefix-map 'corfu-map
|
||||||
|
"C-n" 'corfu-next
|
||||||
|
"C-p" 'corfu-previous
|
||||||
|
"RET" 'corfu-insert
|
||||||
|
"ESC" 'corfu-kill-in-minibuffer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
(use-package popon
|
(use-package popon
|
||||||
:straight
|
:straight
|
||||||
|
Loading…
Reference in New Issue
Block a user