GithubHelp home page GithubHelp logo

committia.vim's Introduction

More Pleasant Editing on Commit Message

When you type git commit, Vim starts and opens a commit buffer. This plugin improves the commit buffer.

committia.vim splits the buffer into 3 windows; edit window, status window and diff window. You no longer need to repeat moving to another window, scrolling and backing to the former position in order to see a long commit diff.

If the width of Vim window is too narrow (160 characters by default), committia.vim falls back to single column mode, which has 2 windows; edit window and diff window.

For wide window:

double column mode

For narrow window:

single column mode

Hooks

You can hook on opening the windows.

Available hooks are:

  • edit_open: When opening a commit message window, this hook is called from the window.
  • diff_open: When opening a diff window, this hook is called from the window.
  • status_open: When opening a status window, this hook is called from the window. Please note that this hook is not called on single-column mode since it does not have a dedicated window for status.

A vimrc example is below.

" You can get the information about the windows with first argument as a dictionary.
"
"   KEY              VALUE                      AVAILABILITY
"-----------------------------------------------------------------------------------
"   vcs            : vcs type (e.g. 'git')   -> all hooks
"   edit_winnr     : winnr of edit window    -> ditto
"   edit_bufnr     : bufnr of edit window    -> ditto
"   diff_winnr     : winnr of diff window    -> ditto
"   diff_bufnr     : bufnr of diff window    -> ditto
"   status_winnr   : winnr of status window  -> all hooks except for 'diff_open' hook
"   status_bufnr   : bufnr of status window  -> ditto

let g:committia_hooks = {}
function! g:committia_hooks.edit_open(info)
    " Additional settings
    setlocal spell

    " If no commit message, start with insert mode
    if a:info.vcs ==# 'git' && getline(1) ==# ''
        startinsert
    endif

    " Scroll the diff window from insert mode
    " Map <C-n> and <C-p>
    imap <buffer><C-n> <Plug>(committia-scroll-diff-down-half)
    imap <buffer><C-p> <Plug>(committia-scroll-diff-up-half)
endfunction

Mappings

Mappings to scroll diff window for insert mode are available.

Mapping Description
<Plug>(committia-scroll-diff-down-half) Scroll down the diff window by half a screen.
<Plug>(committia-scroll-diff-up-half) Scroll up the diff window by half a screen.
<Plug>(committia-scroll-diff-down-page) Scroll down the diff window by a screen.
<Plug>(committia-scroll-diff-up-page) Scroll up the diff window by a screen.
<Plug>(committia-scroll-diff-down) Scroll down the diff window by one line.
<Plug>(committia-scroll-diff-up) Scroll up the diff window by one line.

Variables

Some variables are available to control the behavior of committia.vim.

g:committia_open_only_vim_starting (default: 1)

If the value is 0, committia.vim always attempts to open committia's buffer when COMMIT_EDITMSG buffer is opened. If you use vim-fugitive, I recommend to set this value to 1.

g:committia_use_singlecolumn (default: 'fallback')

If the value is 'always', committia.vim always employs single column mode.

g:committia_min_window_width (default: 160)

If the width of window is narrower than the value, committia.vim employs single column mode.

g:committia_status_window_opencmd (default: 'belowright split')

Vim command which opens a status window in multi-columns mode.

g:committia_diff_window_opencmd (default: 'botright vsplit')

Vim command which opens a diff window in multi-columns mode.

g:committia_singlecolumn_diff_window_opencmd (default: 'belowright split')

Vim command which opens a diff window in single-column mode.

g:committia_edit_window_width (default: 80)

If committia.vim is in multi-columns mode, specifies the width of the edit window.

g:committia_status_window_min_height (default: 0)

Minimum height of a status window.

Future

  • Cooperate with vim-fugitive.
  • Add more VCS supports
  • Test all features

Contribution

License

Distributed under the MIT license

committia.vim's People

Contributors

anekos avatar haya14busa avatar jaydorsey avatar kleinmann avatar lesguillemets avatar lki avatar ogaken-1 avatar rbialon avatar rhysd avatar seebi avatar st31ny avatar tyru avatar uasi avatar xaizek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

committia.vim's Issues

work with neogit

Hi, does anyone know how to set it up with neogit? Commiting from neogit does not trigger committia.

The content of '__committia_diff__' buffer is going to be '0' using commitia.vim with singleton.vim.

事象

singleton.vimとの併用で__committia_diff__バッファの内容が「0」になる。

