Skip to content

Latest commit

History

425 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

hackline.vim

hackline.vim 'hacks' your statusline so you don't have to.

An opinionated minimalistic statusline plugin for Vim and Neovim. It's lightweight, loads in no-time, still quite fully featured, with some features through optional plugins.

  • No prerequisites like patched icon fonts. It has simple options for changing separators.
  • Supports any colorscheme by being a normal Vim statusline. Highlight groups can be changed per mode, but changes the entire statusline for its context.
  • Mode flag when not normal mode. Minimal by default.
  • Responsive design adjusts and truncates on priority for smaller widths.
  • All buffers uses same settings. No bloat with specific buffer/file type targeting. hackline.vim is just setup as dynamically as possible in how items are sorted and truncated, but still keeping them nice and logical for main buffers.

Integrations:

  • LSP flag if connected to buffer. Supports Neovim's LSP. And vim-lsp (only simple flag if active LSP in buffer).
  • Git info is bring-your-own function (from a plugin usually), or falls back to the built-in support for one of the following plugins (though maintenance of plugin support can not be ensured) connected to in order: vim-fugitive, vim-gitbranch. VGit can supplement the two latter with Git status. Gitsigns.nvim can provide status summary numbers.

Why another statusline plugin? Hackline.vim needs no customizing or no patched icon font. It’s not for the shallow, but hacked to be the lightest statusline plugin for pragmatic vimmers. In all honesty, the minimalism and barebones Vim features hackline.vim uses has drawbacks, but that’s worked around by hackline‘s design choices and are not really noticeable. Except the opinionated nature. The advantage is load time. Also, hackline.vim is generally fast.

Installation

For lazy.nvim (Neovim Lua):

{
"jssteinberg/hackline.vim",
dependencies="itchyny/vim-gitbranch",
config=function()
-- to disable cmdline mode flagvim.opt.showmode=falseend,
}
More examples
-- packer example (Neovim Lua)use {
"jssteinberg/hackline.vim",
requires= { "itchyny/vim-gitbranch" },
config=function()
-- disable command line mode flagvim.opt.showmode=falseend
}
" minpac (vimscript)callminpac#add('jssteinberg/hackline.vim')

hackline.vim requires Neovim or Vim version > 8.2.1[something]---basically a newer version that supports re-evaluating expression results as a statusline format string. For Mac, you can use Vim from Homebrew.

hackline.vim is tested on Neovim and Vim compiled with lua (but should work without Lua).

Options

Global variables for simple customization. Default values:

" Options:letg:hackline_laststatus=2" corresponds to `laststatus`letg:hackline_aggressive=0" or 1 for aggressive rerendering of statusline" Items:letg:hackline_mode=1" To activate mode flags and not deactivating `showmode`" Separators and signs:letg:hackline_separators= #{ l:' / ', r: ' / ' }
" for vgitletg:hackline_git_signs= #{
\added: "+",
\removed: "-",
\changed: "~",
\}

Further customize

For full customization define your global Hackline function to customize.

function!Hackline(status) abortreturn""endfunction

Hackline provided functions

Vimscript:

  • hackline#ui#dir#info() -- params min_breakpoint = "lg", max_breakpoint = "xl" (possible values: "md" | "lg" | "xl") -- returns current buffer relative directory, shortened between breakpoint, empty below min_breakpoint.
  • hackline#ui#git#info() -- params append = "*" (string will be appended left; list will append values left then right), display_breakpoint = "md" (possible display_breakpoint values: "md" | "lg" | "xl") -- returns git info from gitsigns, fugitive, vim-branch, or vgit.
  • hackline#ui#tab#info() -- params style = "max" (use "min" to truncate info) -- returns tabs or spaces, and their size.
  • hackline#ui#nvim_lsp#info() -- params append_left = " ", label = "LSP", preped_label = " ", seperator_servers = " ", prepend_right = " ", truncation_breakpoint = "xl" (possible truncation_breakpoint values: "md" | "lg" | "xl") -- returns LSP connected servers by name/length (above/below breakpoint)
  • Also see :help statusline, https://jdhao.github.io/2019/11/03/vim_custom_statusline

Breakpoints can be redefined with g:hackline_breakpoints. E.g.:

" defaultletg:hackline_breakpoints= #{
md: 70, lg: 90, xl:130
}

Number values refer to winwidth(0). Note that breakpoints are ignored if &laststatus == 3.

For vim-lsp there's a buffer local variable that tells if LSP is active:

ifget(b:, "hackline_use_vim_lsp", "0")
" LSP is active for bufferendif
Full example
function!StatuslineModeLabels(sep_l ="", sep_r ="") abortifmode() =="i" | return"I"elseifmode() =="c" | return"C"elseifmode() =="t" | return"T"elseifmode() =="r" | return"R"elseifmode() =="s" | return"S"else | return"V"endifendfunctionfunction!Hackline(status) abortletl:active=a:status" separator labelletl:sep_l=""" separator sectionsletl:sep= #{l:" -- ", r: " / "}
" seperator secondaryletl:sep_s= #{l:"" , r: ""}
" separator itemsletl:sep_i= #{l:"" , r: ""}
" Statusline Start" ----------------letl:line=""" set statusline default colorletl:line.=l:active ? "%#StatusLine#" : "%#StatusLineNC#"" set some mode colorsletl:line.=l:active&&matchstr(mode(), "[itr]") !="" ? "%#IncSearch#" : """ Start spacingletl:line.=""ifl:active&&matchstr(mode(), "[nc]") ==""" (not normal or command mode)letl:line.="%1(%{StatuslineModeLabels()}%)"else" modified flag, fixed width 1letl:line.="%1(%M%)"endif" spacingletl:line.=""" buffern numberletl:line.="%(:b%{bufnr()}%)"" filetypeletl:line.="%(" . l:sep_i.l . "%{&filetype}%)"letl:line.=l:sep.l" file pathletl:line.="%(%{hackline#ui#dir#info()}/%)"" filenameletl:line.="%(%t%)"letl:line.=l:sep.l" Cursor positionletl:line.="l-%l/%L c-%c"" Statusline END" --------------letl:line.="%=" . l:sep_s.r" truncation pointletl:line.="%<"" vim lspifl:active&&get(b:, "hackline_use_vim_lsp", "0")
letl:line.="LSP" . l:sep.rendif" nvim LSPifl:active&&has("nvim")
letl:line.=hackline#ui#nvim_lsp#info("", "LSP", l:sep_l, l:sep_i.r, l:sep.r)
endif" spelllangifl:active&& &spell==1letl:line.="%(spl=%{&spelllang}" . l:sep_i.r . "%)"endif" tabs/spacesletl:line.="%(%{hackline#ui#tab#info('min')}" . l:sep_i.r . "%)"" encodingletl:line.="%(%{hackline#fileencoding#info()}%)"" formatletl:line.="%(" . l:sep_i.r . "%{&fileformat}%)"" CWDiflen(getcwd(0)) > 1letl:line.=l:sep.rletl:line.="%(%{split(getcwd(0), '/')[-1]}%)"" Gitletl:line.=hackline#ui#git#info(" *")
endif" End spacingletl:line.=""returnl:lineendfunction

About development

This is v4.0.0-0.

Originally a fork of the lightweight skyline.vim which has a different look.

Future

  • Highlight group for unsaved
  • Add Vim help documentation.
  • Visual mode contextual information such column/line range, words in visual selection, etc.
  • Nvim LSP number of buffer warning/errors?

About

No description or website provided.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages