Files
confi-emacs-actual/configs/init-vc.el
kj dabaf86f28 Big re-write :)
I reordered the code in a more clean an organized way. Also this improves a lot
the emacs startup time again, bucause after some updates it becomes a bit slow
with the old configuration, so i did it again in a new way.
2025-07-20 13:18:05 -03:00

144 lines
5.2 KiB
EmacsLisp

;;; init-vc.el --- Configuración del control de versiones -*- lexical-binding: t -*-
;; Author: kj <webmaster@outcontrol.net>
;; URL: https://git.kj2.me/kj/confi-emacs-actual
;;; Commentary:
;; Archivo de configuración específico para el control de versiones.
;;
;; Puedes que hoy en día la norma es usar git para este trabajo,
;; la gran mayoría de configuraciones son justamente para el mismo.
;;; Code:
;; Resolver diferencias entre 2 archivos o versiones del mismo.
(use-package ediff
:ensure nil
:config
(setq ediff-diff-options "")
(setq ediff-custom-diff-options "-u")
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-vertically))
;; Marca a la izq. si una linea ha sido agregada, editada o eliminada desde el último commit.
(use-package diff-hl
:custom (diff-hl-draw-borders nil)
:autoload diff-hl-flydiff-mode
:custom-face
(diff-hl-change ((t (:inherit custom-changed :foreground unspecified :background unspecified))))
(diff-hl-insert ((t (:inherit diff-added :background unspecified))))
(diff-hl-delete ((t (:inherit diff-removed :background unspecified))))
:bind (:map diff-hl-command-map
("SPC" . diff-hl-mark-hunk))
:hook ((elpaca-after-init . global-diff-hl-mode)
(elpaca-after-init . global-diff-hl-show-hunk-mouse-mode)
(dired-mode . diff-hl-dired-mode))
:config
;; Highlight on-the-fly
(diff-hl-flydiff-mode 1)
;; Set fringe style
(setq-default fringes-outside-margins t)
(with-no-warnings
(unless (display-graphic-p)
;; Fall back to the display margin since the fringe is unavailable in tty
(diff-hl-margin-mode 1)
;; Avoid restoring `diff-hl-margin-mode'
(with-eval-after-load 'desktop
(add-to-list 'desktop-minor-mode-table
'(diff-hl-margin-mode nil))))
;; Integration with magit
(with-eval-after-load 'magit
(add-hook 'magit-pre-refresh-hook #'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook #'diff-hl-magit-post-refresh))))
;; Visitar rápidamente viejas versiones de un archivo rápidamente
(use-package git-timemachine
:custom-face
(git-timemachine-minibuffer-author-face ((t (:inherit success :foreground unspecified))))
(git-timemachine-minibuffer-detail-face ((t (:inherit warning :foreground unspecified))))
:bind (:map vc-prefix-map
("t" . git-timemachine))
:hook ((git-timemachine-mode . (lambda ()
"Improve `git-timemachine' buffers."
;; Display different colors in mode-line
(if (facep 'mode-line-active)
(face-remap-add-relative 'mode-line-active 'custom-state)
(face-remap-add-relative 'mode-line 'custom-state))
;; Highlight symbols in elisp
(and (derived-mode-p 'emacs-lisp-mode)
(fboundp 'highlight-defined-mode)
(highlight-defined-mode t))
;; Display line numbers
(and (derived-mode-p 'prog-mode 'yaml-mode)
(fboundp 'display-line-numbers-mode)
(display-line-numbers-mode t))))
(before-revert . (lambda ()
(when (bound-and-true-p git-timemachine-mode)
(user-error "Cannot revert the timemachine buffer"))))))
;; Generador automatizado de archivos de licencia
(use-package license-templates)
;; Magia para git
(use-package magit)
;; Todolist en magit de todos los archivos del projecto.
(use-package magit-todos
:after magit-status
:commands magit-todos-mode
:init
(setq magit-todos-nice (if (executable-find "nice") t nil))
(magit-todos-mode 1))
;; Modo para resolución de confictos
(use-package smerge-mode
:ensure nil
:config
(defhydra hydra-smerge (:color pink
:hint nil)
"
^Move^ ^Keep^ ^Diff^ ^Other^
^^-----------^^-------------------^^---------------------^^-------
_n_ext _b_ase _<_: upper/base _C_ombine
_p_rev _u_pper _=_: upper/lower _r_esolve
^^ _l_ower _>_: base/lower _k_ill current
^^ _a_ll _R_efine
^^ _RET_: current _E_diff
"
("n" smerge-next)
("p" smerge-prev)
("b" smerge-keep-base)
("u" smerge-keep-upper)
("l" smerge-keep-lower)
("a" smerge-keep-all)
("RET" smerge-keep-current)
("\C-m" smerge-keep-current)
("<" smerge-diff-base-upper)
("=" smerge-diff-upper-lower)
(">" smerge-diff-base-lower)
("R" smerge-refine)
("E" smerge-ediff)
("C" smerge-combine-with-next)
("r" smerge-resolve)
("k" smerge-kill-current)
("q" nil "cancel" :color blue))
)
(use-package transient)
;; Mostrar el último commit que modificó la linea actual
(use-package vc-msg
:bind (("C-c C-v" . vc-msg-show))
)
(provide 'init-vc)
;;; init-vc.el ends here