all repos — dotfiles @ 0e527c5e6a5124aa303d423910a614858efe4b0c

my *nix dotfiles

nvim: Clean up statusline
Anirudh Oppiliappan x@icyphox.sh
Mon, 01 Mar 2021 11:36:26 +0530
commit

0e527c5e6a5124aa303d423910a614858efe4b0c

parent

024ecf3c818ea7363dd8900fee3eef298fa294f2

2 files changed, 22 insertions(+), 36 deletions(-)

jump to
M config/nvim/lua/settings.luaconfig/nvim/lua/settings.lua

@@ -26,7 +26,7 @@ o.wildmenu = true

o.tabstop = 4 o.shiftwidth = 4 o.softtabstop = 4 -o.showmode = false +o.showmode = true o.listchars='tab:│ ,nbsp:␣,trail:·,extends:>,precedes:<' o.hidden = true o.wildignore = [[
M config/nvim/lua/statusline.luaconfig/nvim/lua/statusline.lua

@@ -1,47 +1,33 @@

-local mode_map = { - ['n'] = 'normal ', - ['no'] = 'n·operator pending ', - ['v'] = 'visual ', - ['V'] = 'v·line ', - [''] = 'v·block ', - ['s'] = 'select ', - ['S'] = 's·line ', - [''] = 's·block ', - ['i'] = 'insert ', - ['R'] = 'replace ', - ['Rv'] = 'v·replace ', - ['c'] = 'command ', - ['cv'] = 'vim ex ', - ['ce'] = 'ex ', - ['r'] = 'prompt ', - ['rm'] = 'more ', - ['r?'] = 'confirm ', - ['!'] = 'shell ', - ['t'] = 'terminal ' -} - -local function mode() - local m = vim.api.nvim_get_mode().mode - if mode_map[m] == nil then return m end - return mode_map[m] -end - -- set highlights for statusline sections vim.api.nvim_exec( [[ - hi PrimaryBlock ctermfg=06 ctermbg=00 - hi SecondaryBlock ctermfg=08 ctermbg=00 - hi Blanks ctermfg=07 ctermbg=00 + hi PrimaryBlock ctermfg=06 ctermbg=00 + hi SecondaryBlock ctermfg=07 ctermbg=00 + hi Blanks ctermfg=08 ctermbg=00 ]], false) +local function git_branch() + local handle = io.popen('git branch --show-current') + local branch = handle:read('*a'):gsub('\n', '') + handle:close() + return branch +end + +local function clean_or_dirty() + local handle = io.popen('git status --porcelain') + local status = handle:read('*a') + + if status ~= '' then return '*' end + return status +end local stl = { '%#PrimaryBlock#', - mode(), - '%#SecondaryBlock#', + '%f', '%#Blanks#', - '%f', '%m', + '%#SecondaryBlock#', + ' ' .. '(git_branch())' .. clean_or_dirty(), '%=', '%#SecondaryBlock#', '%l,%c ',

@@ -49,4 +35,4 @@ '%#PrimaryBlock#',

'%{&filetype}', } -vim.o.statusline = table.concat(stl) +vim.wo.statusline = table.concat(stl)