;; init-highlight.el --- Initialize highlighting configurations. -*- lexical-binding: t -*- ;; Author: kj ;; URL: https://git.kj2.me/kj/confi-emacs-actual ;;; Commentary: ;; ;; Highlighting configurations. ;; ;;; Code: ;; Highlight the current line (use-package hl-line :ensure nil :hook (((dashboard-mode eshell-mode shell-mode term-mode vterm-mode) . (lambda () (setq-local global-hl-line-mode nil))) ;; (after-init . global-hl-line-mode) )) ;; Highlight matching parens (use-package paren :ensure nil :functions childframe-workable-p :custom-face (show-paren-match ((((class color) (background light)) (:box (:line-width (-1 . -1) :color "gray73"))) (((class color) (background dark)) (:box (:line-width (-1 . -1) :color "gray56"))))) :hook (after-init . show-paren-mode) :init (setq show-paren-when-point-inside-paren t show-paren-when-point-in-periphery t) :config (setq blink-matching-paren-highlight-offscreen t show-paren-context-when-offscreen (if (childframe-workable-p) 'child-frame 'overlay)) (with-no-warnings ;; Display matching line for off-screen paren. (defun display-line-overlay (pos str &optional face) "Display line at POS as STR with FACE. FACE defaults to inheriting from default and highlight." (let ((ol (save-excursion (goto-char pos) (make-overlay (line-beginning-position) (line-end-position))))) (overlay-put ol 'display str) (overlay-put ol 'face (or face '(:inherit highlight))) ol)) (defvar-local show-paren--off-screen-overlay nil) (defun show-paren-off-screen (&rest _args) "Display matching line for off-screen paren." (when (overlayp show-paren--off-screen-overlay) (delete-overlay show-paren--off-screen-overlay)) ;; Check if it's appropriate to show match info, (when (and (overlay-buffer show-paren--overlay) (not (or cursor-in-echo-area executing-kbd-macro noninteractive (minibufferp) this-command)) (and (not (bobp)) (memq (char-syntax (char-before)) '(?\) ?\$))) (= 1 (logand 1 (- (point) (save-excursion (forward-char -1) (skip-syntax-backward "/\\") (point)))))) ;; Rebind `minibuffer-message' called by `blink-matching-open' ;; to handle the overlay display. (cl-letf (((symbol-function #'minibuffer-message) (lambda (msg &rest args) (let ((msg (apply #'format-message msg args))) (setq show-paren--off-screen-overlay (display-line-overlay (window-start) msg )))))) (blink-matching-open)))) (advice-add #'show-paren-function :after #'show-paren-off-screen))) ;; Resalta los escapes de secuencia (use-package highlight-escape-sequences :hook (prog-mode . hes-mode) :config (setq hes-mode-alist `((c-mode . ,hes-c/c++/objc-escape-sequence-re) (c++-mode . ,hes-c/c++/objc-escape-sequence-re) (objc-mode . ,hes-c/c++/objc-escape-sequence-re) (go-mode . ,hes-c/c++/objc-escape-sequence-re) (php-mode . ,hes-c/c++/objc-escape-sequence-re) (php-ts-mode . ,hes-c/c++/objc-escape-sequence-re) (java-mode . ,hes-java-escape-sequence-re) (clojure-mode . ,hes-java-escape-sequence-re) (js-mode . ,hes-js-escape-sequence-re) (js2-mode . ,hes-js-escape-sequence-re) (ruby-mode . ,hes-ruby-escape-sequence-keywords) (lisp-mode . ,hes-elisp-escape-sequence-re) (lisp-interaction-mode . ,hes-elisp-escape-sequence-re) (emacs-lisp-mode . ,hes-elisp-escape-sequence-re)) ) ) ;; Resalta todas las ocurrencias del contenido seleccionado (use-package region-occurrences-highlighter :diminish :bind (:map region-occurrences-highlighter-nav-mode-map ("M-n" . region-occurrences-highlighter-next) ("M-p" . region-occurrences-highlighter-prev)) :hook (elpaca-after-init . global-region-occurrences-highlighter-mode)) ;; Highlight indentions (use-package indent-bars :custom (indent-bars-color '(highlight :face-bg t :blend 0.225)) (indent-bars-highlight-current-depth '(:face default :blend 0.225)) (indent-bars-color-by-depth nil) (indent-bars-pattern ".") (indent-bars-treesit-support t) (indent-bars-no-descend-string t) (indent-bars-treesit-ignore-blank-lines-types '("module")) (indent-bars-prefer-character t) (indent-bars-treesit-scope '((python function_definition class_definition for_statement if_statement with_statement while_statement))) ;; :hook ((prog-mode yaml-mode) . indent-bars-mode) :config (require 'indent-bars-ts)) ;; Colorize color names in buffers (use-package colorful-mode :diminish :hook (after-init . global-colorful-mode) :init (setq colorful-use-prefix t) :config (dolist (mode '(html-mode php-mode help-mode helpful-mode)) (add-to-list 'global-colorful-modes mode))) ;; Highlight brackets according to their depth (use-package rainbow-delimiters) ;; Resaltar palabras clave como TODO, FIXME, etc. en comentarios del código. (use-package hl-todo :autoload hl-todo-flymake hl-todo-search-and-highlight :functions rg rg-read-files rg-project :bind (:map hl-todo-mode-map ([C-f3] . hl-todo-occur)) :hook (elpaca-after-init . global-hl-todo-mode) :init (setq hl-todo-require-punctuation t hl-todo-highlight-punctuation ":") :config (add-to-list 'hl-todo-keyword-faces '("BUG" . "#d99600")) ;; Integrate into flymake (with-eval-after-load 'flymake (add-hook 'flymake-diagnostic-functions #'hl-todo-flymake)) ;; Integrate into magit (with-eval-after-load 'magit (add-hook 'magit-log-wash-summary-hook #'hl-todo-search-and-highlight t) (add-hook 'magit-revision-wash-message-hook #'hl-todo-search-and-highlight t)) ) (provide 'init-highlight) ;;; init-highlight.el ends here