nvim: Set statusline via augroup
Anirudh Oppiliappan x@icyphox.sh
Thu, 08 Jul 2021 10:45:16 +0530
2 files changed,
12 insertions(+),
5 deletions(-)
M
config/nvim/lua/statusline/git.lua
→
config/nvim/lua/statusline/git.lua
@@ -22,7 +22,7 @@ local HEAD = f_head:read()
f_head:close() local branch = HEAD:match('ref: refs/heads/(.+)$') if branch then git_branch = branch - else git_branch = HEAD:sub(1,6) end + else git_branch = HEAD:sub(1,7) end end return nil end
M
config/nvim/lua/statusline/line.lua
→
config/nvim/lua/statusline/line.lua
@@ -1,11 +1,12 @@
local git = require('statusline.git') +local utils = require('utils') -- set highlights for statusline sections vim.api.nvim_exec( [[ - hi PrimaryBlock ctermfg=06 ctermbg=00 - hi SecondaryBlock ctermfg=07 ctermbg=00 - hi Blanks ctermfg=08 ctermbg=00 + 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)@@ -32,4 +33,10 @@ '%#PrimaryBlock#',
'%{&filetype}', } -vim.opt_global.statusline = table.concat(stl) +_G.statusline = function() + return table.concat(stl) +end + +utils.create_augroup({ + { 'WinEnter,BufEnter', '*', 'setlocal', 'statusline=%!v:lua.statusline()' }, +}, 'Statusline')