原因

gitコマンドに--git-dirオプションが付いていないため、
カレントディレクトリ以下にリポジトリがあることが前提になっている。

解決法

パッと思い付いたのは以下の2つです。

  1. 全てのgitコマンドに--git-dir付けて回る
  2. gitコマンドを呼び出す時一時的にカレントディレクトリを変える

1を選んだ場合、以下のような懸念事項があります。

  • git <git-dir> diff -u --cached みたいに置換文字列を埋め込む
  • そもそも 'diff -u --cached' としてgitコマンドをとっぱらう
    • この場合"git"をなんらかの方法で指定する必要がある。グローバル変数とか
    • コマンドはgit以外にも、環境変数PATHに置いてあるgit以外のgitを指定したいニーズとかあるかもなので、固定より指定できた方がいいかも?

その他の懸念

  • singlecolumnの場合のみでしか確認できていないので、singlecolumnでない場合も検証する(私へのTODO)。

参考リンク

http://lingr.com/room/vim/archives/2014/08/10#message-19901651

Result to deleted all file when HEAD commit is "Merge pull request..."

最終のcommitが"Merge pull request..."の際に上からcommitしますと、mergeコミットにはファイル情報がない?ためか、diffバッファの表示がgit管理化の全てのファイルが削除されていることになるようです。

committia.vimのコードを確認していないので、こちらの設定などの問題でしたら申し訳ないです。

Shown strange status with git worktree

Consider the following situation.

$ mkdir tmp
$ cd tmp
$ git init base
Initialized empty Git repository in /home/thinca/tmp/base/.git/

$ cd base
$ touch README.md
$ git add README.md
$ git commit -m init
[master (root-commit) 6e8b9c5] init
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md

$ git worktree add ../sub
Preparing ../sub (identifier sub)
HEAD is now at 6e8b9c5 init

$ cd ../sub
$ touch new.vim
$ git add new.vim
$ git commit

committia.vim shows the following in status window.

# On branch sub
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   new.vim
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    README.md
#       deleted:    new.vim
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       sub/
#

This is strange. I want to use committia.vim with git worktree.

committia doesn't overwrite user-supplied textwidth

I have textwidth specified in my .vimrc for normal operation. However, I'd like committia to set the textwidth appropriately to 72 characters (or whatever it is, I forget) when I'm editing a commit message. Is there a way to do this?

You can see my entire vimrc here in case it should already be working that way and it's something with my setup that's wonky.

invalid range error

I get this error whenever I try to open up a commit.

Error detected while processing function committia#open[21]..committia#open_multicolumn[14]..<SNR>262_remove_all_contents_except_for_commit_message:                                                                 
line    4:                                                                                                                                                                                                           
E16: Invalid range: silent 11,$ delete _                                                                                                                                                                             

E21: Cannot make changes, 'modifiable' is off

I have been getting this error after upgrading recently:

"~/.git/COMMIT_EDITMSG" 106L, 1744C
Error detected while processing function committia#open..<SNR>225_open_singlecolumn..<SNR>225_open_diff_window..<SNR>225_open_window:
line    8:
Error detected while processing function committia#open..<SNR>225_open_multicolumn..<SNR>225_remove_all_contents_except_for_commit_message:
line    4:
E21: Cannot make changes, 'modifiable' is off
Press ENTER or type command to continue

Thanks. 👼

git commit -a not working properly for diff view

Due to committia using --cached for the git diff command when doing a commit -a there is no diff result that will be displayed. Ideally committia should parse the text in the COMMIT_EDITMSG to figure out the files. Due to git using multiple languages it should probably have some way to configure what to look for, best is probably # : and then have a list of possible words there.

More control over single/multicolumn mode

(1) Is there a way to manually toggle between single/multicolumn mode? E.g., when the Vim window first opens up, it might be narrow, but I might later expand the Vim window and then would like to switch to multicolumn mode. Or vice versa.

(2) Is there a way to force committia to open in one one mode or the other, regardless of the width of the window?

Commitia didn't show up on rebase (rewrite)

Hello,
I use the committia plugin happily but find some case where it did not show up,
in particular when I rebase a branch like rewrite command.

I use Debian SID, and Vim 7.4 / Git 2.1.4.

I can make more test / give additional information if needed.

Regards,
Guillaume.

Does not work for vcsh or fake bare git technique

I am using vcsh which allows me to version control my dotfiles with git.
vcsh works by (taking a line from its manpage)

