• Stars
    star
    1,263
  • Rank 36,959 (Top 0.8 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created over 11 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vim and Neovim plugin to reveal the commit messages under the cursor

git-messenger.vim

Build Status codecov

git-messenger.vim is a Vim/Neovim plugin to reveal the hidden message from Git under the cursor quickly. It shows the history of commits under the cursor in popup window.

This plugin shows the message of the last commit in a 'popup window'. If the last commit is not convenient, you can explore older commits in the popup window. Additionally you can also check diff of the commit.

The popup window is implemented in

  • Floating window on Neovim (0.4 or later)
  • Preview window on Vim (8 or later) or Neovim (0.3 or earlier)

The floating window is definitely recommended since it can shows the information near the cursor.

I wrote a Japanese blogpost for this plugin.

Why?

When you're modifying unfamiliar codes, you would sometimes wonder 'why was this line added?' or 'why this value was chosen?' in the source code. The answer sometimes lays in a commit message, especially in message of the last commit which modifies the line.

Screenshot

Show popup window with Neovim v0.4.0-dev

main screenshot

Exploring older commits

history screenshot

Exploring diff of the commit (you may be also interested in g:git_messenger_include_diff)

diff screenshot

Switching unified diffs and word diffs

word diff screenshot

Installation

Please ensure the following requirement before installing this plugin.

  • Git v1.8.5 or later (for -C option of git command)

If you use any package manager, please follow its instruction.

With vim-plug:

Plug 'rhysd/git-messenger.vim'

With dein.vim:

call dein#add('rhysd/git-messenger.vim', {
            \   'lazy' : 1,
            \   'on_cmd' : 'GitMessenger',
            \   'on_map' : '<Plug>(git-messenger)',
            \ })

With minpac:

call minpac#add('rhysd/git-messenger.vim')

if you use Vim's builtin packager, please follow the instruction at :help pack-add.

To enable a floating window support, you need to install Neovim 0.4 or later. Please follow the official instruction.

To check if Neovim's floating window feature is available, try :checkhealth.

Usage

Only one mapping (or one command) provides all features of this plugin. Briefly, move cursor to the position and run :GitMessenger or <Leader>gm. If you see an error message, please try health check.

Commands

:GitMessenger

Behavior of this command is depending on the situation. You can do every operations only with this mapping.

  • Normally, it opens a popup window with the last commit message
  • When a popup window is already open, it moves cursor into the window
  • When a cursor is within a popup window, it closes the window

It opens a popup window with the last commit message which modified the line at cursor. The popup window shows following contents:

  • History: History: {page number} In popup window, o/O navigates to previous/next commit.
  • Commit: Commit: {hash} The commit hash
  • Author: Author: {name}<{email}> Author name and mail address of the commit
  • Committer: Committer: {name}<{email}> Committer name and mail address of the commit when committer is different from author
  • Date: Date: {date} Author date of the commit in system format
    • When a committer date and an author date are different (e.g. the commit was created again with git commit --amend), both Author Date: and Committer Date: are shown.
  • Summary: First line after Date: header line is a summary of commit
  • Body: After summary, commit body is put (if the commit has body)

The popup window will be automatically closed when you move the cursor so you don't need to close it manually.

Running this command while a popup window is open, it moves the cursor into the window. This behavior is useful when the commit message is too long and window cannot show the whole content. By moving the cursor into the popup window, you can see the rest of contents by scrolling it. You can also see the older commits.

Following mappings are defined within popup window.

Mapping Description
q Close the popup window
o older. Back to older commit at the line
O Opposite to o. Forward to newer commit at the line
d Toggle unified diff hunks only in current file of the commit
D Toggle all unified diff hunks of the commit
r Toggle word diff hunks only in current file of the commit
R Toggle all word diff hunks of current commit
? Show mappings help

Mappings

<Plug>(git-messenger)

The same as running :GitMessenger command.

By default, this plugin defines following mapping.

nmap <Leader>gm <Plug>(git-messenger)

