GithubHelp home page GithubHelp logo

luiznux / evil-magit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emacs-evil/evil-magit

0.0 0.0 0.0 219 KB

Black magic or evil keys for magit

Home Page: https://github.com/justbur/evil-magit

License: GNU General Public License v3.0

Emacs Lisp 98.98% Makefile 1.02%

evil-magit's Introduction

https://github.com/emacs-evil/evil-magit/workflows/evil-magit-test/badge.svg http://melpa.org/packages/evil-magit-badge.svg http://stable.melpa.org/packages/evil-magit-badge.svg

NOTE [2020-11-24]: This repository is no longer maintained. This package is now a part of evil-collection.

Black magic

This library configures Magit and Evil to play well with each other. For some background see Issue #1.

Note: I intend to track the latest commits to the master branch of the magit repo, meaning the keybindings here are potentially ahead of the last stable release of magit. Once the code in evil-magit stabilizes, I may switch to primarily tracking the stable release of magit and secondarily track the latest commits to master. Any help is welcomed.

Recent Changes (most recent first)

  1. [2019-09-04] Don’t use evil-next-visual-line and evil=previous-visual-line. See Issue #70.
  2. [2019-06-16] Added evil-magit-stage-untracked-file-with-intent at I. See Issue #67.
  3. [2019-02-15] Added forge-dispatch at @.
  4. [2018-05-22] Added evil-magit-use-z-for-folds. See docstring for more information.
  5. [2018-03-13] Added basic evil support for magit-list-repositories.
  6. [2016-07-27] Moved submodules popup to ’ and added the new subtree popup at “. This is not mnemonic in any way but easy to reach and keeps the two keys together.
  7. [2016-03-24] Moved magit-diff-less-context to = to fix conflict with moved revert.
  8. [2016-03-21] Moved revert commands from o and O to - and _. Rationale is that you are subtracting a commit. This makes room for o and O to be reset and the new reset popup command. Think of resetting to an “old” state. ¯\_(ツ)_/¯
  9. Added evil-magit-want-horizontal-movement. Use h and l for movement like vim, moving h to H, l to L, and L to C-l.
  10. Added evil-magit-toggle-text-mode on C-t. This is a quick way to enter text mode in a magit buffer, which allows arbitrary movement, copying, etc. Use C-t to return to the previous magit mode.
  11. When evil-magit-use-y-for-yank is non nil, C-w will prefix the evil window switching functions from magit buffers.
  12. evil-magit-use-y-for-yank is now the default. It has worked well for me so far, and I’ve had good feedback, but please let me know if you see issues. You can use the original behavior with (setq evil-magit-use-y-for-yank nil). See the table below for a summary of differences.

Installation and Use

Everything is contained in evil-magit.el, so you may download and load that file directly. The recommended method is to use MELPA via package.el (M-x package-install RET evil-magit RET).

Evil and Magit are both required. After requiring those packages, the following will setup the new key bindings for you.

;; optional: this is the evil state that evil-magit will use
;; (setq evil-magit-state 'normal)
;; optional: disable additional bindings for yanking text
;; (setq evil-magit-use-y-for-yank nil)
(require 'evil-magit)

Note on evil usage

This package assumes that you either use the global variant of evil mode (e.g., through (evil-mode 1)), or at least have evil-local-mode (the local variant) enabled in the magit buffers you want these bindings to take effect in. When evil is disabled in a magit buffer, this package will not affect the default key bindings (with one minor exception).

Note on evil-magit-use-y-for-yank

evil-magit-use-y-for-yank enables evil’s visual state for linewise selection, and as a consequnce y will yank text from the buffer.

With this enabled which it is by default evil-magit uses v and V to select by line. Selection in magit occurs linewise, so this choice is to avoid confusion that might arise if someone thought they could stage part of a line with v for example.

Text mode

Text mode can be toggled with evil-magit-toggle-text-mode (triggered with C-t or \). This takes nearly any magit buffer out of the related magit mode and puts it into text-mode. This allows free movement in the buffer using the standard evil movement and selection commands, making it easy to for example copy arbitrary text in the buffer. It also effectively prevents magit keys from shadowing evil ones, so f runs evil-find-char instead of magit-fetch-popup, allowing all vim related movement commands to be used in magit buffers. You can think of this if you like as another state for evil-magit to be in.

Several requests have been made to allow selecting and copying arbitrary text in the magit buffers, but there are many conflicts between evil bindings and magit bindings and there is no elegant solution to this problem in my opinion. Text mode is the best that I have come up with.

Key Bindings

The basic key binding scheme for evil-magit (EM) is described in the following tables. Blank columns indicate that the key is carried over from the left.

CategoryDefaultEM w/o yank optw/ yank opt (default)w/ horiz movew/ folds
cherry picka/A
branchb
bisectB
commitc
diffd/D
ediffe/E
fetchf
pullF
refreshggr/gR (g in popup)
helph/?H/?
ignorei/I
intent to stageI
jumpjg
deletekx
untrackKX
logl/LL/C-l
mergem
remoteM
next sectionnC-j
next section siblingM-ngj or ]
submoduleo
subtreeO
prev sectionpC-k
prev section siblingM-pgk or [
pushPP or p
quitqq or ESC
rebaser
renameR
stages/S
tagt
notesT
unstageu/U
revertv/V-/_
amw
patchW
resetx/Xo/O
show-refsyyr (y in popup)
cherryY
stashz/ZZ
git-cmd:¦
run!
forge@
diff less/more context-/+= / +
copy section infoC-wys
copy buffer infoM-wyb

New Commands

CommandEM w/o yank optEM w/ yank opt (default)w/ horiz move
evil-goto-lineG
evil-next-visual-linej
evil-previous-visual-linek
evil-backward-charunder M-xh
evil-forward-charunder M-xl
evil-search-nextn
evil-search-previousN
set-mark-commandv or VC-SPC
evil-visual-lineunder M-xv or V
evil-ex:
evil-search-forward/
evil-scroll-page-upC-b
evil-scroll-downC-d
evil-scroll-page-downC-f
evil-scroll-upC-u (if C-u scrolls)
evil-emacs-stateC-z
evil-yank-lineunder M-xyy
evil-window-mapunder M-xC-w
evil-magit-toggle-text-modeC-t/\

Any other bindings are meant to be consistent with these.

Use evil-magit-revert to revert changes made by evil-magit to the default evil+magit behavior.

To add other common evil commands

Some may want ? to search backward instead of launching the popup which is also bound to h. To get this behavior, add the following line after (require 'evil-magit) in your configuration.

(evil-define-key evil-magit-state magit-mode-map "?" 'evil-search-backward)

Most (but not all) magit bindings are in magit-mode-map, so other commands can be bound in this way too.

To remove commands

Typically, to prevent evil-magit from overriding the default behavior with evil and magit loaded, you should bind the respective key to nil after loading evil-magit. For example, to make escape behave as default

(evil-define-key* evil-magit-state magit-mode-map [escape] nil)

Known Conflicts

These are the third-party packages that conflict with these bindings and will probably need to be disabled in magit buffers for evil-magit to work properly.

  1. evil-snipe
  2. evil-escape with certain escape sequences

Disclaimer

Given the complexity of magit key bindings combined with the complexity of git itself, it is possible that there are some rough edges where the current binding is not the expected one in a buffer. It will be very helpful for you to report any such instances.

evil-magit's People

Contributors

bling avatar bmag avatar br3athein avatar danielrichtmann avatar duianto avatar edkolev avatar fuyu0425 avatar justbur avatar michaelstergianis avatar tarsius avatar yyadavalli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.