diff options
author | ben <ben@nagy.contact> | 2025-01-08 15:45:00 -0800 |
---|---|---|
committer | ben <ben@nagy.contact> | 2025-01-08 15:45:00 -0800 |
commit | bb2e30b412c23b76ae876e792398f4926467d962 (patch) | |
tree | 4f50f94b7bf50103a61ddbab8a0a30f753918b21 /nvim/lua/core/statusline.lua | |
parent | ec2cc455fed8933a98a8b13bea015dd9c4b6e99a (diff) |
added current config
Diffstat (limited to 'nvim/lua/core/statusline.lua')
-rw-r--r-- | nvim/lua/core/statusline.lua | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/nvim/lua/core/statusline.lua b/nvim/lua/core/statusline.lua new file mode 100644 index 0000000..45a2c42 --- /dev/null +++ b/nvim/lua/core/statusline.lua @@ -0,0 +1,55 @@ +local M = {} + +local function git_branch() + local git_dir = vim.fn.system("git rev-parse --git-dir 2>/dev/null") + if vim.v.shell_error ~= 0 then + return "" + end + local branch = vim.fn.system("git branch --show-current 2>/dev/null | tr -d '\n'") + return branch +end + +function M.statusline_git() + local branch_name = git_branch() + return #branch_name > 0 and ' ' .. branch_name .. ' ' or '' +end + +function M.setup() + vim.cmd('highlight clear StatusLine') + vim.cmd('highlight clear StatusLineNC') + + local highlights = { + StatusLineGit = { bg = "#161616", fg = "#D8DEE9" }, + StatusLineBuffer = { bg = "NONE", fg = "#D8DEE9" }, + StatusLine = { bg = "NONE", fg = "#D8DEE9" }, + StatusLineFiletype = { bg = "NONE", fg = "#D8DEE9" }, + StatusLinePath = { bg = "NONE", fg = "#D8DEE9" }, + StatusLineModified = { bg = "NONE", fg = "#D8DEE9" }, + } + + for name, colors in pairs(highlights) do + vim.api.nvim_set_hl(0, name, colors) + end + + vim.opt.statusline = table.concat({ + "%#StatusLineGit#%{v:lua.require'core.statusline'.statusline_git()}", + "%#StatusLineBuffer# %n ", + "%#StatusLine#%{&ff} ", + "%#StatusLineFiletype#%y", + "%#StatusLinePath# %<%{expand('%:p:h')}/%f", + "%#StatusLineModified#%m", + "%=", + "%#StatusLine#%5l", + "/%L:%v ", + "%{char2nr(getline('.')[col('.')-1])} " + }) +end + +vim.api.nvim_create_autocmd("ColorScheme", { + pattern = "*", + callback = function() + M.setup() + end, +}) + +return M |