If you don't like the default mapping, set g:git_messenger_no_default_mappings to v:true in your .vimrc or init.vim and map the <Plug> mapping to your favorite key sequence.

For example:

nmap <C-w>m <Plug>(git-messenger)

Some other additional <Plug> mappings. Please read :help git-messenger.

Variables

Some global variables are available to configure the behavior of this plugin.

g:git_messenger_close_on_cursor_moved (Default: v:true)

When this value is set to v:false, a popup window is no longer closed automatically when moving a cursor after the window is shown up.

g:git_messenger_include_diff (Default: "none")

One of "none", "current", "all".

When this value is not set to "none", a popup window includes diff hunks of the commit at showing up. "current" includes diff hunks of only current file in the commit. "all" includes all diff hunks in the commit.

Please note that typing d/D or r/R in popup window toggle showing diff hunks even if this value is set to "none".

g:git_messenger_git_command (Default: "git")

git command to retrieve commit messages. If your git executable is not in $PATH directories, please specify the path to the executable.

g:git_messenger_no_default_mappings (Default: v:false)

When this value is set to v:true, it does not define any key mappings. <Plug> mappings are still defined since they don't make any conflicts with existing mappings.

g:git_messenger_into_popup_after_show (Default: v:true)

When this value is set to v:false, running :GitMessenger or <plug>(git-messenger) again after showing a popup does not move the cursor in the window.

g:git_messenger_always_into_popup (Default: v:false)

When this value is set to v:true, the cursor goes into a popup window when running :GitMessenger or <Plug>(git-messenger).

g:git_messenger_extra_blame_args (Default: "")

When this variable is set the contents will be appended to the git blame command. Use it to add options (like -w).

g:git_messenger_preview_mods (Default: "")

This variable is effective only when opening preview window (on Neovim (0.3.0 or earlier) or Vim).

Command modifiers for opening preview window. The value will be passed as prefix of :pedit command. For example, setting "botright" to the variable opens a preview window at bottom of the current window. Please see :help <mods> for more details.

g:git_messenger_max_popup_height (Default: v:null)

Max lines of popup window in an integer value. Setting v:null means no limit.

g:git_messenger_max_popup_width (Default: v:null)

Max characters of popup window in an integer value. Setting v:null means no limit.

g:git_messenger_date_format (Default: "%c")

String value to format dates in popup window. Please see :help strftime() to know the details of the format.

" Example: '2019 May 26 03:27:43'
let g:git_messenger_date_format = "%Y %b %d %X"

g:git_messenger_conceal_word_diff_marker (Default: v:true)

When this value is set to v:true, markers for word diffs like [-, -], {+, +} are concealed. Set v:false when you don't want to hide them.

Note: Word diff is enabled by typing "r" in a popup window.

g:git_messenger_floating_win_opts (Default {})

Options passed to nvim_open_win() on opening a popup window. This is useful when you want to override some window options.

The following example will add single border line to the window.

let g:git_messenger_floating_win_opts = { 'border': 'single' }

g:git_messenger_popup_content_margins (Default: v:true)

Setting v:true means adding margins in popup window. Blank lines at the top and bottom of popup content are inserted. And every line is indented with one whitespace character. Setting v:false to this variable removes all the margins.

Popup Window Highlight

This plugin uses color definitions from your colorscheme for highlighting stuffs in popup window by default. This is done by linking highlight groups in syntax/gitmessengerpopup.vim on gitmessengerpopup filetype. Highlights for diff are common with normal diff filetype syntax highlighting.

If the groups don't fit, please rearrange the highlight with :hi link. For example:

" Normal color in popup window with 'CursorLine'
hi link gitmessengerPopupNormal CursorLine

" Header such as 'Commit:', 'Author:' with 'Statement' highlight group
hi link gitmessengerHeader Statement

" Commit hash at 'Commit:' header with 'Special' highlight group
hi link gitmessengerHash Special

" History number at 'History:' header with 'Title' highlight group
hi link gitmessengerHistory Title

