refactor: Visual indentation guides

- Switch from highlight-indentation package to highlight-indent-guides.
- Activate visual indentation in a prog-mode hook, rather than doing
  within each individual major mode. It was already done within all
  major modes based on prog-mode anyway.
- Add new siren-display-indetation module and function as a central way
  to enable visual indetation guides. This makes switching the
  underlying package at some point in the future much easier.
This commit is contained in:
2020-01-26 18:53:44 +00:00
parent 702d2989dd
commit 8ed4a4e6f5
30 changed files with 54 additions and 65 deletions

View File

@@ -22,6 +22,7 @@
;; Editor
(require 'siren-browse-kill-ring)
(require 'siren-display-indentation)
(require 'siren-helm-command)
(require 'siren-ido)
(require 'siren-linum)

View File

@@ -0,0 +1,17 @@
;;; siren-display-indentation.el --- jimeh's Emacs Siren: indent guides setup
;;; Commentary:
;; Setup for rendering indent guides.
;;; Code:
(require 'siren-highlight-indent-guides)
(defun siren-display-indentation (&optional arg)
"Activate or deactivate indentation guides.
Optional ARG is passed directly to mode toggle function."
(highlight-indent-guides-mode (or arg t)))
(provide 'siren-display-indentation)
;;; siren-display-indentation.el ends here

View File

@@ -9,7 +9,19 @@
(use-package highlight-indent-guides
:defer t
:commands highlight-indent-guides-mode
:diminish highlight-indent-guides-mode)
:diminish highlight-indent-guides-mode
:hook
(prog-mode . highlight-indent-guides-mode)
:custom
(highlight-indent-guides-auto-even-face-perc 3)
(highlight-indent-guides-auto-odd-face-perc 2.5)
(highlight-indent-guides-auto-top-even-face-perc 12)
(highlight-indent-guides-auto-top-odd-face-perc 10)
(highlight-indent-guides-character ?\u2502)
(highlight-indent-guides-method 'column)
(highlight-indent-guides-responsive 'top))
(provide 'siren-highlight-indent-guides)
;;; siren-highlight-indent-guides.el ends here

View File

@@ -9,7 +9,10 @@
(use-package highlight-indentation
:defer t
:diminish (highlight-indentation-mode
highlight-indentation-current-column-mode))
highlight-indentation-current-column-mode)
:hook
(prog-mode . highlight-indent-guides-mode))
(provide 'siren-highlight-indentation)
;;; siren-highlight-indentation.el ends here

View File

@@ -28,7 +28,6 @@
(coffee-cos-mode t))
(setq tab-width 2)
(highlight-indentation-current-column-mode)
(subword-mode +1)))
(provide 'siren-coffee)

View File

@@ -6,12 +6,12 @@
;;; Code:
(require 'siren-display-indentation)
(require 'siren-fci)
(require 'siren-flyspell)
(require 'siren-linum)
(require 'siren-prog-mode)
(require 'siren-flycheck)
(require 'siren-highlight-indentation)
(require 'siren-highlight-symbol)
(require 'siren-smartparens)
@@ -24,11 +24,10 @@
(siren-prog-mode-setup)
(setq tab-width 2)
(siren-display-indentation)
(fci-mode)
(flycheck-mode)
(flyspell-prog-mode)
(highlight-indentation-current-column-mode)
(highlight-indentation-set-offset 2)
(highlight-symbol-mode)
(linum-mode)
(smartparens-mode)))

View File

@@ -23,7 +23,6 @@
(company-mode +1)
(lsp)
(highlight-indentation-current-column-mode +1)
(rainbow-mode +1)))
(provide 'siren-css)

View File

@@ -6,12 +6,12 @@
;;; Code:
(require 'siren-display-indentation)
(require 'siren-fci)
(require 'siren-flyspell)
(require 'siren-linum)
(require 'siren-prog-mode)
(require 'siren-flycheck)
(require 'siren-highlight-indentation)
(require 'siren-highlight-symbol)
(require 'siren-smartparens)
@@ -25,11 +25,10 @@
(siren-prog-mode-setup)
(setq tab-width 2)
(siren-display-indentation)
(fci-mode)
(flycheck-mode)
(flyspell-prog-mode)
(highlight-indentation-current-column-mode)
(highlight-indentation-set-offset 2)
(highlight-symbol-mode)
(linum-mode)
(smartparens-mode)))

View File

@@ -26,7 +26,6 @@
(defun siren-emacs-lisp-mode-setup ()
"Sensible defaults for `emacs-lisp-mode'."
(highlight-indent-guides-mode)
;; (run-hooks 'siren-lisp-coding-hook)
;; (eldoc-mode +1)
;; (siren-recompile-elc-on-save)

View File

@@ -35,11 +35,10 @@
(setq gofmt-command goimports)))
(setq tab-width 4)
(whitespace-toggle-options '(tabs))
(highlight-symbol-mode -1)
(company-mode +1)
(lsp)
(highlight-symbol-mode -1)
(hs-minor-mode 1)
(hideshowvis-enable)
(subword-mode +1))

View File

@@ -16,7 +16,6 @@
groovy-indent-offset 4
tab-width 4)
(highlight-indentation-current-column-mode)
(subword-mode +1)))
(provide 'siren-groovy)

View File

@@ -12,9 +12,7 @@
:init
(defun siren-haml-mode-setup ()
(setq tab-width 2)
(highlight-indentation-set-offset 2)
(highlight-indentation-current-column-mode +1)))
(setq tab-width 2)))
(provide 'siren-haml)
;;; siren-haml.el ends here

View File

@@ -31,7 +31,6 @@
(lsp)
(subword-mode +1)
(hs-minor-mode 1)
(highlight-indentation-current-column-mode)
(hideshowvis-enable)
(let ((map js-mode-map))

View File

@@ -25,10 +25,9 @@
"Default tweaks for `json-mode'."
(let ((width 2))
(setq js-indent-level width)
(setq json-reformat:indent-width width)
(setq tab-width width)
(highlight-indentation-set-offset width))
(setq js-indent-level width
json-reformat:indent-width width
tab-width width))
(setq flycheck-checker 'json-jsonlint)))

View File

@@ -19,7 +19,6 @@
(company-mode +1)
(subword-mode +1)
(hs-minor-mode +1)
(highlight-indentation-current-column-mode +1)
(hideshowvis-enable)))
(provide 'siren-jsx)

View File

@@ -6,8 +6,6 @@
;;; Code:
(require 'siren-highlight-indent-guides)
;; Lisp configuration
(define-key read-expression-map (kbd "TAB") 'completion-at-point)
@@ -22,7 +20,6 @@
;; interactive modes don't need whitespace checks
(defun siren-interactive-lisp-coding-hook ()
(highlight-indent-guides-mode)
(whitespace-mode -1))
(provide 'siren-lisp)

View File

@@ -15,7 +15,6 @@
(setq lua-indent-level 2
whitespace-action '(auto-cleanup))
(highlight-indentation-current-column-mode)
(subword-mode +1)))
(provide 'siren-lua)

View File

@@ -16,9 +16,7 @@
(defun siren-makefile-mode-setup ()
(subword-mode +1)
(setq tab-width 4)
(highlight-indentation-set-offset 4)
(highlight-indentation-current-column-mode)))
(setq tab-width 4)))
(provide 'siren-makefile)
;;; siren-makefile.el ends here

View File

@@ -7,7 +7,6 @@
;;; Code:
(require 'siren-folding)
(require 'siren-highlight-indentation)
(require 'siren-rainbow)
(use-package php-mode
@@ -21,7 +20,6 @@
(rainbow-mode +1)
(company-mode +1)
(subword-mode +1)
(highlight-indentation-current-column-mode)
(hs-minor-mode 1)
(hideshowvis-enable)))

View File

@@ -6,8 +6,6 @@
;;; Code:
(require 'siren-highlight-indentation)
(use-package plantuml-mode
:mode "\\.uml\\'"
:hook
@@ -16,10 +14,7 @@
:init
(defun siren-plantuml-mode-setup ()
(setq tab-width 2
plantuml-jar-path "/usr/local/opt/plantuml/libexec/plantuml.jar")
(highlight-indentation-set-offset 2)
(highlight-indentation-current-column-mode)))
plantuml-jar-path "/usr/local/opt/plantuml/libexec/plantuml.jar")))
(provide 'siren-plantuml)
;;; siren-plantuml.el ends here

View File

@@ -8,7 +8,6 @@
(require 'siren-company)
(require 'siren-folding)
(require 'siren-highlight-indentation)
(require 'siren-projectile)
(require 'siren-realgud)
(require 'siren-smartparens)
@@ -63,7 +62,6 @@
(company-mode +1)
(hs-minor-mode 1)
(hideshowvis-enable)
(highlight-indentation-current-column-mode)
(subword-mode +1))
:config

View File

@@ -7,7 +7,6 @@
;;; Code:
(require 'siren-folding)
(require 'siren-highlight-indentation)
(require 'siren-lsp)
(use-package rust-mode
@@ -28,7 +27,6 @@
(lsp-mode)
(hs-minor-mode 1)
(hideshowvis-enable)
(highlight-indentation-current-column-mode)
(subword-mode +1)))
(use-package cargo

View File

@@ -6,8 +6,6 @@
;;; Code:
(require 'siren-highlight-indentation)
(use-package sh-script
:ensure nil ;; loaded from emacs built-ins
:mode
@@ -25,8 +23,6 @@
whitespace-action '(auto-cleanup))
(subword-mode +1)
(highlight-indentation-set-offset 2)
(highlight-indentation-current-column-mode)
(define-key sh-mode-map (kbd "RET") 'newline-and-indent)))
(provide 'siren-sh)

View File

@@ -6,15 +6,12 @@
;;; Code:
(require 'siren-highlight-indentation)
(use-package slim-mode
:mode "\\.slim\\'"
:hook (slim-mode . siren-slim-mode-hook)
:init
(defun siren-slim-mode-setup ()
(highlight-indentation-current-column-mode)))
(defun siren-slim-mode-setup ()))
(provide 'siren-slim)
;;; siren-slim.el ends here

View File

@@ -17,8 +17,7 @@
(defun siren-sql-mode-setup ()
(setq tab-width 2)
(company-mode +1)
(highlight-indentation-current-column-mode +1)))
(company-mode +1)))
(use-package sqlformat
:hook

View File

@@ -11,7 +11,6 @@
(require 'siren-linum)
(require 'siren-prog-mode)
(require 'siren-flycheck)
(require 'siren-highlight-indentation)
(require 'siren-highlight-symbol)
(require 'siren-smartparens)
@@ -27,8 +26,6 @@
(fci-mode)
(flycheck-mode)
(flyspell-prog-mode)
(highlight-indentation-current-column-mode)
(highlight-indentation-set-offset 2)
(highlight-symbol-mode)
(linum-mode)
(smartparens-mode)

View File

@@ -9,7 +9,6 @@
(require 'siren-company)
(require 'siren-folding)
(require 'siren-flycheck)
(require 'siren-highlight-indentation)
(require 'siren-prettier-js)
(require 'siren-web-mode)
@@ -29,7 +28,6 @@
(lsp)
(subword-mode +1)
(hs-minor-mode 1)
(highlight-indentation-current-column-mode)
(hideshowvis-enable)
(let ((map typescript-mode-map))

View File

@@ -9,7 +9,6 @@
(require 'siren-company)
(require 'siren-fci)
(require 'siren-folding)
(require 'siren-highlight-indentation)
(use-package web-mode
:mode
@@ -40,8 +39,6 @@
(fci-mode -1)
(hideshowvis-enable)
(hs-minor-mode +1)
(highlight-indentation-current-column-mode)
(highlight-indentation-set-offset 2)
(subword-mode +1)))
(use-package web-beautify

View File

@@ -6,9 +6,9 @@
;;; Code:
(require 'siren-display-indentation)
(require 'siren-fci)
(require 'siren-flyspell)
(require 'siren-highlight-indentation)
(require 'siren-linum)
(require 'siren-prog-mode)
(require 'siren-smartparens)
@@ -27,10 +27,9 @@
(setq tab-width 2
whitespace-action '(auto-cleanup))
(siren-display-indentation)
(fci-mode)
(flyspell-mode)
(highlight-indentation-current-column-mode)
(highlight-indentation-set-offset 2)
(linum-mode t)
(smartparens-mode +1)
(subword-mode +1)))

View File

@@ -6,6 +6,7 @@
;;; Code:
(require 'siren-display-indentation)
(require 'siren-fci)
(require 'siren-flyspell)
(require 'siren-linum)
@@ -35,12 +36,13 @@
whitespace-action '(auto-cleanup))
(setcar (nthcdr 4 org-emphasis-regexp-components) 20)
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
(org-set-emph-re 'org-emphasis-regexp-components
org-emphasis-regexp-components)
(linum-mode t)
(flyspell-mode)
(fci-mode)
(highlight-indentation-current-column-mode)
(siren-display-indentation)
(smartparens-mode +1)
(visual-line-mode +1)
(whitespace-mode +1)))