vcsh is using a technique called fake bare Git repositories, keeping $GIT_DIR in a different directory from $GIT_WORK_TREE which is pointed to $HOME.

So if I want to commit a change for a vcsh repo, I enter a vcsh environment then which have a different $GIT_DIR compared to $GIT_WORK_TREE for that repo.

committia chokes on this $GIT_DIR as shown in the following error upon committing.

Error detected while processing function committia#open[14]..<SNR>65_open_multicolumn[3]..<SNR>65_open_diff_window[1]..<SN
R>65_open_window[1]..committia#git#diff[1]..<SNR>66_search_git_dir_and_work_tree:
line   24:
E605: Exception not caught: committia: git: Failed to get git-dir from $GIT_DIR
Error detected while processing function committia#open:
line   14:
E171: Missing :endif
Error detected while processing function dein#autoload#_on_default_event[23]..<SNR>47_source_events:
line   12:
E171: Missing :endif

Can committia be adapted to support fake git repo technique please?

Configure diff tool?

I use diff-so-fancy as my command line diff tool, configured with my .gitconfig. I'd like the ability to configure what program to call for generating diffs, if possible.

Characters are inserted in the edit window when using startinsert in the edit_open hook

EDIT: Fixed by removing the mapping: inoremap <esc> <nop>.

The title says it pretty much I think, but here are the details:

Any ideas on what's happening are appreciated. See below for my vim version.

Regards,
Yann

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 22 2015 07:29:11)
Included patches: 1-711
Compiled by inside
Big version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   -perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         -profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/home/inside/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -fno-strength-reduce -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L.  -rdynamic -Wl,-export-dynamic  -L/usr/local/lib -Wl,--as-needed -o vim        -lm -ltinfo -lnsl   -ldl  -L/usr/lib -llua5.1  -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions   -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib

How to trigger the committia

Hi friend~

I saw in README that type git commit will show the commit buffer?

But seems I can't. And I also tried :Commit<CR>

I also see there's <Plug> to map to a shortcut, but seem there's no one to map to trigger the commit buffer?

support MERGE_MSG

i am currently using on open MERGE_MSG via

autocmd dkocommittia
      \ BufNewFile,BufReadPost **/{MERGE_,TAG_EDIT,}MSG
      \ call committia#open('git')

It opens successfully but does not close committia on :wq/ZZ

Does not work with amend

Committia is not triggered for git commit --amend... I also did not find a config option for that. (Moreover, I think no config option would be necessary...)

proper handling of "git commit --amend"

When calling "git commit --amend" the commit message window stays empty and does not show the former commit message for editing. Moreover, there is no way to abort the commit-amend, so the history is rewritten in any case.
Thanks for the great plugin and for working on this minor issue!
Best,
Maximilian

Definitions for <Plug>(committia-scroll-diff-down) / up seem to be wrong

Hi, thanks for the brilliant plugin I depend on daily.

There are two mappings not mentioned in the README, which should scroll one line in diff buffer, defined here

inoremap <silent> <Plug>(committia-scroll-diff-down) <C-o>:call committia#scroll_window('diff', 'j')<CR>
inoremap <silent> <Plug>(committia-scroll-diff-up) <C-o>:call committia#scroll_window('diff', 'k')<CR>

and here.

nnoremap <silent> <Plug>(committia-scroll-diff-down) :<C-u>call committia#scroll_window('diff', 'j')<CR>
nnoremap <silent> <Plug>(committia-scroll-diff-up) :<C-u>call committia#scroll_window('diff', 'k')<CR>

Sadly using these mappings results in E21: Cannot make changes, 'modifiable' is off, because calling committia#scroll_window('diff', 'j'), resolved by this function,

function! s:get_map_of(cmd) abort
return eval('"\<' . a:cmd . '>"')
endfunction

ends up calling <j> (:help <{motion}), if I understand correctly.

I think the solution here is using 'C-e' and 'C-y' instead of 'j' and 'k' in the mappings: it solves the error, and also seems more sensible as the purpose is scrolling, not moving the cursor in the diff.

If you are ok with the changes and need a pull-req, I'll make one. I just thought the changes are too small for a pr.

Can't be lazy loaded with neobundle

I've created a neobundle ticket here with an example config showing that committia doesn't work/do anything if lazy loaded on filetype. Do you have any insight as to why this might be?

Work with vim-fugitive

