GithubHelp home page GithubHelp logo

itchyny / vim-gitbranch Goto Github PK

View Code? Open in Web Editor NEW
200.0 6.0 17.0 7 KB

Provides the branch name of the current git repository

License: MIT License

Vim Script 100.00%
vim vim-plugins vim-scripts

vim-gitbranch's Introduction

vim-gitbranch

Usage

This plugin provides a function which returns the name of the git branch.

:echo gitbranch#name()

You can use this function to integrate with statusline plugins.

For example, in order to show git branch using lightline.vim, configure as follows.

let g:lightline = {
      \ 'active': {
      \   'left': [ [ 'mode', 'paste' ],
      \             [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
      \ },
      \ 'component_function': {
      \   'gitbranch': 'gitbranch#name'
      \ },
      \ }

See the README.md of lightline for further details.

Installation

Install with your favorite plugin manager.

Author

itchyny (https://github.com/itchyny)

License

This software is released under the MIT License, see LICENSE.

vim-gitbranch's People

Contributors

itchyny 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

vim-gitbranch's Issues

Add example how to use gitbranach with airline

Maybe it would be good for the uninformed users to add an example to the readme how to use gitbranch with airline. Here is how I do it:

let g:airline_section_b = '%{gitbranch#name()}'

This is good if one doesn't want to use a heavy plugin like fugitive just to show the current branch in the airline.

Unlocking the mysteries of the vim function for the uninitiated ...

Hello itchyny,

Thank you for your time and your advice.

Would you be so kind as to give a brief explanation of how to implement the function in your vim gitbranch plugin, I am relatively new to the programming world, also due to my current use of the vundle plugin to install vim scripts I am consequently lacking in experience in this area.

How can I call this function, is is possible to make the git branch name appear in lightline?

Thank you for your kind consideration and should you see fit; Any consequent advice.

unwanted changed directory

Hi

something weird.

In .vimrc, I installed the plugin with

Plug 'itchyny/vim-gitbranch' 

and I configured it with:

let g:lightline = {
      \ 'active': {
      \   'left': [ [ 'mode', 'paste' ],
      \             [ 'readonly', 'filename', 'modified' ] ],
      \   'right': [ [ 'lineinfo' ],
      \              [ 'percent' ],
      \              [ 'fileformat', 'fileencoding', 'filetype', 'gitbranch' ] ]
      \ },
      \ 'component_function': {
      \   'gitbranch': 'gitbranch#name'
      \ },
      \ }

All fine until I realized this:

$ cd /home/giorgio/cpiabot
$ ls
interpreter.js naifSetup.js lib/

$ vi interpreter.js 
:pwd
/home/giorgio

???
No, interpreter.js directory is /home/giorgio/cpiabot and is not /home/giorgio
Why the local directory is changed in vim?

$ vi naifSetup.js 
:pwd
/home/giorgio/cpiabot

That's unexpected (and a bug I presume). Just for this specific file "interpreter.js" the directory is changed to the parent directory. The beehaviour is "wrong". because Interpreter.js and naifSetup.js are in the same directory.

I'm confused.
I solved the issue disabling the plugin :(

giorgio

Branch of parent instead of submodule is displayed when editing `COMMIT_EDITMSG`

It looks like something similar has been brought up before (#2), but this is slightly different. When writing a commit message in a submodule, the parent's branch is displayed. This seems to be due to COMMIT_EDITMSG of a submodule existing in ../.git/modules/<submodule name>. It can be confusing to write a commit message when in a submodule and see the parent's branch.

According to :PlugSnapshot, I'm on commit 8118dc1

Hey, man

It's better to write a readme.md file

Request: adding a property if the file is currently checked

Hello,

I was trying to write my own light plugin, but yours seem to be exactly what I had in mind!

Would it be possible to just add the status of the file as #info property?

I would suggest to keep it simple (ex: find if the file is excluded using .gitignore, find if the file modified or staged using .git/index) to keep your excellent plugin very light.

Thanks!

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.