For another example, if you want to define colors directly, defining the colors with :hi works fine as follows.

hi gitmessengerPopupNormal term=None guifg=#eeeeee guibg=#333333 ctermfg=255 ctermbg=234
hi gitmessengerHeader term=None guifg=#88b8f6 ctermfg=111
hi gitmessengerHash term=None guifg=#f0eaaa ctermfg=229
hi gitmessengerHistory term=None guifg=#fd8489 ctermfg=210

Note: If your colorscheme does not allocate proper color for NormalFloat, you may need to set proper color to gitmessengerPopupNormal.

Note: gitmessengerPopupNormal is only available on Neovim since winhighlight option is used. On Vim, simply Normal highlight group is used for normal color.

Configuration for Popup Window

Filetype gitmessengerpopup is set in the popup window. Please hook FileType event to do some local setup within a popup window.

For example:

function! s:setup_git_messenger_popup() abort
    " Your favorite configuration here

    " For example, set go back/forward history to <C-o>/<C-i>
    nmap <buffer><C-o> o
    nmap <buffer><C-i> O
endfunction
autocmd FileType gitmessengerpopup call <SID>setup_git_messenger_popup()

Recent Neovim supports adding border lines to floating windows. git_messenger_floating_win_opts is available to set the options. And g:git_messenger_popup_content_margins can remove margins within popup content if you feel margins are unnecessary.

let g:git_messenger_floating_win_opts = { 'border': 'single' }
let g:git_messenger_popup_content_margins = v:false

popup with border

Health Check

This plugin supports a health checker on Neovim. When you see some error, please run :checkhealth to check your environment is ready for use of this plugin.

On Vim, please install vim-healthcheck and run :CheckHealth. It's a plugin to run :checkhealth on Vim.

Known Issues

  • On Windows, git command installed via MSYS does not work. Please use Git for Windows for now. This issue is tracked at #57.

License

Distributed under the MIT License

More Repositories

1

vim.wasm

Vim editor ported to WebAssembly
Vim Script
5,305
star
2

actionlint

:octocat: Static checker for GitHub Actions workflow files
Go
2,605
star
3

NyaoVim

Web-enhanced Extensible Neovim Frontend
TypeScript
2,207
star
4

vim-grammarous

A powerful grammar checker for Vim using LanguageTool.
Vim Script
1,058
star
5

vim-clang-format

Vim plugin for clang-format, a formatter for C, C++, Obj-C, Java, JavaScript, and so on.
Vim Script
1,036
star
6

clever-f.vim

Extended f, F, t and T key mappings for Vim.
Vim Script
968
star
7

Shiba

Rich markdown live preview app with linter
TypeScript
751
star
8

gocaml

🐫 Statically typed functional programming language implementation with Go and LLVM
Go
732
star
9

kiro-editor

A terminal UTF-8 text editor written in Rust πŸ“πŸ¦€
Rust
728
star
10

committia.vim

A Vim plugin for more pleasant editing on commit messages
Vim Script
687
star
11

go-github-selfupdate

Binary self-update mechanism for Go commands using GitHub
Go
527
star
12

conflict-marker.vim

Weapon to fight against conflicts in Vim.
Vim Script
442
star
13

wain

WebAssembly implementation from scratch in Safe Rust with zero dependencies
Rust
425
star
14

hgrep

Grep with human-friendly search results
Rust
419
star
15

electron-about-window

'About This App' mini-window for Electron apps
TypeScript
405
star
16

Mstdn

Tiny web-based mastodon client for your desktop
TypeScript
390
star
17

tui-textarea

Simple yet powerful multi-line text editor widget for ratatui and tui-rs
Rust
287
star
18

vim-color-spring-night

Low-contrast calm color scheme for Vim
Rust
276
star
19

cargo-husky

Setup Git hooks automatically for cargo projects with 🐢
Rust
260
star
20

dot-github

.github directory generator
Go
248
star
21

8cc.vim

