mirror of https://github.com/amix/vimrc.git
commit
1756011e51
@ -1 +0,0 @@ |
||||
Subproject commit 705e68d90d6596c621093a28bf480a572a41ad02 |
@ -0,0 +1,117 @@ |
||||
# Change Log |
||||
|
||||
## [Unreleased](https://github.com/morhetz/gruvbox/tree/HEAD) |
||||
|
||||
[Full Changelog](https://github.com/morhetz/gruvbox/compare/v1.3.5...HEAD) |
||||
|
||||
**Fixed bugs:** |
||||
|
||||
- Lighter background on terminal [\#8](https://github.com/morhetz/gruvbox/issues/8) |
||||
|
||||
**Closed issues:** |
||||
|
||||
- Installation issue. [\#54](https://github.com/morhetz/gruvbox/issues/54) |
||||
|
||||
- Italic font in terminal\(urxvt\) [\#49](https://github.com/morhetz/gruvbox/issues/49) |
||||
|
||||
- Unable to log in when sourcing the palette shellscript [\#48](https://github.com/morhetz/gruvbox/issues/48) |
||||
|
||||
- How can i modify multiple comment scheme [\#46](https://github.com/morhetz/gruvbox/issues/46) |
||||
|
||||
- Remove comment highlight in iterm [\#44](https://github.com/morhetz/gruvbox/issues/44) |
||||
|
||||
- Comments looking strange withing tmux [\#43](https://github.com/morhetz/gruvbox/issues/43) |
||||
|
||||
- comments are reverse-video in xterm [\#41](https://github.com/morhetz/gruvbox/issues/41) |
||||
|
||||
- What font are you using in the screenshots? [\#39](https://github.com/morhetz/gruvbox/issues/39) |
||||
|
||||
- vim-signature crashes when I use gruvbox [\#38](https://github.com/morhetz/gruvbox/issues/38) |
||||
|
||||
- Color of statusbar in inactive windows [\#37](https://github.com/morhetz/gruvbox/issues/37) |
||||
|
||||
- Go method and struct highlighting missing [\#36](https://github.com/morhetz/gruvbox/issues/36) |
||||
|
||||
- gruvbox\_256palette.sh doesn't work for Konsole [\#35](https://github.com/morhetz/gruvbox/issues/35) |
||||
|
||||
- Contrast in jekyll markdown files [\#33](https://github.com/morhetz/gruvbox/issues/33) |
||||
|
||||
- Pentadactyl Gruvbox Theme [\#32](https://github.com/morhetz/gruvbox/issues/32) |
||||
|
||||
- make vertsplit better [\#31](https://github.com/morhetz/gruvbox/issues/31) |
||||
|
||||
- Console support. [\#30](https://github.com/morhetz/gruvbox/issues/30) |
||||
|
||||
- How can I change the background color? [\#29](https://github.com/morhetz/gruvbox/issues/29) |
||||
|
||||
- Some words are not bold [\#28](https://github.com/morhetz/gruvbox/issues/28) |
||||
|
||||
- Terminal theme on base gruvbox [\#25](https://github.com/morhetz/gruvbox/issues/25) |
||||
|
||||
- Markdown has inverted colors when using \* [\#24](https://github.com/morhetz/gruvbox/issues/24) |
||||
|
||||
- how install it on mac osx [\#23](https://github.com/morhetz/gruvbox/issues/23) |
||||
|
||||
- Comments color for Terminal Vim [\#22](https://github.com/morhetz/gruvbox/issues/22) |
||||
|
||||
- Move palette files to gruvbox-generalized [\#20](https://github.com/morhetz/gruvbox/issues/20) |
||||
|
||||
- Maybe add Gruvbox Airline theme? [\#19](https://github.com/morhetz/gruvbox/issues/19) |
||||
|
||||
- For Sublime text [\#18](https://github.com/morhetz/gruvbox/issues/18) |
||||
|
||||
**Merged pull requests:** |
||||
|
||||
- Fix the 256 palette script failed login issue [\#53](https://github.com/morhetz/gruvbox/pull/53) ([jonasmalacofilho](https://github.com/jonasmalacofilho)) |
||||
|
||||
- add minimal coloring for gitcommit highlighting [\#52](https://github.com/morhetz/gruvbox/pull/52) ([daniely](https://github.com/daniely)) |
||||
|
||||
- For terminals, turn off italics by default. [\#47](https://github.com/morhetz/gruvbox/pull/47) ([ryanmjacobs](https://github.com/ryanmjacobs)) |
||||
|
||||
- Change color of vertical/horizontal seperators between split windows [\#45](https://github.com/morhetz/gruvbox/pull/45) ([deshtop](https://github.com/deshtop)) |
||||
|
||||
- Improve gruvbox with C code [\#34](https://github.com/morhetz/gruvbox/pull/34) ([gladiac](https://github.com/gladiac)) |
||||
|
||||
- Fix for linux console [\#27](https://github.com/morhetz/gruvbox/pull/27) ([vyp](https://github.com/vyp)) |
||||
|
||||
- Colors for plugin vimshell.vim [\#21](https://github.com/morhetz/gruvbox/pull/21) ([joelmo](https://github.com/joelmo)) |
||||
|
||||
## [v1.3.5](https://github.com/morhetz/gruvbox/tree/v1.3.5) (2014-03-19) |
||||
|
||||
[Full Changelog](https://github.com/morhetz/gruvbox/compare/v0.0.8...v1.3.5) |
||||
|
||||
**Implemented enhancements:** |
||||
|
||||
- Better selection colors [\#15](https://github.com/morhetz/gruvbox/issues/15) |
||||
|
||||
- When hlsearch is on, the cursor inverts the search color and not visible [\#2](https://github.com/morhetz/gruvbox/issues/2) |
||||
|
||||
**Fixed bugs:** |
||||
|
||||
- Problem with changing between dark and light on 256 color terminal [\#7](https://github.com/morhetz/gruvbox/issues/7) |
||||
|
||||
- IndentGuides coloring doesn't show up [\#1](https://github.com/morhetz/gruvbox/issues/1) |
||||
|
||||
**Closed issues:** |
||||
|
||||
- Requesting rxvt-unicode theme [\#17](https://github.com/morhetz/gruvbox/issues/17) |
||||
|
||||
- gruvbox\_256palette.sh gets reset \(gnome-terminal on Ubuntu\) [\#13](https://github.com/morhetz/gruvbox/issues/13) |
||||
|
||||
- Powerline colors [\#12](https://github.com/morhetz/gruvbox/issues/12) |
||||
|
||||
- Info necessary for making a port of this colorscheme [\#10](https://github.com/morhetz/gruvbox/issues/10) |
||||
|
||||
**Merged pull requests:** |
||||
|
||||
- Fix GNU screen detection for \*-bce [\#16](https://github.com/morhetz/gruvbox/pull/16) ([blueyed](https://github.com/blueyed)) |
||||
|
||||
- Added iTerm2 dark theme [\#11](https://github.com/morhetz/gruvbox/pull/11) ([Greduan](https://github.com/Greduan)) |
||||
|
||||
- Fix typo in Readme [\#5](https://github.com/morhetz/gruvbox/pull/5) ([ViViDboarder](https://github.com/ViViDboarder)) |
||||
|
||||
## [v0.0.8](https://github.com/morhetz/gruvbox/tree/v0.0.8) (2012-12-08) |
||||
|
||||
|
||||
|
||||
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* |
@ -0,0 +1,110 @@ |
||||
<p align="center"><img src="http://imgh.us/gruvbox_logo.svg"></p> |
||||
|
||||
gruvbox is heavily inspired by [badwolf][], [jellybeans][] and [solarized][]. |
||||
|
||||
Designed as a bright theme with pastel 'retro groove' colors and light/dark mode switching in the way of [solarized][]. The main focus when developing gruvbox is to keep colors easily distinguishable, contrast enough and still pleasant for the eyes. |
||||
|
||||
[badwolf]: https://github.com/sjl/badwolf |
||||
[jellybeans]: https://github.com/nanotech/jellybeans.vim |
||||
[solarized]: http://ethanschoonover.com/solarized |
||||
|
||||
Attention |
||||
--------- |
||||
|
||||
1. [Read this first](https://github.com/morhetz/gruvbox/wiki/Terminal-specific) |
||||
2. Typeface from gallery is [Fantasque Sans Mono](https://github.com/belluzj/fantasque-sans) |
||||
3. Typeface from screenshots below is [Fira Mono](http://www.carrois.com/fira-4-1/) |
||||
|
||||
Screenshots |
||||
----------- |
||||
|
||||
Refer [Gallery][] for more syntax-specific screenshots. |
||||
|
||||
[Gallery]: https://github.com/morhetz/gruvbox/wiki/Gallery |
||||
|
||||
### Dark mode |
||||
|
||||
 |
||||
|
||||
### Light mode |
||||
|
||||
 |
||||
|
||||
### Airline theme |
||||
|
||||
 |
||||
|
||||
Palette |
||||
------- |
||||
|
||||
### Dark mode |
||||
|
||||
 |
||||
|
||||
### Light mode |
||||
|
||||
 |
||||
|
||||
Contrast options |
||||
---------------- |
||||
|
||||
Refer [wiki section][] for contrast configuration and other options. |
||||
|
||||
[wiki section]: https://github.com/morhetz/gruvbox/wiki/Configuration#ggruvbox_contrast_dark |
||||
|
||||
 |
||||
|
||||
Documentation |
||||
------------- |
||||
|
||||
Please check [wiki][] for installation details, terminal-specific setup, troubleshooting, configuration options and others. |
||||
|
||||
[wiki]: https://github.com/morhetz/gruvbox/wiki |
||||
|
||||
Features |
||||
-------- |
||||
|
||||
* Lots of style-customization options (contrast, color invertion, italics usage etc.) |
||||
* Extended filetype highlighting: Html, Xml, Vim (and ES6 with [yajs.vim](https://github.com/othree/yajs.vim)), Clojure, C, Python, JavaScript, CoffeeScript, Ruby, Objective-C, Go, Lua, MoonScript, Java, Markdown, Haskell |
||||
* Supported plugins: [EasyMotion][], [vim-sneak][], [Indent Guides][], [indentLine][], [Rainbow Parentheses][], [Airline][], [Lightline][], [GitGutter][], [Signify][], [ShowMarks][], [Signature][], [Syntastic][], [CtrlP][], [Startify][] |
||||
|
||||
[EasyMotion]: https://github.com/Lokaltog/vim-easymotion |
||||
[vim-sneak]: https://github.com/justinmk/vim-sneak |
||||
[Indent Guides]: https://github.com/nathanaelkane/vim-indent-guides |
||||
[indentLine]: https://github.com/Yggdroot/indentLine |
||||
[Rainbow Parentheses]: https://github.com/kien/rainbow_parentheses.vim |
||||
[Airline]: https://github.com/bling/vim-airline |
||||
[Lightline]: https://github.com/itchyny/lightline.vim |
||||
[GitGutter]: https://github.com/airblade/vim-gitgutter |
||||
[Signify]: https://github.com/mhinz/vim-signify |
||||
[ShowMarks]: http://www.vim.org/scripts/script.php?script_id=152 |
||||
[Signature]: https://github.com/kshenoy/vim-signature |
||||
[Syntastic]: https://github.com/scrooloose/syntastic |
||||
[CtrlP]: https://github.com/kien/ctrlp.vim |
||||
[Startify]: https://github.com/mhinz/vim-startify |
||||
|
||||
Contributions |
||||
------------- |
||||
|
||||
See [gruvbox-contrib][] repo for contributions, ports and extras. |
||||
|
||||
[gruvbox-contrib]: https://github.com/morhetz/gruvbox-contrib |
||||
|
||||
ToDo |
||||
---- |
||||
|
||||
* Filetype syntax highlighting (R, TeX, Swift, Erlang, Purescript and I'm still dissatisfied with CSS) |
||||
* Plugin support (MiniBufExplorer, Tagbar, Netrw, VimPLug) |
||||
|
||||
Self-Promotion |
||||
-------------- |
||||
|
||||
If you like gruvbox follow the repository on |
||||
[GitHub](https://github.com/morhetz/gruvbox) and vote for it on |
||||
[vim.org](http://www.vim.org/scripts/script.php?script_id=4349). |
||||
|
||||
License |
||||
------- |
||||
[MIT/X11][] |
||||
|
||||
[MIT/X11]: https://en.wikipedia.org/wiki/MIT_License |
@ -0,0 +1,79 @@ |
||||
" ----------------------------------------------------------------------------- |
||||
" File: gruvbox.vim |
||||
" Description: Retro groove color scheme for Airline |
||||
" Author: morhetz <morhetz@gmail.com> |
||||
" Source: https://github.com/morhetz/gruvbox |
||||
" Last Modified: 22 Aug 2014 |
||||
" ----------------------------------------------------------------------------- |
||||
|
||||
let g:airline#themes#gruvbox#palette = {} |
||||
|
||||
function! airline#themes#gruvbox#refresh() |
||||
|
||||
let M0 = airline#themes#get_highlight('Identifier') |
||||
let accents_group = airline#themes#get_highlight('Special') |
||||
let modified_group = [M0[0], '', M0[2], '', ''] |
||||
let warning_group = airline#themes#get_highlight2(['Normal', 'bg'], ['Question', 'fg']) |
||||
let error_group = airline#themes#get_highlight2(['Normal', 'bg'], ['WarningMsg', 'fg']) |
||||
|
||||
let s:N1 = airline#themes#get_highlight2(['Normal', 'bg'], ['StatusLineNC', 'bg']) |
||||
let s:N2 = airline#themes#get_highlight2(['StatusLineNC', 'bg'], ['StatusLineNC', 'fg']) |
||||
let s:N3 = airline#themes#get_highlight2(['StatusLineNC', 'bg'], ['CursorLine', 'bg']) |
||||
let g:airline#themes#gruvbox#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) |
||||
let g:airline#themes#gruvbox#palette.normal_modified = { 'airline_c': modified_group } |
||||
let g:airline#themes#gruvbox#palette.normal.airline_warning = warning_group |
||||
let g:airline#themes#gruvbox#palette.normal_modified.airline_warning = warning_group |
||||
let g:airline#themes#gruvbox#palette.normal.airline_error = error_group |
||||
let g:airline#themes#gruvbox#palette.normal_modified.airline_error = error_group |
||||
|
||||
let s:I1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Identifier', 'fg']) |
||||
let s:I2 = s:N2 |
||||
let s:I3 = airline#themes#get_highlight2(['Normal', 'fg'], ['StatusLineNC', 'fg']) |
||||
let g:airline#themes#gruvbox#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) |
||||
let g:airline#themes#gruvbox#palette.insert_modified = g:airline#themes#gruvbox#palette.normal_modified |
||||
let g:airline#themes#gruvbox#palette.insert.airline_warning = g:airline#themes#gruvbox#palette.normal.airline_warning |
||||
let g:airline#themes#gruvbox#palette.insert_modified.airline_warning = g:airline#themes#gruvbox#palette.normal_modified.airline_warning |
||||
let g:airline#themes#gruvbox#palette.insert.airline_error = g:airline#themes#gruvbox#palette.normal.airline_error |
||||
let g:airline#themes#gruvbox#palette.insert_modified.airline_error = g:airline#themes#gruvbox#palette.normal_modified.airline_error |
||||
|
||||
let s:R1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Structure', 'fg']) |
||||
let s:R2 = s:I2 |
||||
let s:R3 = s:I3 |
||||
let g:airline#themes#gruvbox#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) |
||||
let g:airline#themes#gruvbox#palette.replace_modified = g:airline#themes#gruvbox#palette.normal_modified |
||||
let g:airline#themes#gruvbox#palette.replace.airline_warning = g:airline#themes#gruvbox#palette.normal.airline_warning |
||||
let g:airline#themes#gruvbox#palette.replace_modified.airline_warning = g:airline#themes#gruvbox#palette.normal_modified.airline_warning |
||||
let g:airline#themes#gruvbox#palette.replace.airline_error = g:airline#themes#gruvbox#palette.normal.airline_error |
||||
let g:airline#themes#gruvbox#palette.replace_modified.airline_error = g:airline#themes#gruvbox#palette.normal_modified.airline_error |
||||
|
||||
let s:V1 = airline#themes#get_highlight2(['Normal', 'bg'], ['ModeMsg', 'fg']) |
||||
let s:V2 = s:N2 |
||||
let s:V3 = airline#themes#get_highlight2(['Normal', 'bg'], ['TabLine', 'fg']) |
||||
let g:airline#themes#gruvbox#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) |
||||
let g:airline#themes#gruvbox#palette.visual_modified = { 'airline_c': [ s:V3[0], '', s:V3[2], '', '' ] } |
||||
let g:airline#themes#gruvbox#palette.visual.airline_warning = g:airline#themes#gruvbox#palette.normal.airline_warning |
||||
let g:airline#themes#gruvbox#palette.visual_modified.airline_warning = g:airline#themes#gruvbox#palette.normal_modified.airline_warning |
||||
let g:airline#themes#gruvbox#palette.visual.airline_error = g:airline#themes#gruvbox#palette.normal.airline_error |
||||
let g:airline#themes#gruvbox#palette.visual_modified.airline_error = g:airline#themes#gruvbox#palette.normal_modified.airline_error |
||||
|
||||
let s:IA = airline#themes#get_highlight2(['TabLine', 'fg'], ['CursorLine', 'bg']) |
||||
let g:airline#themes#gruvbox#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) |
||||
let g:airline#themes#gruvbox#palette.inactive_modified = { 'airline_c': modified_group } |
||||
|
||||
let g:airline#themes#gruvbox#palette.accents = { 'red': accents_group } |
||||
|
||||
let s:TF = airline#themes#get_highlight2(['Normal', 'bg'], ['Normal', 'bg']) |
||||
let g:airline#themes#gruvbox#palette.tabline = { |
||||
\ 'airline_tab': s:N2, |
||||
\ 'airline_tabsel': s:N1, |
||||
\ 'airline_tabtype': s:V1, |
||||
\ 'airline_tabfill': s:TF, |
||||
\ 'airline_tabhid': s:IA, |
||||
\ 'airline_tabmod': s:I1 |
||||
\ } |
||||
|
||||
endfunction |
||||
|
||||
call airline#themes#gruvbox#refresh() |
||||
|
||||
" vim: set sw=2 ts=2 sts=2 et tw=80 ft=vim fdm=marker: |
@ -0,0 +1,41 @@ |
||||
" ----------------------------------------------------------------------------- |
||||
" File: gruvbox.vim |
||||
" Description: Retro groove color scheme for Vim |
||||
" Author: morhetz <morhetz@gmail.com> |
||||
" Source: https://github.com/morhetz/gruvbox |
||||
" Last Modified: 09 Apr 2014 |
||||
" ----------------------------------------------------------------------------- |
||||
|
||||
function! gruvbox#invert_signs_toggle() |
||||
if g:gruvbox_invert_signs == 0 |
||||
let g:gruvbox_invert_signs=1 |
||||
else |
||||
let g:gruvbox_invert_signs=0 |
||||
endif |
||||
|
||||
colorscheme gruvbox |
||||
endfunction |
||||
|
||||
" Search Highlighting {{{ |
||||
|
||||
function! gruvbox#hls_show() |
||||
set hlsearch |
||||
call GruvboxHlsShowCursor() |
||||
endfunction |
||||
|
||||
function! gruvbox#hls_hide() |
||||
set nohlsearch |
||||
call GruvboxHlsHideCursor() |
||||
endfunction |
||||
|
||||
function! gruvbox#hls_toggle() |
||||
if &hlsearch |
||||
call gruvbox#hls_hide() |
||||
else |
||||
call gruvbox#hls_show() |
||||
endif |
||||
endfunction |
||||
|
||||
" }}} |
||||
|
||||
" vim: set sw=2 ts=2 sts=2 et tw=80 ft=vim fdm=marker: |
@ -0,0 +1,53 @@ |
||||
" ----------------------------------------------------------------------------- |
||||
" File: gruvbox.vim |
||||
" Description: Gruvbox colorscheme for Lightline (itchyny/lightline.vim) |
||||
" Author: gmoe <me@griffinmoe.com> |
||||
" Source: https://github.com/morhetz/gruvbox |
||||
" Last Modified: 31 Oct 2015 |
||||
" ----------------------------------------------------------------------------- |
||||
|
||||
function! s:getGruvColor(group) |
||||
let guiColor = synIDattr(hlID(a:group), "fg", "gui") |
||||
let termColor = synIDattr(hlID(a:group), "fg", "cterm") |
||||
return [ guiColor, termColor ] |
||||
endfunction |
||||
|
||||
if exists('g:lightline') |
||||
|
||||
let s:bg0 = s:getGruvColor('GruvboxBg0') |
||||
let s:bg1 = s:getGruvColor('GruvboxBg1') |
||||
let s:bg2 = s:getGruvColor('GruvboxBg2') |
||||
let s:bg4 = s:getGruvColor('GruvboxBg4') |
||||
let s:fg1 = s:getGruvColor('GruvboxFg1') |
||||
let s:fg4 = s:getGruvColor('GruvboxFg4') |
||||
|
||||
let s:yellow = s:getGruvColor('GruvboxYellow') |
||||
let s:blue = s:getGruvColor('GruvboxBlue') |
||||
let s:aqua = s:getGruvColor('GruvboxAqua') |
||||
let s:orange = s:getGruvColor('GruvboxOrange') |
||||
|
||||
let s:p = {'normal':{}, 'inactive':{}, 'insert':{}, 'replace':{}, 'visual':{}, 'tabline':{}} |
||||
let s:p.normal.left = [ [ s:bg0, s:fg4 ], [ s:fg4, s:bg2 ] ] |
||||
let s:p.normal.right = [ [ s:bg0, s:fg4 ], [ s:fg4, s:bg2 ] ] |
||||
let s:p.normal.middle = [ [ s:fg4, s:bg1 ] ] |
||||
let s:p.inactive.right = [ [ s:bg4, s:bg1 ], [ s:bg4, s:bg1 ] ] |
||||
let s:p.inactive.left = [ [ s:bg4, s:bg1 ], [ s:bg4, s:bg1 ] ] |
||||
let s:p.inactive.middle = [ [ s:bg4, s:bg1 ] ] |
||||
let s:p.insert.left = [ [ s:bg0, s:blue ], [ s:fg1, s:bg2 ] ] |
||||
let s:p.insert.right = [ [ s:bg0, s:blue ], [ s:fg1, s:bg2 ] ] |
||||
let s:p.insert.middle = [ [ s:fg4, s:bg2 ] ] |
||||
let s:p.replace.left = [ [ s:bg0, s:aqua ], [ s:fg1, s:bg2 ] ] |
||||
let s:p.replace.right = [ [ s:bg0, s:aqua ], [ s:fg1, s:bg2 ] ] |
||||
let s:p.replace.middle = [ [ s:fg4, s:bg2 ] ] |
||||
let s:p.visual.left = [ [ s:bg0, s:orange ], [ s:bg0, s:bg4 ] ] |
||||
let s:p.visual.right = [ [ s:bg0, s:orange ], [ s:bg0, s:bg4 ] ] |
||||
let s:p.visual.middle = [ [ s:fg4, s:bg1 ] ] |
||||
let s:p.tabline.left = [ [ s:fg4, s:bg2 ] ] |
||||
let s:p.tabline.tabsel = [ [ s:bg0, s:fg4 ] ] |
||||
let s:p.tabline.middle = [ [ s:bg0, s:bg0 ] ] |
||||
let s:p.tabline.right = [ [ s:bg0, s:orange ] ] |
||||
let s:p.normal.error = [ [ s:bg0, s:orange ] ] |
||||
let s:p.normal.warning = [ [ s:bg2, s:yellow ] ] |
||||
|
||||
let g:lightline#colorscheme#gruvbox#palette = lightline#colorscheme#flatten(s:p) |
||||
endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,118 @@ |
||||
#!/bin/sh |
||||
|
||||
if [ "${TERM%%-*}" = "screen" ]; then |
||||
if [ -n "$TMUX" ]; then |
||||
printf "\033Ptmux;\033\033]4;236;rgb:32/30/2f\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;234;rgb:1d/20/21\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;235;rgb:28/28/28\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;237;rgb:3c/38/36\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;239;rgb:50/49/45\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;241;rgb:66/5c/54\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;243;rgb:7c/6f/64\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;244;rgb:92/83/74\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;245;rgb:92/83/74\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;228;rgb:f2/e5/bc\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;230;rgb:f9/f5/d7\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;229;rgb:fb/f1/c7\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;223;rgb:eb/db/b2\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;250;rgb:d5/c4/a1\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;248;rgb:bd/ae/93\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;246;rgb:a8/99/84\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;167;rgb:fb/49/34\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;142;rgb:b8/bb/26\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;214;rgb:fa/bd/2f\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;109;rgb:83/a5/98\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;175;rgb:d3/86/9b\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;108;rgb:8e/c0/7c\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;208;rgb:fe/80/19\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;88;rgb:9d/00/06\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;100;rgb:79/74/0e\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;136;rgb:b5/76/14\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;24;rgb:07/66/78\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;96;rgb:8f/3f/71\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;66;rgb:42/7b/58\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;130;rgb:af/3a/03\007\033\\" |
||||
else |
||||
printf "\033P\033]4;236;rgb:32/30/2f\007\033\\" |
||||
printf "\033P\033]4;234;rgb:1d/20/21\007\033\\" |
||||
|
||||
printf "\033P\033]4;235;rgb:28/28/28\007\033\\" |
||||
printf "\033P\033]4;237;rgb:3c/38/36\007\033\\" |
||||
printf "\033P\033]4;239;rgb:50/49/45\007\033\\" |
||||
printf "\033P\033]4;241;rgb:66/5c/54\007\033\\" |
||||
printf "\033P\033]4;243;rgb:7c/6f/64\007\033\\" |
||||
|
||||
printf "\033P\033]4;244;rgb:92/83/74\007\033\\" |
||||
printf "\033P\033]4;245;rgb:92/83/74\007\033\\" |
||||
|
||||
printf "\033P\033]4;228;rgb:f2/e5/bc\007\033\\" |
||||
printf "\033P\033]4;230;rgb:f9/f5/d7\007\033\\" |
||||
|
||||
printf "\033P\033]4;229;rgb:fb/f1/c7\007\033\\" |
||||
printf "\033P\033]4;223;rgb:eb/db/b2\007\033\\" |
||||
printf "\033P\033]4;250;rgb:d5/c4/a1\007\033\\" |
||||
printf "\033P\033]4;248;rgb:bd/ae/93\007\033\\" |
||||
printf "\033P\033]4;246;rgb:a8/99/84\007\033\\" |
||||
|
||||
printf "\033P\033]4;167;rgb:fb/49/34\007\033\\" |
||||
printf "\033P\033]4;142;rgb:b8/bb/26\007\033\\" |
||||
printf "\033P\033]4;214;rgb:fa/bd/2f\007\033\\" |
||||
printf "\033P\033]4;109;rgb:83/a5/98\007\033\\" |
||||
printf "\033P\033]4;175;rgb:d3/86/9b\007\033\\" |
||||
printf "\033P\033]4;108;rgb:8e/c0/7c\007\033\\" |
||||
printf "\033P\033]4;208;rgb:fe/80/19\007\033\\" |
||||
|
||||
printf "\033P\033]4;88;rgb:9d/00/06\007\033\\" |
||||
printf "\033P\033]4;100;rgb:79/74/0e\007\033\\" |
||||
printf "\033P\033]4;136;rgb:b5/76/14\007\033\\" |
||||
printf "\033P\033]4;24;rgb:07/66/78\007\033\\" |
||||
printf "\033P\033]4;96;rgb:8f/3f/71\007\033\\" |
||||
printf "\033P\033]4;66;rgb:42/7b/58\007\033\\" |
||||
printf "\033P\033]4;130;rgb:af/3a/03\007\033\\" |
||||
fi |
||||
|
||||
elif [ "$TERM" != "linux" ] && [ "$TERM" != "vt100" ] && [ "$TERM" != "vt220" ]; then |
||||
|
||||
printf "\033]4;236;rgb:32/30/2f\033\\" |
||||
printf "\033]4;234;rgb:1d/20/21\033\\" |
||||
|
||||
printf "\033]4;235;rgb:28/28/28\033\\" |
||||
printf "\033]4;237;rgb:3c/38/36\033\\" |
||||
printf "\033]4;239;rgb:50/49/45\033\\" |
||||
printf "\033]4;241;rgb:66/5c/54\033\\" |
||||
printf "\033]4;243;rgb:7c/6f/64\033\\" |
||||
|
||||
printf "\033]4;244;rgb:92/83/74\033\\" |
||||
printf "\033]4;245;rgb:92/83/74\033\\" |
||||
|
||||
printf "\033]4;228;rgb:f2/e5/bc\033\\" |
||||
printf "\033]4;230;rgb:f9/f5/d7\033\\" |
||||
|
||||
printf "\033]4;229;rgb:fb/f1/c7\033\\" |
||||
printf "\033]4;223;rgb:eb/db/b2\033\\" |
||||
printf "\033]4;250;rgb:d5/c4/a1\033\\" |
||||
printf "\033]4;248;rgb:bd/ae/93\033\\" |
||||
printf "\033]4;246;rgb:a8/99/84\033\\" |
||||
|
||||
printf "\033]4;167;rgb:fb/49/34\033\\" |
||||
printf "\033]4;142;rgb:b8/bb/26\033\\" |
||||
printf "\033]4;214;rgb:fa/bd/2f\033\\" |
||||
printf "\033]4;109;rgb:83/a5/98\033\\" |
||||
printf "\033]4;175;rgb:d3/86/9b\033\\" |
||||
printf "\033]4;108;rgb:8e/c0/7c\033\\" |
||||
printf "\033]4;208;rgb:fe/80/19\033\\" |
||||
|
||||
printf "\033]4;88;rgb:9d/00/06\033\\" |
||||
printf "\033]4;100;rgb:79/74/0e\033\\" |
||||
printf "\033]4;136;rgb:b5/76/14\033\\" |
||||
printf "\033]4;24;rgb:07/66/78\033\\" |
||||
printf "\033]4;96;rgb:8f/3f/71\033\\" |
||||
printf "\033]4;66;rgb:42/7b/58\033\\" |
||||
printf "\033]4;130;rgb:af/3a/03\033\\" |
||||
fi |
@ -0,0 +1,116 @@ |
||||
#!/bin/sh |
||||
|
||||
if [ "${TERM%%-*}" = "screen" ]; then |
||||
if [ -n "$TMUX" ]; then |
||||
printf "\033Ptmux;\033\033]4;236;rgb:26/24/23\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;234;rgb:16/18/19\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;235;rgb:1e/1e/1e\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;237;rgb:2e/2a/29\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;239;rgb:3f/39/35\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;241;rgb:53/4a/42\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;243;rgb:68/5c/51\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;244;rgb:7f/70/61\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;245;rgb:7f/70/61\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;228;rgb:ef/df/ae\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;230;rgb:f8/f4/cd\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;229;rgb:fa/ee/bb\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;223;rgb:e6/d4/a3\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;250;rgb:cb/b8/90\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;248;rgb:af/9f/81\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;246;rgb:97/87/71\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;167;rgb:f7/30/28\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;142;rgb:aa/b0/1e\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;214;rgb:f7/b1/25\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;109;rgb:71/95/86\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;175;rgb:c7/70/89\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;108;rgb:7d/b6/69\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;208;rgb:fb/6a/16\007\033\\" |
||||
|
||||
printf "\033Ptmux;\033\033]4;88;rgb:89/00/09\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;100;rgb:66/62/0d\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;136;rgb:a5/63/11\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;24;rgb:0e/53/65\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;96;rgb:7b/2b/5e\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;66;rgb:35/6a/46\007\033\\" |
||||
printf "\033Ptmux;\033\033]4;130;rgb:9d/28/07\007\033\\" |
||||
else |
||||
printf "\033P\033]4;236;rgb:26/24/23\007\033\\" |
||||
printf "\033P\033]4;234;rgb:16/18/19\007\033\\" |
||||
|
||||
printf "\033P\033]4;235;rgb:1e/1e/1e\007\033\\" |
||||
printf "\033P\033]4;237;rgb:2e/2a/29\007\033\\" |
||||
printf "\033P\033]4;239;rgb:3f/39/35\007\033\\" |
||||
printf "\033P\033]4;241;rgb:53/4a/42\007\033\\" |
||||
printf "\033P\033]4;243;rgb:68/5c/51\007\033\\" |
||||
|
||||
printf "\033P\033]4;244;rgb:7f/70/61\007\033\\" |
||||
printf "\033P\033]4;245;rgb:7f/70/61\007\033\\" |
||||
|
||||
printf "\033P\033]4;228;rgb:ef/df/ae\007\033\\" |
||||
printf "\033P\033]4;230;rgb:f8/f4/cd\007\033\\" |
||||
|
||||
printf "\033P\033]4;229;rgb:fa/ee/bb\007\033\\" |
||||
printf "\033P\033]4;223;rgb:e6/d4/a3\007\033\\" |
||||
printf "\033P\033]4;250;rgb:cb/b8/90\007\033\\" |
||||
printf "\033P\033]4;248;rgb:af/9f/81\007\033\\" |
||||
printf "\033P\033]4;246;rgb:97/87/71\007\033\\" |
||||
|
||||
printf "\033P\033]4;167;rgb:f7/30/28\007\033\\" |
||||
printf "\033P\033]4;142;rgb:aa/b0/1e\007\033\\" |
||||
printf "\033P\033]4;214;rgb:f7/b1/25\007\033\\" |
||||
printf "\033P\033]4;109;rgb:71/95/86\007\033\\" |
||||
printf "\033P\033]4;175;rgb:c7/70/89\007\033\\" |
||||
printf "\033P\033]4;108;rgb:7d/b6/69\007\033\\" |
||||
printf "\033P\033]4;208;rgb:fb/6a/16\007\033\\" |
||||
|
||||
printf "\033P\033]4;88;rgb:89/00/09\007\033\\" |
||||
printf "\033P\033]4;100;rgb:66/62/0d\007\033\\" |
||||
printf "\033P\033]4;136;rgb:a5/63/11\007\033\\" |
||||
printf "\033P\033]4;24;rgb:0e/53/65\007\033\\" |
||||
printf "\033P\033]4;96;rgb:7b/2b/5e\007\033\\" |
||||
printf "\033P\033]4;66;rgb:35/6a/46\007\033\\" |
||||
printf "\033P\033]4;130;rgb:9d/28/07\007\033\\" |
||||
fi |
||||
else |
||||
printf "\033]4;236;rgb:26/24/23\033\\" |
||||
printf "\033]4;234;rgb:16/18/19\033\\" |
||||
|
||||
printf "\033]4;235;rgb:1e/1e/1e\033\\" |
||||
printf "\033]4;237;rgb:2e/2a/29\033\\" |
||||
printf "\033]4;239;rgb:3f/39/35\033\\" |
||||
printf "\033]4;241;rgb:53/4a/42\033\\" |
||||
printf "\033]4;243;rgb:68/5c/51\033\\" |
||||
|
||||
printf "\033]4;244;rgb:7f/70/61\033\\" |
||||
printf "\033]4;245;rgb:7f/70/61\033\\" |
||||
|
||||
printf "\033]4;228;rgb:ef/df/ae\033\\" |
||||
printf "\033]4;230;rgb:f8/f4/cd\033\\" |
||||
|
||||
printf "\033]4;229;rgb:fa/ee/bb\033\\" |
||||
printf "\033]4;223;rgb:e6/d4/a3\033\\" |
||||
printf "\033]4;250;rgb:cb/b8/90\033\\" |
||||
printf "\033]4;248;rgb:af/9f/81\033\\" |
||||
printf "\033]4;246;rgb:97/87/71\033\\" |
||||
|
||||
printf "\033]4;167;rgb:f7/30/28\033\\" |
||||
printf "\033]4;142;rgb:aa/b0/1e\033\\" |
||||
printf "\033]4;214;rgb:f7/b1/25\033\\" |
||||
printf "\033]4;109;rgb:71/95/86\033\\" |
||||
printf "\033]4;175;rgb:c7/70/89\033\\" |
||||
printf "\033]4;108;rgb:7d/b6/69\033\\" |
||||
printf "\033]4;208;rgb:fb/6a/16\033\\" |
||||
|
||||
printf "\033]4;88;rgb:89/00/09\033\\" |
||||
printf "\033]4;100;rgb:66/62/0d\033\\" |
||||
printf "\033]4;136;rgb:a5/63/11\033\\" |
||||
printf "\033]4;24;rgb:0e/53/65\033\\" |
||||
printf "\033]4;96;rgb:7b/2b/5e\033\\" |
||||
printf "\033]4;66;rgb:35/6a/46\033\\" |
||||
printf "\033]4;130;rgb:9d/28/07\033\\" |
||||
fi |
@ -1 +0,0 @@ |
||||
Subproject commit 28a989b28457e38df620e4c7ab23e224aff70efe |
@ -1 +0,0 @@ |
||||
Subproject commit 339f8ba079ed7d465ca442c9032b36bc56c21f61 |
@ -0,0 +1,5 @@ |
||||
/doc/tags |
||||
/misc |
||||
/test/*.actual |
||||
*.log |
||||
|
@ -0,0 +1,499 @@ |
||||
## vim-gitgutter |
||||
|
||||
A Vim plugin which shows a git diff in the 'gutter' (sign column). It shows whether each line has been added, modified, and where lines have been removed. You can also stage and undo individual hunks. |
||||
|
||||
Features: |
||||
|
||||
* Shows signs for added, modified, and removed lines. |
||||
* Runs the diffs asynchronously in terminal Vim/MacVim (7.4.1826+), gVim (7.4.1850+), MacVim GUI (7.4.1832+), and NeoVim. |
||||
* Ensures signs are always as up to date as possible (but without running more than necessary). |
||||
* Quick jumping between blocks of changed lines ("hunks"). |
||||
* Stage/undo/preview individual hunks. |
||||
* Provides a hunk text object. |
||||
* Diffs against index (default) or any commit. |
||||
* Handles line endings correctly, even with repos that do CRLF conversion. |
||||
* Optional line highlighting. |
||||
* Fully customisable (signs, sign column, line highlights, mappings, extra git-diff arguments, etc). |
||||
* Can be toggled on/off. |
||||
* Preserves signs from other plugins. |
||||
* Easy to integrate diff stats into status line; built-in integration with [vim-airline](https://github.com/bling/vim-airline/). |
||||
* Works with fish shell (in addition to the usual shells). |
||||
|
||||
Constraints: |
||||
|
||||
* Supports git only. |
||||
|
||||
If you work with other version control systems, I recommend [vim-signify](https://github.com/mhinz/vim-signify). |
||||
|
||||
|
||||
### Screenshot |
||||
|
||||
 |
||||
|
||||
In the screenshot above you can see: |
||||
|
||||
* Line 15 has been modified. |
||||
* Lines 21-24 are new. |
||||
* A line or lines were removed between lines 25 and 26. |
||||
|
||||
|
||||
### Installation |
||||
|
||||
Before installation, please check your Vim supports signs by running `:echo has('signs')`. `1` means you're all set; `0` means you need to install a Vim with signs support. If you're compiling Vim yourself you need the 'big' or 'huge' feature set. [MacVim][] supports signs. |
||||
|
||||
You install vim-gitgutter like any other vim plugin. |
||||
|
||||
##### Pathogen |
||||
|
||||
``` |
||||
cd ~/.vim/bundle |
||||
git clone git://github.com/airblade/vim-gitgutter.git |
||||
``` |
||||
|
||||
##### Voom |
||||
|
||||
Edit your plugin manifest (`voom edit`) and add: |
||||
|
||||
``` |
||||
airblade/vim-gitgutter |
||||
``` |
||||
|
||||
##### VimPlug |
||||
|
||||
Place this in your .vimrc: |
||||
|
||||
```viml |
||||
Plug 'airblade/vim-gitgutter' |
||||
``` |
||||
|
||||
Then run the following in Vim: |
||||
|
||||
``` |
||||
:source % |
||||
:PlugInstall |
||||
``` |
||||
|
||||
##### NeoBundle |
||||
|
||||
Place this in your .vimrc: |
||||
|
||||
```viml |
||||
NeoBundle 'airblade/vim-gitgutter' |
||||
``` |
||||
|
||||
Then run the following in Vim: |
||||
|
||||
``` |
||||
:source % |
||||
:NeoBundleInstall |
||||
``` |
||||
|
||||
##### No plugin manager |
||||
|
||||
Copy vim-gitgutter's subdirectories into your vim configuration directory: |
||||
|
||||
``` |
||||
cd /tmp && git clone git://github.com/airblade/vim-gitgutter.git |
||||
cp -r vim-gitgutter/* ~/.vim/ |
||||
``` |
||||
|
||||
See `:help add-global-plugin`. |
||||
|
||||
|
||||
If you are on Windows you may find the command prompt pops up briefly every time vim-gitgutter runs. You can avoid this by installing both [vim-misc](https://github.com/xolox/vim-misc) and [vim-shell](https://github.com/xolox/vim-shell). If you have those two plugins but don't want vim-gitgutter to use them, you can opt out with `let g:gitgutter_avoid_cmd_prompt_on_windows = 0` in your `~/.vimrc`. |
||||
|
||||
|
||||
### Getting started |
||||
|
||||
When you make a change to a file tracked by git, the diff markers should appear automatically. The delay is governed by vim's `updatetime` option; the default value is 4 seconds but I suggest reducing it to around 250ms (add `set updatetime=250` to your vimrc). |
||||
|
||||
You can jump between hunks with `[c` and `]c`. You can preview, stage, and undo hunks with `<leader>hp`, `<leader>hs`, and `<leader>hu` respectively. |
||||
|
||||
You cannot currently unstage a staged hunk. |
||||
|
||||
|
||||
#### Activation |
||||
|
||||
You can explicitly turn vim-gitgutter off and on (defaults to on): |
||||
|
||||
* turn off with `:GitGutterDisable` |
||||
* turn on with `:GitGutterEnable` |
||||
* toggle with `:GitGutterToggle`. |
||||
|
||||
You can turn the signs on and off (defaults to on): |
||||
|
||||
* turn on with `:GitGutterSignsEnable` |
||||
* turn off with `:GitGutterSignsDisable` |
||||
* toggle with `:GitGutterSignsToggle`. |
||||
|
||||
And you can turn line highlighting on and off (defaults to off): |
||||
|
||||
* turn on with `:GitGutterLineHighlightsEnable` |
||||
* turn off with `:GitGutterLineHighlightsDisable` |
||||
* toggle with `:GitGutterLineHighlightsToggle`. |
||||
|
||||
Note that if you have line highlighting on and signs off, you will have an empty sign column โ more accurately, a sign column with invisible signs. This is because line highlighting requires signs and Vim always shows the sign column even if the signs are invisible. |
||||
|
||||
If you switch off both line highlighting and signs, you won't see the sign column. That is unless you have set `let g:gitgutter_sign_column_always = 1` so it's always there. |
||||
|
||||
To keep your Vim snappy, vim-gitgutter will suppress itself when a file has more than 500 changes. As soon as the number of changes falls below the limit vim-gitgutter will show the signs again. You can configure the threshold with: |
||||
|
||||
```viml |
||||
let g:gitgutter_max_signs = 500 " default value |
||||
``` |
||||
|
||||
#### Hunks |
||||
|
||||
You can jump between hunks: |
||||
|
||||
* jump to next hunk (change): `]c` |
||||
* jump to previous hunk (change): `[c`. |
||||
|
||||
Both of those take a preceding count. |
||||
|
||||
To set your own mappings for these, for example `]h` and `[h`: |
||||
|
||||
```viml |
||||
nmap ]h <Plug>GitGutterNextHunk |
||||
nmap [h <Plug>GitGutterPrevHunk |
||||
``` |
||||
|
||||
You can stage or undo an individual hunk when your cursor is in it: |
||||
|
||||
* stage the hunk with `<Leader>hs` or |
||||
* undo it with `<Leader>hu`. |
||||
|
||||
See the FAQ if you want to unstage staged changes. |
||||
|
||||
The `.` command will work with both these if you install [repeat.vim](https://github.com/tpope/vim-repeat). |
||||
|
||||
To set your own mappings for these, for example if you prefer the mnemonics hunk-add and hunk-revert: |
||||
|
||||
```viml |
||||
nmap <Leader>ha <Plug>GitGutterStageHunk |
||||
nmap <Leader>hr <Plug>GitGutterUndoHunk |
||||
``` |
||||
|
||||
And you can preview a hunk's changes with `<Leader>hp`. You can of course change this mapping, e.g: |
||||
|
||||
```viml |
||||
nmap <Leader>hv <Plug>GitGutterPreviewHunk |
||||
``` |
||||
|
||||
A hunk text object is provided which works in visual and operator-pending modes. |
||||
|
||||
- `ic` operates on all lines in the current hunk. |
||||
- `ac` operates on all lines in the current hunk and any trailing empty lines. |
||||
|
||||
To re-map these, for example to `ih` and `ah`: |
||||
|
||||
```viml |
||||
omap ih <Plug>GitGutterTextObjectInnerPending |
||||
omap ah <Plug>GitGutterTextObjectOuterPending |
||||
xmap ih <Plug>GitGutterTextObjectInnerVisual |
||||
xmap ah <Plug>GitGutterTextObjectOuterVisual |
||||
``` |
||||
|
||||
If you don't want vim-gitgutter to set up any mappings at all, use this: |
||||
|
||||
```viml |
||||
let g:gitgutter_map_keys = 0 |
||||
``` |
||||
|
||||
Finally, you can force vim-gitgutter to update its signs across all visible buffers with `:GitGutterAll`. |
||||
|
||||
See the customisation section below for how to change the defaults. |
||||
|
||||
|
||||
### When are the signs updated? |
||||
|
||||
By default the signs are updated as follows: |
||||
|
||||
| Event | Reason for update | Configuration | |
||||
|---------------------------|--------------------------------------|------------------------| |
||||
| Stop typing | So the signs are real time | `g:gitgutter_realtime` | |
||||
| Switch buffer | To notice change to git index | `g:gitgutter_eager` | |
||||
| Switch tab | To notice change to git index | `g:gitgutter_eager` | |
||||
| Focus the GUI | To notice change to git index | `g:gitgutter_eager` (not gVim on Windows) | |
||||
| Read a file into a buffer | To display initial signs | [always] | |
||||
| Save a buffer | So non-realtime signs are up to date | [always] | |
||||
| Change a file outside Vim | To notice `git stash` | [always] | |
||||
|
||||
The length of time Vim waits after you stop typing before it triggers the plugin is governed by the setting `updatetime`. This defaults to `4000` milliseconds which is rather too long. I recommend around `250` milliseconds but it depends on your system and your preferences. Note that in terminal Vim pre-7.4.427 an `updatetime` of less than approximately `1000` milliseconds can lead to random highlighting glitches; the lower the `updatetime`, the more glitches. |
||||
|
||||
If you experience a lag, you can trade speed for accuracy: |
||||
|
||||
```viml |
||||
let g:gitgutter_realtime = 0 |
||||
let g:gitgutter_eager = 0 |
||||
``` |
||||
|
||||
Note the realtime updating requires Vim 7.3.105 or higher. |
||||
|
||||
|
||||
### Customisation |
||||
|
||||
You can customise: |
||||
|
||||
* The sign column's colours |
||||
* Whether or not the sign column is shown when there aren't any signs (defaults to no) |
||||
* The signs' colours and symbols |
||||
* Line highlights |
||||
* The base of the diff |
||||
* Extra arguments for `git diff` |
||||
* Key mappings |
||||
* Whether or not vim-gitgutter is on initially (defaults to on) |
||||
* Whether or not signs are shown (defaults to yes) |
||||
* Whether or not line highlighting is on initially (defaults to off) |
||||
* Whether or not vim-gitgutter runs in "realtime" (defaults to yes) |
||||
* Whether or not vim-gitgutter runs eagerly (defaults to yes) |
||||
* Whether or not vim-gitgutter runs asynchronously (defaults to yes) |
||||
|
||||
Please note that vim-gitgutter won't override any colours or highlights you've set in your colorscheme. |
||||
|
||||
|
||||
#### Sign column |
||||
|
||||
By default vim-gitgutter will make the sign column look like the line number column. |
||||
|
||||
To customise your sign column's background color, first tell vim-gitgutter to leave it alone: |
||||
|
||||
```viml |
||||
let g:gitgutter_override_sign_column_highlight = 0 |
||||
``` |
||||
|
||||
And then either update your colorscheme's `SignColumn` highlight group or set it in your vimrc: |
||||
|
||||
```viml |
||||
highlight SignColumn ctermbg=whatever " terminal Vim |
||||
highlight SignColumn guibg=whatever " gVim/MacVim |
||||
``` |
||||
|
||||
By default the sign column will appear when there are signs to show and disappear when there aren't. If you would always like the sign column to be there, add `let g:gitgutter_sign_column_always = 1` to your `~/.vimrc`. |
||||
|
||||
|
||||
#### Signs' colours and symbols |
||||
|
||||
To customise the colours, set up the following highlight groups in your colorscheme or `~/.vimrc`: |
||||
|
||||
```viml |
||||
GitGutterAdd " an added line |
||||
GitGutterChange " a changed line |
||||
GitGutterDelete " at least one removed line |
||||
GitGutterChangeDelete " a changed line followed by at least one removed line |
||||
``` |
||||
|
||||
You can either set these with `highlight GitGutterAdd {key}={arg}...` or link them to existing highlight groups with, say, `highlight link GitGutterAdd DiffAdd`. |
||||
|
||||
To customise the symbols, add the following to your `~/.vimrc`: |
||||
|
||||
```viml |
||||
let g:gitgutter_sign_added = 'xx' |
||||
let g:gitgutter_sign_modified = 'yy' |
||||
let g:gitgutter_sign_removed = 'zz' |
||||
let g:gitgutter_sign_removed_first_line = '^^' |
||||
let g:gitgutter_sign_modified_removed = 'ww' |
||||
``` |
||||
|
||||
|
||||
#### Line highlights |
||||
|
||||
Similarly to the signs' colours, set up the following highlight groups in your colorscheme or `~/.vimrc`: |
||||
|
||||
```viml |
||||
GitGutterAddLine " default: links to DiffAdd |
||||
GitGutterChangeLine " default: links to DiffChange |
||||
GitGutterDeleteLine " default: links to DiffDelete |
||||
GitGutterChangeDeleteLine " default: links to GitGutterChangeLineDefault, i.e. DiffChange |
||||
``` |
||||
|
||||
|
||||
#### The base of the diff |
||||
|
||||
By default buffers are diffed against the index. However you can diff against any commit by setting: |
||||
|
||||
```viml |
||||
let g:gitgutter_diff_base = '<commit SHA>' |
||||
``` |
||||
|
||||
|
||||
#### Extra arguments for `git diff` |
||||
|
||||
If you want to pass extra arguments to `git diff`, for example to ignore whitespace, do so like this: |
||||
|
||||
```viml |
||||
let g:gitgutter_diff_args = '-w' |
||||
``` |
||||
|
||||
#### Key mappings |
||||
|
||||
To disable all key mappings: |
||||
|
||||
```viml |
||||
let g:gitgutter_map_keys = 0 |
||||
``` |
||||
|
||||
See above for configuring maps for hunk-jumping and staging/undoing. |
||||
|
||||
|
||||
#### Use a custom `grep` command |
||||
|
||||
If you use an alternative to grep, or your grep does not support the `color` flag, you can tell vim-gitgutter to use it here. It only needs to support extended POSIX regex. |
||||
|
||||
```viml |
||||
" Default: |
||||
let g:gitgutter_grep_command = 'grep --color=never -e' |
||||
``` |
||||
|
||||
#### To turn off vim-gitgutter by default |
||||
|
||||
Add `let g:gitgutter_enabled = 0` to your `~/.vimrc`. |
||||
|
||||
|
||||
#### To turn off signs by default |
||||
|
||||
Add `let g:gitgutter_signs = 0` to your `~/.vimrc`. |
||||
|
||||
|
||||
#### To turn on line highlighting by default |
||||
|
||||
Add `let g:gitgutter_highlight_lines = 1` to your `~/.vimrc`. |
||||
|
||||
|
||||
#### To turn off asynchronous updates |
||||
|
||||
By default diffs are run asynchronously. To run diffs synchronously instead: |
||||
|
||||
```viml |
||||
let g:gitgutter_async = 0 |
||||
``` |
||||
|
||||
|
||||
### Extensions |
||||
|
||||
#### Operate on every line in a hunk |
||||
|
||||
You can map an operator to do whatever you want to every line in a hunk. |
||||
|
||||
Let's say, for example, you want to remove trailing whitespace. |
||||
|
||||
```viml |
||||
function! CleanUp(...) |
||||
if a:0 " opfunc |
||||
let [first, last] = [line("'["), line("']")] |
||||
else |
||||
let [first, last] = [line("'<"), line("'>")] |
||||
endif |
||||
for lnum in range(first, last) |
||||
let line = getline(lnum) |
||||
|
||||
" clean up the text, e.g.: |
||||
let line = substitute(line, '\s\+$', '', '') |
||||
|
||||
call setline(lnum, line) |
||||
endfor |
||||
endfunction |
||||
|
||||
nmap <silent> <Leader>x :set opfunc=CleanUp<CR>g@ |
||||
``` |
||||
|
||||
Then place your cursor in a hunk and type `\xic` (assuming a leader of `\`). |
||||
|
||||
Alternatively you could place your cursor in a hunk, type `vic` to select it, then `:call CleanUp()`. |
||||
|
||||
|
||||
#### Operate on every changed line in a file |
||||
|
||||
You can write a command to do whatever you want to every changed line in a file. |
||||
|
||||
```viml |
||||
function! GlobalChangedLines(ex_cmd) |
||||
for hunk in GitGutterGetHunks() |
||||
for lnum in range(hunk[2], hunk[2]+hunk[3]-1) |
||||
let cursor = getcurpos() |
||||
silent! execute lnum.a:ex_cmd |
||||
call setpos('.', cursor) |
||||
endfor |
||||
endfor |
||||
endfunction |
||||
|
||||
command -nargs=1 Glines call GlobalChangedLines(<q-args>) |
||||
``` |
||||
|
||||
Let's say, for example, you want to remove trailing whitespace from all changed lines: |
||||
|
||||
```viml |
||||
:Glines s/\s\+$// |
||||
``` |
||||
|
||||
|
||||
### FAQ |
||||
|
||||
> Why can't I unstage staged changes? |
||||
|
||||
Unstaging staged hunks is feasible but not quite as easy as it sounds. There are three relevant versions of a file at any one time: |
||||
|
||||
1. The version at HEAD in the repo. |
||||
2. The version staged in the index. |
||||
3. The version in the working tree, in your vim buffer. |
||||
|
||||
`git-diff` without arguments shows you how 3 and 2 differ; this is what vim-gitgutter shows too. |
||||
|
||||
`git-diff --staged` shows you how 2 and 1 differ. |
||||
|
||||
Let's say you are looking at a file in vim which has some unstaged changes. Now you stage a hunk, either via vim-gitgutter or another means. The hunk is no longer marked in vim-gitgutter because it is the same in 3 and 2. |
||||
|
||||
Now you want to unstage that hunk. To see it, you need the difference between 2 and 1. For vim-gitgutter to show those differences, it would need to show you 2 instead of 3 in your vim buffer. But 2 is virtual so vim-gitgutter would need to handle it without touching 3. |
||||
|
||||
I intend to implement this but I can't commit to any deadline. |
||||
|
||||
> Why are the colours in the sign column weird? |
||||
|
||||
Your colorscheme is configuring the `SignColumn` highlight group weirdly. Please see the section above on customising the sign column. |
||||
|
||||
> There's a noticeable lag when vim-gitter runs; how can I avoid it? |
||||
|
||||
By default vim-gitgutter runs often so the signs are as accurate as possible. The delay is governed by `updatetime`; see [above](#when-are-the-signs-updated) for more information. |
||||
|
||||
If you don't want realtime updates and would like to trade a little accuracy for speed, add this to your `~/.vimrc`: |
||||
|
||||
```viml |
||||
let g:gitgutter_realtime = 0 |
||||
let g:gitgutter_eager = 0 |
||||
``` |
||||
|
||||
> What happens if I also use another plugin which uses signs (e.g. Syntastic)? |
||||
|
||||
Vim only allows one sign per line. Before adding a sign to a line, vim-gitgutter checks whether a sign has already been added by somebody else. If so it doesn't do anything. In other words vim-gitgutter won't overwrite another plugin's signs. It also won't remove another plugin's signs. |
||||
|
||||
> Why aren't any signs showing at all? |
||||
|
||||
Here are some things you can check: |
||||
|
||||
* `:echo system("git --version")` succeeds. |
||||
* Your git config is compatible with the version of git returned by the command above. |
||||
* Your Vim supports signs (`:echo has('signs')` should give `1`). |
||||
* Your file is being tracked by git and has unstaged changes. |
||||
* If your grep does not support the `color` flag, add `let g:gitgutter_grep_command = 'grep -e'` to your `~/.vimrc`. |
||||
|
||||
|
||||
### Shameless Plug |
||||
|
||||
If this plugin has helped you, or you'd like to learn more about Vim, why not check out this screencast I wrote for PeepCode: |
||||
|
||||
* [Smash Into Vim][siv] |
||||
|
||||
This was one of PeepCode's all-time top three bestsellers and is now available at Pluralsight. |
||||
|
||||
You can read reviews on my [website][airblade]. |
||||
|
||||
|
||||
### Intellectual Property |
||||
|
||||
Copyright Andrew Stewart, AirBlade Software Ltd. Released under the MIT licence. |
||||
|
||||
|
||||
[pathogen]: https://github.com/tpope/vim-pathogen |
||||
[siv]: http://pluralsight.com/training/Courses/TableOfContents/smash-into-vim |
||||
[airblade]: http://airbladesoftware.com/peepcode-vim |
||||
[macvim]: http://code.google.com/p/macvim/ |
@ -0,0 +1,253 @@ |
||||
let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ? '<nomodeline>' : '' |
||||
|
||||
" Primary functions {{{ |
||||
|
||||
function! gitgutter#all() abort |
||||
for buffer_id in gitgutter#utility#dedup(tabpagebuflist()) |
||||
let file = expand('#' . buffer_id . ':p') |
||||
if !empty(file) |
||||
call gitgutter#process_buffer(buffer_id, 0) |
||||
endif |
||||
endfor |
||||
endfunction |
||||
|
||||
" bufnr: (integer) the buffer to process. |
||||
" realtime: (boolean) when truthy, do a realtime diff; otherwise do a disk-based diff. |
||||
function! gitgutter#process_buffer(bufnr, realtime) abort |
||||
call gitgutter#utility#use_known_shell() |
||||
|
||||
call gitgutter#utility#set_buffer(a:bufnr) |
||||
if gitgutter#utility#is_active() |
||||
if g:gitgutter_sign_column_always |
||||
call gitgutter#sign#add_dummy_sign() |
||||
endif |
||||
try |
||||
if !a:realtime || gitgutter#utility#has_fresh_changes() |
||||
let diff = gitgutter#diff#run_diff(a:realtime || gitgutter#utility#has_unsaved_changes(), 0) |
||||
if diff != 'async' |
||||
call gitgutter#handle_diff(diff) |
||||
endif |
||||
endif |
||||
catch /diff failed/ |
||||
call gitgutter#debug#log('diff failed') |
||||
call gitgutter#hunk#reset() |
||||
endtry |
||||
execute "silent doautocmd" s:nomodeline "User GitGutter" |
||||
else |
||||
call gitgutter#hunk#reset() |
||||
endif |
||||
|
||||
call gitgutter#utility#restore_shell() |
||||
endfunction |
||||
|
||||
|
||||
function! gitgutter#handle_diff(diff) abort |
||||
call gitgutter#debug#log(a:diff) |
||||
|
||||
call setbufvar(gitgutter#utility#bufnr(), 'gitgutter_tracked', 1) |
||||
|
||||
call gitgutter#hunk#set_hunks(gitgutter#diff#parse_diff(a:diff)) |
||||
let modified_lines = gitgutter#diff#process_hunks(gitgutter#hunk#hunks()) |
||||
|
||||
if len(modified_lines) > g:gitgutter_max_signs |
||||
call gitgutter#utility#warn_once('exceeded maximum number of signs (configured by g:gitgutter_max_signs).', 'max_signs') |
||||
call gitgutter#sign#clear_signs() |
||||
return |
||||
endif |
||||
|
||||
if g:gitgutter_signs || g:gitgutter_highlight_lines |
||||
call gitgutter#sign#update_signs(modified_lines) |
||||
endif |
||||
|
||||
call gitgutter#utility#save_last_seen_change() |
||||
endfunction |
||||
|
||||
function! gitgutter#disable() abort |
||||
" get list of all buffers (across all tabs) |
||||
let buflist = [] |
||||
for i in range(tabpagenr('$')) |
||||
call extend(buflist, tabpagebuflist(i + 1)) |
||||
endfor |
||||
|
||||
for buffer_id in gitgutter#utility#dedup(buflist) |
||||
let file = expand('#' . buffer_id . ':p') |
||||
if !empty(file) |
||||
call gitgutter#utility#set_buffer(buffer_id) |
||||
call gitgutter#sign#clear_signs() |
||||
call gitgutter#sign#remove_dummy_sign(1) |
||||
call gitgutter#hunk#reset() |
||||
endif |
||||
endfor |
||||
|
||||
let g:gitgutter_enabled = 0 |
||||
endfunction |
||||
|
||||
function! gitgutter#enable() abort |
||||
let g:gitgutter_enabled = 1 |
||||
call gitgutter#all() |
||||
endfunction |
||||
|
||||
function! gitgutter#toggle() abort |
||||
if g:gitgutter_enabled |
||||
call gitgutter#disable() |
||||
else |
||||
call gitgutter#enable() |
||||
endif |
||||
endfunction |
||||
|
||||
" }}} |
||||
|
||||
" Line highlights {{{ |
||||
|
||||
function! gitgutter#line_highlights_disable() abort |
||||
let g:gitgutter_highlight_lines = 0 |
||||
call gitgutter#highlight#define_sign_line_highlights() |
||||
|
||||
if !g:gitgutter_signs |
||||
call gitgutter#sign#clear_signs() |
||||
call gitgutter#sign#remove_dummy_sign(0) |
||||
endif |
||||
|
||||
redraw! |
||||
endfunction |
||||
|
||||
function! gitgutter#line_highlights_enable() abort |
||||
let old_highlight_lines = g:gitgutter_highlight_lines |
||||
|
||||
let g:gitgutter_highlight_lines = 1 |
||||
call gitgutter#highlight#define_sign_line_highlights() |
||||
|
||||
if !old_highlight_lines && !g:gitgutter_signs |
||||
call gitgutter#all() |
||||
endif |
||||
|
||||
redraw! |
||||
endfunction |
||||
|
||||
function! gitgutter#line_highlights_toggle() abort |
||||
if g:gitgutter_highlight_lines |
||||
call gitgutter#line_highlights_disable() |
||||
else |
||||
call gitgutter#line_highlights_enable() |
||||
endif |
||||
endfunction |
||||
|
||||
" }}} |
||||
|
||||
" Signs {{{ |
||||
|
||||
function! gitgutter#signs_enable() abort |
||||
let old_signs = g:gitgutter_signs |
||||
|
||||
let g:gitgutter_signs = 1 |
||||
call gitgutter#highlight#define_sign_text_highlights() |
||||
|
||||
if !old_signs && !g:gitgutter_highlight_lines |
||||
call gitgutter#all() |
||||
endif |
||||
endfunction |
||||
|
||||
function! gitgutter#signs_disable() abort |
||||
let g:gitgutter_signs = 0 |
||||
call gitgutter#highlight#define_sign_text_highlights() |
||||
|
||||
if !g:gitgutter_highlight_lines |
||||
call gitgutter#sign#clear_signs() |
||||
call gitgutter#sign#remove_dummy_sign(0) |
||||
endif |
||||
endfunction |
||||
|
||||
function! gitgutter#signs_toggle() abort |
||||
if g:gitgutter_signs |
||||
call gitgutter#signs_disable() |
||||
else |
||||
call gitgutter#signs_enable() |
||||
endif |
||||
endfunction |
||||
|
||||
" }}} |
||||
|
||||
" Hunks {{{ |
||||
|
||||
function! gitgutter#stage_hunk() abort |
||||
call gitgutter#utility#use_known_shell() |
||||
if gitgutter#utility#is_active() |
||||
" Ensure the working copy of the file is up to date. |
||||
" It doesn't make sense to stage a hunk otherwise. |
||||
noautocmd silent write |
||||
let diff = gitgutter#diff#run_diff(0, 1) |
||||
call gitgutter#handle_diff(diff) |
||||
|
||||
if empty(gitgutter#hunk#current_hunk()) |
||||
call gitgutter#utility#warn('cursor is not in a hunk') |
||||
else |
||||
let diff_for_hunk = gitgutter#diff#generate_diff_for_hunk(diff, 'stage') |
||||
call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' apply --cached --unidiff-zero - '), diff_for_hunk) |
||||
|
||||
" refresh gitgutter's view of buffer |
||||
silent execute "GitGutter" |
||||
endif |
||||
|
||||
silent! call repeat#set("\<Plug>GitGutterStageHunk", -1)<CR> |
||||
endif |
||||
call gitgutter#utility#restore_shell() |
||||
endfunction |
||||
|
||||
function! gitgutter#undo_hunk() abort |
||||
call gitgutter#utility#use_known_shell() |
||||
if gitgutter#utility#is_active() |
||||
" Ensure the working copy of the file is up to date. |
||||
" It doesn't make sense to stage a hunk otherwise. |
||||
noautocmd silent write |
||||
let diff = gitgutter#diff#run_diff(0, 1) |
||||
call gitgutter#handle_diff(diff) |
||||
|
||||
if empty(gitgutter#hunk#current_hunk()) |
||||
call gitgutter#utility#warn('cursor is not in a hunk') |
||||
else |
||||
let diff_for_hunk = gitgutter#diff#generate_diff_for_hunk(diff, 'undo') |
||||
call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' apply --reverse --unidiff-zero - '), diff_for_hunk) |
||||
|
||||
" reload file preserving screen line position |
||||
let wl = winline() |
||||
silent edit |
||||
let offset = wl - winline() |
||||
execute "normal! ".offset."\<C-Y>" |
||||
endif |
||||
|
||||
silent! call repeat#set("\<Plug>GitGutterUndoHunk", -1)<CR> |
||||
endif |
||||
call gitgutter#utility#restore_shell() |
||||
endfunction |
||||
|
||||
function! gitgutter#preview_hunk() abort |
||||
call gitgutter#utility#use_known_shell() |
||||
if gitgutter#utility#is_active() |
||||
" Ensure the working copy of the file is up to date. |
||||
" It doesn't make sense to stage a hunk otherwise. |
||||
noautocmd silent write |
||||
let diff = gitgutter#diff#run_diff(0, 1) |
||||
call gitgutter#handle_diff(diff) |
||||
|
||||
if empty(gitgutter#hunk#current_hunk()) |
||||
call gitgutter#utility#warn('cursor is not in a hunk') |
||||
else |
||||
let diff_for_hunk = gitgutter#diff#generate_diff_for_hunk(diff, 'preview') |
||||
|
||||
silent! wincmd P |
||||
if !&previewwindow |
||||
noautocmd execute 'bo' &previewheight 'new' |
||||
set previewwindow |
||||
endif |
||||
|
||||
setlocal noro modifiable filetype=diff buftype=nofile bufhidden=delete noswapfile |
||||
execute "%delete_" |
||||
call append(0, split(diff_for_hunk, "\n")) |
||||
|
||||
noautocmd wincmd p |
||||
endif |
||||
endif |
||||
call gitgutter#utility#restore_shell() |
||||
endfunction |
||||
|
||||
" }}} |
@ -0,0 +1,211 @@ |
||||
let s:jobs = {} |
||||
|
||||
" Nvim has always supported async commands. |
||||
" |
||||
" Vim introduced async in 7.4.1826. |
||||
" |
||||
" gVim didn't support aync until 7.4.1850 (though I haven't been able to |
||||
" verify this myself). |
||||
" |
||||
" MacVim-GUI didn't support async until 7.4.1832 (actually commit |
||||
" 88f4fe0 but 7.4.1832 was the first subsequent patch release). |
||||
let s:available = has('nvim') || ( |
||||
\ has('job') && ( |
||||
\ (has('patch-7-4-1826') && !has('gui_running')) || |
||||
\ (has('patch-7-4-1850') && has('gui_running')) || |
||||
\ (has('patch-7-4-1832') && has('gui_macvim')) |
||||
\ ) |
||||
\ ) |
||||
|
||||
function! gitgutter#async#available() |
||||
return s:available |
||||
endfunction |
||||
|
||||
function! gitgutter#async#execute(cmd) abort |
||||
let bufnr = gitgutter#utility#bufnr() |
||||
|
||||
if has('nvim') |
||||
if has('unix') |
||||
let command = ["sh", "-c", a:cmd] |
||||
elseif has('win32') |
||||
let command = ["cmd.exe", "/c", a:cmd] |
||||
else |
||||
throw 'unknown os' |
||||
endif |
||||
" Make the job use a shell while avoiding (un)quoting problems. |
||||
let job_id = jobstart(command, { |
||||
\ 'buffer': bufnr, |
||||
\ 'on_stdout': function('gitgutter#async#handle_diff_job_nvim'), |
||||
\ 'on_stderr': function('gitgutter#async#handle_diff_job_nvim'), |
||||
\ 'on_exit': function('gitgutter#async#handle_diff_job_nvim') |
||||
\ }) |
||||
call gitgutter#debug#log('[nvim job: '.job_id.', buffer: '.bufnr.'] '.a:cmd) |
||||
if job_id < 1 |
||||
throw 'diff failed' |
||||
endif |
||||
|
||||
" Note that when `cmd` doesn't produce any output, i.e. the diff is empty, |
||||
" the `stdout` event is not fired on the job handler. Therefore we keep |
||||
" track of the jobs ourselves so we can spot empty diffs. |
||||
call s:job_started(job_id) |
||||
|
||||
else |
||||
" Make the job use a shell. |
||||
" |
||||
" Pass a handler for stdout but not for stderr so that errors are |
||||
" ignored (and thus signs are not updated; this assumes that an error |
||||
" only occurs when a file is not tracked by git). |
||||
|
||||
if has('unix') |
||||
let command = ["sh", "-c", a:cmd] |
||||
elseif has('win32') |
||||
" Help docs recommend {command} be a string on Windows. But I think |
||||
" they also say that will run the command directly, which I believe would |
||||
" mean the redirection and pipe stuff wouldn't work. |
||||
" let command = "cmd.exe /c ".a:cmd |
||||
let command = ["cmd.exe", "/c", a:cmd] |
||||
else |
||||
throw 'unknown os' |
||||
endif |
||||
|
||||
let job = job_start(command, { |
||||
\ 'out_cb': 'gitgutter#async#handle_diff_job_vim', |
||||
\ 'close_cb': 'gitgutter#async#handle_diff_job_vim_close' |
||||
\ }) |
||||
call gitgutter#debug#log('[vim job: '.string(job_info(job)).', buffer: '.bufnr.'] '.a:cmd) |
||||
|
||||
call s:job_started(s:channel_id(job_getchannel(job)), bufnr) |
||||
endif |
||||
endfunction |
||||
|
||||
|
||||
function! gitgutter#async#handle_diff_job_nvim(job_id, data, event) abort |
||||
call gitgutter#debug#log('job_id: '.a:job_id.', event: '.a:event.', buffer: '.self.buffer) |
||||
|
||||
let job_bufnr = self.buffer |
||||
if bufexists(job_bufnr) |
||||
let current_buffer = gitgutter#utility#bufnr() |
||||
call gitgutter#utility#set_buffer(job_bufnr) |
||||
|
||||
if a:event == 'stdout' |
||||
" a:data is a list |
||||
call s:job_finished(a:job_id) |
||||
if gitgutter#utility#is_active() |
||||
call gitgutter#handle_diff(gitgutter#utility#stringify(a:data)) |
||||
endif |
||||
|
||||
elseif a:event == 'exit' |
||||
" If the exit event is triggered without a preceding stdout event, |
||||
" the diff was empty. |
||||
if s:is_job_started(a:job_id) |
||||
if gitgutter#utility#is_active() |
||||
call gitgutter#handle_diff("") |
||||
endif |
||||
call s:job_finished(a:job_id) |
||||
endif |
||||
|
||||
else " a:event is stderr |
||||
call gitgutter#hunk#reset() |
||||
call s:job_finished(a:job_id) |
||||
|
||||
endif |
||||
|
||||
call gitgutter#utility#set_buffer(current_buffer) |
||||
else |
||||
call s:job_finished(a:job_id) |
||||
endif |
||||
endfunction |
||||
|
||||
|
||||