Async git branch in neovim

builds.sr.ht via public-inbox

3 months ago

Greg V via public-inbox

3 months ago

#Neovim Async Git Status

Only works on Linux

This project is somewhat of an experiment into writing vim plugins in Rust. I wrote this plugin because I wanted to have my git branch in my statusline without having to run git over and over again. And without using a large git plugin.

So I wrote this plugin. It's fairly simple, I listens for modifications to .git/HEAD, then sets g:async_git_status to the branch name. So you can just include g:async_git_status in your status line and call it a day.

#How to use

  • Install the plugin using your preferred method
  • Either download the compiled binary and put it you path or compile it yourself
  • Put g:async_git_status in your statusline.
  • Profit!

#Technical details

I wanted to use async Rust so I decided to forgo the existing neovim rpc Rust libraries. I found a library called rmp-futures which provided a nice async msgpack-rpc client. Then I used smol as my runtime and inotify to detect file system changes.