All Projects → narajaon → onestatus

narajaon / onestatus

Licence: other
an api to customize tmux from vim

Programming Languages

Vim Script
2826 projects

Projects that are alternatives of or similar to onestatus

Tmux Complete.vim
Vim plugin for insert mode completion of words in adjacent tmux panes
Stars: ✭ 447 (+445.12%)
Mutual labels:  tmux, vim-plugin, neovim-plugin
nvim configration
Neovim diy develop enviroment.This project integrates neovim tmux zsh and some very useful plugs of them including YouCompleteMe FZF auto pairs nerdtree ncm2 and so on.
Stars: ✭ 22 (-73.17%)
Mutual labels:  tmux, powerline
skim.vim
vim support for skim
Stars: ✭ 127 (+54.88%)
Mutual labels:  vim-plugin, neovim-plugin
tmux.nvim
tmux integration for nvim features pane movement and resizing from within nvim.
Stars: ✭ 299 (+264.63%)
Mutual labels:  tmux, neovim-plugin
cmp-tmux
Tmux completion source for nvim-cmp and nvim-compe
Stars: ✭ 98 (+19.51%)
Mutual labels:  tmux, neovim-plugin
vim-readme-viewer
📖 Viewing plugin's README easily like vim help
Stars: ✭ 26 (-68.29%)
Mutual labels:  vim-plugin, neovim-plugin
vim-lineletters
because letters are easier to touch type than numbers
Stars: ✭ 38 (-53.66%)
Mutual labels:  vim-plugin, neovim-plugin
Vimux
easily interact with tmux from vim
Stars: ✭ 1,980 (+2314.63%)
Mutual labels:  tmux, vim-plugin
auto-pairs
Vim plugin, insert or delete brackets, parentheses, and quotes in pairs
Stars: ✭ 109 (+32.93%)
Mutual labels:  vim-plugin, neovim-plugin
42header.vim
Add and update the 42 comment header at the top of your files
Stars: ✭ 15 (-81.71%)
Mutual labels:  vim-plugin, neovim-plugin
vim-counterpoint
Cycle between file counterparts in vim or neovim.
Stars: ✭ 12 (-85.37%)
Mutual labels:  vim-plugin, neovim-plugin
qf helper.nvim
A collection of improvements for the quickfix buffer
Stars: ✭ 70 (-14.63%)
Mutual labels:  vim-plugin, neovim-plugin
.tmux
🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
Stars: ✭ 15,594 (+18917.07%)
Mutual labels:  tmux, powerline
stable-windows
Keeps vim windows stable on layout changes
Stars: ✭ 41 (-50%)
Mutual labels:  vim-plugin, neovim-plugin
Powerline
Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome and Qtile.
Stars: ✭ 12,989 (+15740.24%)
Mutual labels:  tmux, powerline
beacon.nvim
Whenever cursor jumps some distance or moves between windows, it will flash so you can see where it is
Stars: ✭ 217 (+164.63%)
Mutual labels:  vim-plugin, neovim-plugin
vim-tips-wiki
1500+ tips downloaded from Vim Tips Wiki, parsed and formatted to look and work like native Vim help files
Stars: ✭ 56 (-31.71%)
Mutual labels:  vim-plugin, neovim-plugin
Rainbarf
it's like Rainmeter, but for CLI!
Stars: ✭ 1,087 (+1225.61%)
Mutual labels:  tmux, powerline
code runner.nvim
Neovim plugin.The best code runner you could have, it is like the one in vscode but with super powers, it manages projects like in intellij but without being slow
Stars: ✭ 234 (+185.37%)
Mutual labels:  vim-plugin, neovim-plugin
denops-docker.vim
Manage Docker in Vim/Neovim
Stars: ✭ 48 (-41.46%)
Mutual labels:  vim-plugin, neovim-plugin

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.
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 :

  • make sure to disable the default config by setting let g:onestatus_default_layout = 0
  • create your own personal onestatus.json Have fun !

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).
If you want another path you can override g:onestatus_config_path
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

  • tmux option: an option that will be sent to tmux, you can learn more about them in man tmux
  • tmux color: can be any color format supported by tmux (ex: #ffd167)
  • onestatus' builtin function: they begin with s: like s:getFileName

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.
NB2: You can call any global function in labelFunc. Try putting directly the name of a function of your own !

Exposed functions

labelFunc:

  • s:getCWD
  • s:getFileName
  • s:getHead

attributes:

  • s:getDefaultColor (it will make your statusline's background match with your vim's theme)

Exposed global variables

  • g:onestatus_default_layout: can be 0 or 1. Defaults to 1 Setting it to 0 prevents onestatus from applying some arbitrary layout style. Useful when you want to fully customize your statusline.
  • g:onestatus_config_path: a path string It contains the default path where onestatus will look for a onestatus.json. You can override it if you want to use a custom path.
  • g:onestatus_right_length: the max length of your right status. Defaults to 50
  • g:onestatus_left_length: the max length of your left status. Defaults to 50

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

  • Write a proper :h
  • Add more default templates
  • Improve default template theme integration
  • Add more builtin functions
  • Setup automated tests on develop branch

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].