C Compiler written in Vim script
Vim Script
227
star
22

vim-startuptime

A small Go program for better `vim --startuptime` alternative
Go
191
star
23

notes-cli

Small markdown note taking CLI app playing nicely with your favorite editor and other CLI tools
Go
191
star
24

dotfiles

dotfiles symbolic links management CLI
Go
191
star
25

neovim-component

<neovim-editor> WebComponent to embed Neovim to your app with great ease
TypeScript
188
star
26

reply.vim

REPLs play nicely with :terminal on Vim and Neovim
Vim Script
183
star
27

monolith-of-web

A chrome extension to make a single static HTML file of the web page using a WebAssembly port of monolith CLI
TypeScript
183
star
28

github-complete.vim

Vim input completion for GitHub
Vim Script
168
star
29

Trendy

Menubar app to keep you in the loop of GitHub trends :octocat:
TypeScript
166
star
30

git-brws

Command line tool to open repository, file, commit, diff, tag, pull request, blame, issue or project's website in browser for various repository hosting services.
Rust
166
star
31

devdocs.vim

Open devdocs.io from Vim
Vim Script
164
star
32

react-vimjs

Vim in Your Web App
JavaScript
158
star
33

vim-operator-surround

Vim operator mapping to enclose text objects with surrounds like paren, quote and so on.
Vim Script
137
star
34

react-vim-wasm

Vim editor embedded in your React web application
TypeScript
128
star
35

action-setup-vim

GitHub Action to setup Vim or Neovim on Linux, macOS and Windows for testing Vim plugins
TypeScript
126
star
36

accelerated-jk

A vim plugin to accelerate up-down moving!
Vim Script
125
star
37

dogfiles

dog + dotfiles = dogfiles
Vim Script
120
star
38

vim-gfm-syntax

GitHub Flavored Markdown syntax highlight extension for Vim
Vim Script
117
star
39

wandbox-vim

Wandbox plugin for vimmers. http://melpon.org/wandbox/
Vim Script
108
star
40

fixjson

JSON Fixer for Humans using (relaxed) JSON5
TypeScript
99
star
41

tinyjson

Simple JSON parser/generator for Rust
Rust
97
star
42

remark-emoji

Remark markdown transformer to replace :emoji: in text
JavaScript
93
star
43

YourFukurou

Hackable YoruFukurou alternative Twitter client
TypeScript
88
star
44

vim-lsp-ale

Bridge between vim-lsp and ALE
Vim Script
86
star
45

Dachs

Dachs; A Doggy 🐢 Programming Language
C++
81
star
46

vim-textobj-anyblock

A text object for any of '', "", (), {}, [] and <>.
Vim Script
79
star
47

vim-wasm

WebAssembly filetype support for Vim
Vim Script
77
star
48

world-map-gen

πŸ—ΊοΈRandom world map generator CLI and library for Rust and WebAssembly
Rust
74
star
49

vim-go-impl

A Vim plugin to use `impl` command
Vim Script
72
star
50

rust-doc.vim

Search Rust documents and open with browser from Vim.
Vim Script
71
star
51

ghci-color

colorize ghci output
PowerShell
71
star
52

electron-in-page-search

Module to introduce Electron's native in-page search avoiding pitfalls
TypeScript
66
star
53

translate-markdown

CLI tool to translate Markdown document with Google translate
JavaScript
66
star
54

tweet-app

Desktop Twitter client only for tweeting. Timeline never shows up.
TypeScript
65
star
55

dirname-filename-esm

__dirname and __filename for ES Modules environment
JavaScript
65
star
56

github-clone-all

Clone (~1000) repos matched to query on GitHub using Search API
Go
63
star
57

Tui

Twitter client based on mobile.twitter.com in menu bar
TypeScript
62
star
58

array_view

Wrapper for references to array in C++.
C++
58
star
59

vim-textobj-ruby

Make text objects with various ruby block structures.
Vim Script
56
star
60

fast-json-clone

Clone plain JSON value faster than the fastest
TypeScript
56
star
61

riscv32-cpu-chisel

Learning how to make RISC-V 32bit CPU with Chisel
Scala
55
star
62

changelog-from-release

Simple changelog generator via GitHub releases
Go
54
star
63

vim-llvm

Vim filetype support for LLVM (including official files)
Vim Script
49
star
64

Tilectron

Tiling window browser built on Electron.
JavaScript
45
star
65

nyaovim-markdown-preview

Live Markdown Preview on NyaoVim
HTML
45
star
66

Chromenu

Mobile Chrome in your menubar
TypeScript
43
star
67

Crisp

Lisp dialect implemented with Crystal
Crystal
43
star
68

path-slash

Tiny Rust library to convert a file path from/to slash path
Rust
41
star
69

open-pdf.vim

Convert pdf file to plain text, cache it and open it quickly in vim using pdftotext.
Vim Script
39
star
70

fixred

Fix outdated links in files with redirect URLs
Rust
35
star
71

ghpr-blame.vim

Vim plugin which is like `git-blame`, but for pull requests on GitHub
Vim Script
34
star
72

vim-healthcheck

Polyfill of Neovim's health-check for Vim
Vim Script
33
star
73

nyaovim-mini-browser

Embedded Mini Browser for NyaoVim
HTML
31
star
74

vim-color-splatoon

Vim Splatoon randomized color scheme. Let's play!
Vim Script
29
star
75

vim-fixjson

Vim plugin for fixjson; a JSON fixer for Humans
Vim Script
24
star
76

unite-redpen.vim

A unite.vim integration of redpen for automatic proof reading
Vim Script
24
star
77

vimwasm-try-plugin

Try Vim plugin on your browser without installing it using vim.wasm!
Go
24
star
78

react-component-octicons

Zero-dependency React component for Octicons
TypeScript
24
star
79

go-fakeio

Small Go library to fake stdout/stderr/stdin mainly for unit testing
Go
24
star
80

unite-codic.vim

A unite.vim source for codic-vim.
Vim Script
23
star
81

vim-goyacc

Vim filetype support for goyacc
Vim Script
22
star
82

gofmtrlx

(a bit) relaxed gofmt
Go
22
star
83

try-colorscheme.vim

Try colorscheme on your Vim without installation
Vim Script
21
star
84

node-github-trend

node.js library for scraping GitHub trending repositories.
TypeScript
20
star
85

node-github-emoji

Node.js library for GitHub Emoji :octocat: with TypeScript support
TypeScript
20
star
86

vim-syntax-christmas-tree

Vim filetype plugin for X'mas
Vim Script
20
star
87

toy-riscv-backend

Toy RISC-V LLVM backend
C++
18
star
88

FrozenString

C++ immutable string library in C++11 constexpr and type-level
C++
18
star
89

nyaovim-tree-view

Tree-view sidebar for NyaoVim
JavaScript
18
star
90

vim-github-actions

(Outdated) Vim syntax/indent support for GitHub Actions *.workflow files
Vim Script
18
star
91

zsh-bundle-exec

No longer need to type in 'bundle exec'.
Shell
17
star
92

locerr

❌ locerr (locational error): Library for nice-looking errors in source code
Go
16
star
93

rhysd

README.md for my profile page
Ruby
16
star
94

unite-ruby-require.vim

A unite.vim source for searching gems to require
Vim Script
15
star
95

vim-textobj-conflict

Vim text object plugin to select conflicts
Vim Script
15
star
96

electron-open-url

Open URL with Electron window from command line or Node.js program
JavaScript
15
star
97

vim-notes-cli

Vim plugin for notes-cli
Vim Script
15
star
98

marked-sanitizer-github

A sanitizer for marked.js which sanitizes HTML elements in markdown with the same manner as GitHub
TypeScript
14
star
99

api-dts

d.ts generator from JSON API response
Go
13
star
100

Irasutoyer

Desktop app for Irasutoya lovers
TypeScript
13
star