So are you saying that I can use this with vim-fugitive? I have tried setting let g:committia_open_only_vim_starting = 1 but when I do :Gcommit it brings up the default committing window

image

open_singlecolumn error

Just installed this for the first time.

I get these errors:

Error detected while processing function committia#open..<SNR>62_open_singlecolumn:
line   17:
E216: No such group or event: QuitPre COMMIT_EDITMSG call s:callback_on_window_closed()

I don't know where to begin to investigate

Closing diff

When I close the open diff, it does not take me back to what file was open. Am I missing something? I am using vim-fugitive. Could this be related to #28

Doesn't seem to work on neovim

Hi,

I'm trying to get it working on neovim but it just hangs.

This is my init.vim:

call plug#begin('~/.vim/plugged')
Plug 'rhysd/committia.vim'
call plug#end()

Thanks in advance.

Another window with (configurable) git log

I would like to have another window which present last few commits. Something like git log. Ideally it would take arguments and pass it to git log. Alternatively it could just exec system command and present its contents in the window.

Is this possible to do?
As a workaround I was thinking about opening another window in a hook callback. Which one would be best to use? Maybe it would be useful to add another one like: commitia_loaded?

Error after updating commitia

commitia worked fine until I updated the plugin yesterday.
When I type "git commit", I get an error :

Error detected while processing function committia#open[14]..<SNR>81_open_multicolumn[10]..<SNR>81_open_status_window[1]..<SNR>81_open_window[1]..committia#git#status:
line   18:
E605: Exception not caught: committia: git: Failed to execute status command: fatal: This operation must be run in a work tree^@
Error detected while processing function committia#open:
line   14:
E171: Missing :endif

This seems related to the changes introduced with #31 .

Error when amending commit

"committia: git: Failed to execute command" error when amending the commit.

The error occurs in the committia#git#diff() method, where the s:execute_git(g:committia#git#diff_cmd) is not wrapped with a try/catch statement, as it has already been done in committia#git#status().

results in:
[on](error: unable to load config blob object '9aaef36301288211cb852e26750493c74906fb3a'^@diff)

Please, wrap the s:execute_git(g:committia#git#diff_cmd) in committia#git#diff() in the
committia.vim/autoload/committia/git.vim:162 with the try/catch statement or resolve the issue.

Initial merge message is dropped

Git provides first line for a merge message saying Merge branch 'branch-name-here'. In addition to that invoking git merge with --log=999999 argument adds list of commits that are being merged into destination branch.

committia doesn't preserve this information. Is there a way to keep it? It pretty much needs to work for merges the same was as it already does for git commit --amend.

Errors / Crash

after running git merge development or any branch

"~/dev/flight/.git/MERGE_MSG" 7L, 292C Error detected while processing function committia#open..<SNR>162_open_multicolumn..<SNR>162_open_status_window..<SNR>162_open_window..committia#git#status: line 8: E605: Exception not caught: committia: git: Failed to execute status command: fatal: The empty string is not a valid path^@ Error detected while processing function committia#open: line 14: E171: Missing :endif Press ENTER or type command to continue

What can I do to help debug. I love this plugin.

All files are shown as deleted

How to reproduce:

  1. git clone https://github.com/vifm/vifm.git
  2. cd vifm
  3. echo a >> AUTHORS
  4. git commit -a

I suspect that worktree was determined incorrectly, this would explain the effect.

Add the ability to customize left window width

The width of the left panel is a fixed width of 80, here

It would be nice/useful if we could customize this, with
the default set to 80 to maintain behavior

I wrap my commit messages at 80 chars, but I also have some things
in the gutter that always show which leads to the commit message
window horizontally scrolling

I've hard-coded this value locally and it works great but it would
be a nice configuration option, I think. I haven't worked with vimscript
before but I'll try and create a PR for this (someone else feel free to submit
it if you know how to do it)

Edit: I created a PR for this and linked it. I've been using it for a week now and
it's been working great

Git commit templete is removed

~/.gitconfig

[commit]
	template = ~/.git_commit_template

~/.git_commit_template



# Commit Rules
# ...

The content of ~/.git_commit_template should be appear in edit window, but it is removed.
This issue is appeared from #38.

Window navigation using mappings

I currently have the following in my ~/.config/nvim/init.vim:

nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

For easier window navigation. For what some reason these mappings do not work in the committia plugin. I have to use full keystrokes (e.g. <C-w>h) to move between the edit, diff and status windows. Is there a reason why these mappings don't work in committia?

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.