added support git

This commit is contained in:
Jesús 2019-01-08 17:08:58 -05:00
parent 5f494a38d3
commit 0cfbe1a462
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766
3 changed files with 99 additions and 1 deletions

View File

@ -11,7 +11,7 @@
'(ecb-options-version "2.50")
'(package-selected-packages
(quote
(company-php php-refactor-mode php-mode dokuwiki-mode web-mode rainbow-mode yaml-mode scss-mode sass-mode less-css-mode pkgbuild-mode pip-requirements jedi markdown-mode crystal-mode nginx-mode emmet-mode whitespace-cleanup-mode flycheck neotree all-the-icons highlight-indent-guides anzu sml-modeline smart-mode-line-powerline-theme smart-mode-line ecb diminish undo-tree nlinum sublime-themes use-package))))
(git-gutter-fringe git-timemachine gitattributes-mode gitignore-mode gitconfig-mode yaml-mode whitespace-cleanup-mode web-mode use-package undo-tree sublime-themes sml-modeline smart-mode-line-powerline-theme scss-mode sass-mode rainbow-mode pkgbuild-mode pip-requirements php-refactor-mode nlinum nginx-mode neotree markdown-mode less-css-mode jedi highlight-indent-guides flycheck emmet-mode ecb dokuwiki-mode diminish crystal-mode company-php anzu all-the-icons))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.

View File

@ -44,6 +44,7 @@
(require 'init-whitespace)
(require 'init-emmet-mode)
(require 'init-nginx)
(require 'init-git)
;;(require 'init-editorconfig)
;; Languages
(require 'init-ccc)

97
lisp/init-git.el Normal file
View File

@ -0,0 +1,97 @@
;;; init-git.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
(setq vc-follows-symlinks t
find-file-visit-truename t
vc-handled-backends nil)
(if (display-graphic-p)
(use-package git-gutter-fringe
:ensure t
:config
(global-git-gutter-mode t)
(setq-default fringes-outside-margins t)
(setq-default left-fringe-width 10)
(setq indicate-empty-lines nil)
(set-face-foreground 'git-gutter-fr:modified "purple")
(set-face-foreground 'git-gutter-fr:added "green")
(set-face-foreground 'git-gutter-fr:deleted "red")
(defun my-reshape-git-gutter (gutter)
"Re-shape gutter for `ivy-read'."
(let* ((linenum-start (aref gutter 3))
(linenum-end (aref gutter 4))
(target-line "")
(target-linenum 1)
(tmp-line "")
(max-line-length 0))
(save-excursion
(while (<= linenum-start linenum-end)
(goto-line linenum-start)
(setq tmp-line (replace-regexp-in-string "^[ \t]*" ""
(buffer-substring (line-beginning-position)
(line-end-position))))
(when (> (length tmp-line) max-line-length)
(setq target-linenum linenum-start)
(setq target-line tmp-line)
(setq max-line-length (length tmp-line)))
(setq linenum-start (1+ linenum-start))))
;; build (key . linenum-start)
(cons (format "%s %d: %s"
(if (eq 'deleted (aref gutter 1)) "-" "+")
target-linenum target-line)
target-linenum)))
(defun my-goto-git-gutter ()
(interactive)
(if git-gutter-fr:diffinfos
(ivy-read "git-gutters-fr:"
(mapcar 'my-reshape-git-gutter git-gutter-fr:diffinfos)
:action (lambda (e)
;; ivy9+ keep `(car e)'
;; ivy8- strip the `(car e)'
;; we handle both data structure
(unless (numberp e) (setq e (cdr e)))
(goto-line e)))
(message "NO git-gutters-fringe!")))))
(use-package gitconfig-mode
:ensure t
:mode ("/\\.?git/?config$"
"/\\.gitmodules$")
:init (add-hook 'gitconfig-mode-hook 'flyspell-mode))
(use-package gitignore-mode
:ensure t
:mode ("/\\.gitignore$"
"/\\.git/info/exclude$"
"/git/ignore$"))
(use-package gitattributes-mode
:ensure t
:defer t)
(use-package git-timemachine
:ensure t
:commands git-timemachine
:bind (:map git-timemachine-mode
("c" . git-timemachine-show-current-revision)
("b" . git-timemachine-switch-branch)))
;;; smerge-mode video explain https://emacsgifs.github.io/public/videos/758861381898637313.mp4
(use-package smerge-mode
:ensure t
:config
(defun enable-smerge-maybe ()
(when (and buffer-file-name (vc-backend buffer-file-name))
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil t)
(smerge-mode +1)))))
(add-hook 'buffer-list-update-hook #'enable-smerge-maybe))
(provide 'init-git)
;;; init-git.el ends here