all repos — dotfiles @ f9c9735ee6e2e199e5c35a6e70027bd438164aa8

my *nix dotfiles

Add git clean and dirty symbols to statusline
Anirudh Oppiliappan x@icyphox.sh
Sun, 06 Jun 2021 11:16:21 +0530
commit

f9c9735ee6e2e199e5c35a6e70027bd438164aa8

parent

b7bc040910400990bc505e0b4008a202ed33b3d6

2 files changed, 20 insertions(+), 5 deletions(-)

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

@@ -23,7 +23,7 @@ require('statusline')

-- lsp setup -- require('lsp.yaml') shits too noisy -require('lsp.lua') +-- require('lsp.lua') it's horrible require('lsp.python') require('lsp.go')
M config/nvim/lua/statusline.luaconfig/nvim/lua/statusline.lua

@@ -4,14 +4,19 @@ [[

hi PrimaryBlock ctermfg=06 ctermbg=00 hi SecondaryBlock ctermfg=07 ctermbg=00 hi Blanks ctermfg=08 ctermbg=00 + hi GitClean ctermfg=02 ctermbg=00 + hi GitDirty ctermfg=01 ctermbg=00 ]], false) -local function clean_or_dirty() +local clean = '•' +local dirty = '×' + +local function is_clean() local handle = io.popen('git status --porcelain 2> /dev/null') local status = handle:read('*a') - if status ~= '' then return '*' end - return status + if status ~= '' then return false end + return true end local function git_branch()

@@ -19,19 +24,29 @@ local handle = io.popen('git branch --show-current 2> /dev/null')

local branch = handle:read('*a'):gsub('\n', '') local rc = { handle:close() } if rc[1] then - local out = ' ' .. branch .. clean_or_dirty() + local out = ' ' .. branch return out else return '' end end +local function git_sym() + if is_clean() then + return ' %#GitClean#' .. clean + else + return ' %#GitDirty#' .. dirty + end +end + local stl = { '%#PrimaryBlock#', '%f', '%#Blanks#', '%m', '%#SecondaryBlock#', + git_branch(), + git_sym(), '%=', '%#SecondaryBlock#', '%l,%c ',