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