feat(bar): add custom bar and remove lualine

This commit is contained in:
Lucas Barbieri 2024-07-26 19:33:44 -03:00
parent d417baec56
commit 072c9771a5
3 changed files with 207 additions and 105 deletions

View File

@ -1,109 +1,109 @@
return {
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
local lualine = require("lualine")
local colors = {
blue = "#268bd2",
green = "#859900",
violet = "#6c71c4",
yellow = "#b58900",
red = "#dc332f",
cream = "#fdf6e3",
black = "#002b36",
grey = "#073642",
dark = "#002b36",
}
local solarized = {
normal = {
a = { bg = colors.dark, fg = colors.cream, gui = "bold" },
c = { bg = colors.grey, fg = colors.cream, gui = "bold" },
},
insert = {
a = { bg = colors.grey, fg = colors.cream, gui = "bold" },
c = { bg = colors.black, fg = colors.cream, gui = "bold" },
},
visual = {
a = { bg = colors.violet, fg = colors.black, gui = "bold" },
c = { bg = colors.dark, fg = colors.cream, gui = "bold" },
},
command = {
a = { bg = colors.green, fg = colors.black, gui = "bold" },
c = { bg = colors.black, fg = colors.cream, gui = "bold" },
},
replace = {
a = { bg = colors.blue, fg = colors.black, gui = "bold" },
c = { bg = colors.black, fg = colors.cream, gui = "bold" },
},
inactive = {
a = { bg = colors.green, fg = colors.black, gui = "bold" },
c = { bg = colors.black, fg = colors.cream, gui = "bold" },
},
}
-- configure lualine with modified theme
lualine.setup({
options = {
theme = solarized,
component_separators = { left = "", right = "|" },
section_separators = { left = "", right = "" },
},
sections = {
lualine_a = {
"mode",
"branch",
"diff",
"diagnostics",
{
-- "buffers",
-- buffers_color = {
-- active = { bg = colors.yellow, fg = colors.black, gui = "bold" },
-- inactive = { bg = colors.grey, fg = colors.cream, gui = "italic" },
-- "nvim-lualine/lualine.nvim",
-- dependencies = { "nvim-tree/nvim-web-devicons" },
-- config = function()
-- local lualine = require("lualine")
--
-- local colors = {
-- blue = "#268bd2",
-- green = "#859900",
-- violet = "#6c71c4",
-- yellow = "#b58900",
-- red = "#dc332f",
-- cream = "#fdf6e3",
-- black = "#002b36",
-- grey = "#073642",
-- dark = "#002b36",
-- }
--
-- local solarized = {
-- normal = {
-- a = { bg = colors.dark, fg = colors.cream, gui = "bold" },
-- c = { bg = colors.grey, fg = colors.cream, gui = "bold" },
-- },
symbols = {
modified = "",
alternate_file = "",
directory = "",
},
mode = 2,
},
},
lualine_b = {},
lualine_c = {
{
"filename",
file_status = true,
path = 3,
},
},
lualine_x = {},
lualine_y = {},
lualine_z = {
"searchcount",
"selectioncount",
"encoding",
"fileformat",
"filetype",
"progress",
"location",
},
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
})
end,
-- insert = {
-- a = { bg = colors.grey, fg = colors.cream, gui = "bold" },
-- c = { bg = colors.black, fg = colors.cream, gui = "bold" },
-- },
-- visual = {
-- a = { bg = colors.violet, fg = colors.black, gui = "bold" },
-- c = { bg = colors.dark, fg = colors.cream, gui = "bold" },
-- },
-- command = {
-- a = { bg = colors.green, fg = colors.black, gui = "bold" },
-- c = { bg = colors.black, fg = colors.cream, gui = "bold" },
-- },
-- replace = {
-- a = { bg = colors.blue, fg = colors.black, gui = "bold" },
-- c = { bg = colors.black, fg = colors.cream, gui = "bold" },
-- },
-- inactive = {
-- a = { bg = colors.green, fg = colors.black, gui = "bold" },
-- c = { bg = colors.black, fg = colors.cream, gui = "bold" },
-- },
-- }
--
-- -- configure lualine with modified theme
-- lualine.setup({
-- options = {
-- theme = solarized,
-- component_separators = { left = "", right = "|" },
-- section_separators = { left = "", right = "" },
-- },
-- sections = {
-- lualine_a = {
-- "mode",
-- "branch",
-- "diff",
-- "diagnostics",
-- {
-- -- "buffers",
-- -- buffers_color = {
-- -- active = { bg = colors.yellow, fg = colors.black, gui = "bold" },
-- -- inactive = { bg = colors.grey, fg = colors.cream, gui = "italic" },
-- -- },
-- symbols = {
-- modified = " ●",
-- alternate_file = " ",
-- directory = "",
-- },
-- mode = 2,
-- },
-- },
-- lualine_b = {},
-- lualine_c = {
-- {
-- "filename",
-- file_status = true,
-- path = 3,
-- },
-- },
-- lualine_x = {},
-- lualine_y = {},
-- lualine_z = {
-- "searchcount",
-- "selectioncount",
-- "encoding",
-- "fileformat",
-- "filetype",
-- "progress",
-- "location",
-- },
-- },
-- inactive_sections = {
-- lualine_a = {},
-- lualine_b = {},
-- lualine_c = { "filename" },
-- lualine_x = { "location" },
-- lualine_y = {},
-- lualine_z = {},
-- },
-- tabline = {},
-- winbar = {},
-- inactive_winbar = {},
-- extensions = {},
-- })
-- end,
}

101
lua/jabuxas/bar.lua Normal file
View File

@ -0,0 +1,101 @@
local Mode = {}
Mode.map = {
['n'] = 'NORMAL',
['no'] = 'O-PENDING',
['nov'] = 'O-PENDING',
['noV'] = 'O-PENDING',
['no\22'] = 'O-PENDING',
['niI'] = 'NORMAL',
['niR'] = 'NORMAL',
['niV'] = 'NORMAL',
['nt'] = 'NORMAL',
['ntT'] = 'NORMAL',
['v'] = 'VISUAL',
['vs'] = 'VISUAL',
['V'] = 'V-LINE',
['Vs'] = 'V-LINE',
['\22'] = 'V-BLOCK',
['\22s'] = 'V-BLOCK',
['s'] = 'SELECT',
['S'] = 'S-LINE',
['\19'] = 'S-BLOCK',
['i'] = 'INSERT',
['ic'] = 'INSERT',
['ix'] = 'INSERT',
['R'] = 'REPLACE',
['Rc'] = 'REPLACE',
['Rx'] = 'REPLACE',
['Rv'] = 'V-REPLACE',
['Rvc'] = 'V-REPLACE',
['Rvx'] = 'V-REPLACE',
['c'] = 'COMMAND',
['cv'] = 'EX',
['ce'] = 'EX',
['r'] = 'REPLACE',
['rm'] = 'MORE',
['r?'] = 'CONFIRM',
['!'] = 'SHELL',
['t'] = 'TERMINAL',
}
function Mode.get_mode()
local mode_code = vim.api.nvim_get_mode().mode
if Mode.map[mode_code] == nil then
return mode_code
end
return Mode.map[mode_code]
end
local function filename3()
return vim.fn.expand("%:t")
end
local function location()
return vim.fn.line('.') .. ":" .. vim.fn.charcol('.')
end
local function progress()
local total_lines = vim.fn.line('$')
local current_line = vim.fn.line('.')
return math.floor((current_line / total_lines) * 100) .. "%%"
end
local function stats()
return location() .. " " .. progress()
end
function statusline_render()
local components = { Mode.get_mode(), filename3(), stats() }
local total_length = 0
for _, component in ipairs(components) do
total_length = total_length + vim.fn.strwidth(component)
end
local statusline_width = vim.fn.winwidth(0)
local available_space = statusline_width - total_length
local spaces_between = math.floor(available_space / (#components - 1))
local statusline = ""
for i, component in ipairs(components) do
statusline = statusline .. component
if i < #components then
statusline = statusline .. string.rep(" ", spaces_between)
end
end
return statusline
end
local autocmd = vim.api.nvim_create_autocmd
autocmd(
{
"WinEnter", "BufEnter", "BufWritePost", "SessionLoadPost", "FileChangedShellPost", "VimResized", "Filetype",
"CursorMoved", "CursorMovedI", "ModeChanged" },
{
pattern = "*",
callback = function()
vim.opt.statusline = "%{%v:lua.statusline_render()%}"
end,
})

View File

@ -1,2 +1,3 @@
require("jabuxas.remap")
require("jabuxas.set")
require("jabuxas.bar")