Home

Awesome

Disclaimer: This plugin has been tested with neovim so vim support is not garanteed. Feel free to open a PR if you want to contribute !

Motivation

OneStatus is an interface that helps you interact with your tmux.<br> One of my goal with it was to get rid of vim's redundant statusline and instead use tmux's.

Much better !

onestatus

Requirements

If you just want to quickly use the plugin :

If you want to play with the API :

Usage

Since v0.2.0 you can very easily customize your statusline via a onestatus.json file that you put in your config folder ($HOME for vim and $HOME/.config/nvim for nvim).<br> If you want another path you can override g:onestatus_config_path<br> Here's an example of configuration file that you can copy

{
  "status-right": [
    { "fg": "#ffd167", "bg": "default", "label": "" },
    { "fg": "#218380", "bg": "#ffd167", "labelFunc": "s:getCWD" },
    { "fg": "#218380", "bg": "#ffd167", "label": "" },
    { "fg": "#fcfcfc", "bg": "#218380", "labelFunc": "s:getHead" }
  ],
  "status-left": [
    { "fg": "default", "bg": "default", "labelFunc": "s:getFileName" }
  ],
  "status-style": "s:getDefaultColor",
  "window-status-style": [
    { "fg": "#6c757d", "bg": "default", "isStyleOnly": true }
  ],
  "window-status-current-style": [
    { "fg": "#ffd167", "bg": "default", "isStyleOnly": true }
  ]
}

Which will give your current git head and the name of the focused file just like shown in the screenshot

Then you can use the full power of onestatus like in this example

if !empty($TMUX)
    au BufEnter,BufLeave,FocusGained * :OneStatus
    au VimLeave * :OneStatusClean
    set noshowmode noruler
    set laststatus=0
endif

For OneStatus you can use BufEnter and use WinEnter or some other events but I found it sufficient for my everyday use. OneStatusClean on the other end is optional and is a convinient way to clean your tmux status bar when you exit your current vim process.

The Internals

The plugin's implementation is simple, it runs tmux source 'the content of your json file', everything else is just deserialization and formatting.

Let us write an example that displays the current file extension on the left. In your onestatus.json

  "status-left": [
    { "fg": "default", "bg": "default", "labelFunc": "CurrentFileExtension" }
  ]

And make a function in your $MYVIMRC to return the file type.

fun CurrentFileExtension()
    return expand('%:e')
endfun

The labelFunc attribute takes a function name and sends its output to tmux

tmux set-option status-left -g fg=default bg=default "{the output of function}" 

The API

You must have noticed that the json file has these types of attributes

and has this form

{
  option: attributes
}

In order to give a maximum amount of flexibility, attributes can either be an array of attribute of this shape:

{
  "fg": optional tmux color (will default to tmux's default),
  "bg": optional tmux color (will default to tmux's default),
  "label": the text to be displayed if your option takes a string as an argument (ex: status-left ),
  "labelFunc": you can dynamicaly display labels by using one of the functions exposed by onestatus (will take precedance over "label"),
  "isStyleOnly": a boolean that has to be set to true if your option does not display a label
}

NB1: You can also use also use a onestatus function to dynamically generate your attributes. Currently only s:getDefaultColor is supported.<br> NB2: You can call any global function in labelFunc. Try putting directly the name of a function of your own !

Exposed functions

labelFunc:

attributes:

Exposed global variables

For even more customization

OneStatus also provides a helper to send more straightforward commands to tmux

  call onestatus#build([
        \{'command' : 'set-option status-justify centre'},
        \{'command': 'set-option status-right-length 30'},
        \{'command': 'set-option status-left-length 50'},
        \])

TODO

License

Distributed under the same terms as Vim itself. See the vim license.