Created
February 24, 2023 15:39
-
-
Save horseinthesky/17a001da32cea1166e9e4dba6b50d5a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local utils = require "utils" | |
local appearance = require "appearance" | |
local icons = appearance.icons | |
local colors = appearance.colors | |
local mode_map = { | |
n = { "", "NORMAL" }, | |
i = { "", "INSERT" }, | |
ic = { "", "INSERT" }, | |
R = { "", "REPLACE" }, | |
v = { "", "VISUAL" }, | |
V = { "", "V-LINE" }, | |
c = { "ﲵ", "COMMAND" }, | |
s = { "", "SELECT" }, | |
S = { "", "S-LINE" }, | |
t = { "", "TERMINAL" }, | |
nt = { "", "TERMINAL" }, | |
["\22"] = { "", "V-BLOCK" }, | |
["\19"] = { "", "S-BLOCK" }, | |
} | |
setmetatable(mode_map, { | |
__index = function() | |
return { icons.question, vim.api.nvim_get_mode().mode } | |
end, | |
}) | |
local components = { | |
file = { | |
mode = function() | |
local icon, label = unpack(mode_map[vim.api.nvim_get_mode().mode]) | |
local mode = " " .. icon .. " " | |
if utils.wide_enough(60) then | |
mode = mode .. label .. " " | |
end | |
if vim.o.paste then | |
mode = mode .. icons.sep.left .. " " .. icons.paste .. " " | |
if utils.wide_enough(65) then | |
mode = mode .. "Paste " | |
end | |
end | |
return mode | |
end, | |
location = function() | |
return string.format(" %s %s:%s ", icons.line_number, unpack(vim.api.nvim_win_get_cursor(0))) | |
end, | |
percentage = function() | |
local curr_line = vim.api.nvim_win_get_cursor(0)[1] | |
local lines = vim.api.nvim_buf_line_count(0) | |
return string.format(" %s %d%%%% ", icons.page, math.floor(100 * curr_line / lines)) | |
end, | |
}, | |
git = { | |
icon = function() | |
if not vim.b.gitsigns_head and not vim.b.gitsigns_status_dict then | |
return "" | |
end | |
return icons.git.branch | |
end, | |
branch = function() | |
return vim.b.gitsigns_head or "" | |
end, | |
}, | |
lsp = { | |
icon = function() | |
if not utils.diagnostic_exists() then | |
return "" | |
end | |
return icons.gears | |
end, | |
server = function() | |
return utils.get_lsp_clients() | |
end, | |
ok = function() | |
if not utils.diagnostic_exists() then | |
return "" | |
end | |
local e = vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) | |
local w = vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) | |
local i = vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }) | |
local h = vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }) | |
if #w ~= 0 or #e ~= 0 or #i ~= 0 or #h ~= 0 then | |
return "" | |
end | |
return " " .. icons.diagnostic.ok .. " " | |
end, | |
}, | |
} | |
local sections = { | |
a = { { components.file.mode, padding = 0 } }, | |
b = { | |
{ "filetype", icon_only = true, padding = { left = 1 } }, | |
{ | |
"filename", | |
symbols = { | |
modified = icons.file.modified, | |
readonly = icons.file.locked, | |
}, | |
}, | |
}, | |
c = { | |
{ components.git.icon, color = { fg = colors.git_icon }, padding = { left = 1 } }, | |
{ components.git.branch, padding = { left = 1 } }, | |
{ | |
"diff", | |
symbols = { | |
added = icons.circle.plus .. " ", | |
modified = icons.circle.dot .. " ", | |
removed = icons.circle.minus .. " ", | |
}, | |
diff_color = { | |
added = { fg = colors.diff_add }, | |
modified = { fg = colors.diff_modified }, | |
removed = { fg = colors.diff_remove }, | |
}, | |
}, | |
}, | |
x = { | |
{ components.lsp.icon, color = { fg = colors.lsp_icon } }, | |
{ components.lsp.server, padding = 0 }, | |
{ | |
"diagnostics", | |
sources = { "nvim_diagnostic" }, | |
symbols = { | |
error = icons.diagnostic.error .. " ", | |
warn = icons.diagnostic.warning .. " ", | |
info = icons.diagnostic.info .. " ", | |
hint = icons.diagnostic.hint .. " ", | |
}, | |
}, | |
{ components.lsp.ok, color = { fg = colors.ok }, padding = 0 }, | |
}, | |
y = { | |
{ "fileformat", padding = { left = 1 } }, | |
"encoding", | |
}, | |
z = { | |
{ components.file.location, padding = 0, separator = icons.sep.left }, | |
{ components.file.percentage, padding = 0, separator = icons.sep.right }, | |
}, | |
} | |
require("lualine").setup { | |
options = { | |
section_separators = { | |
left = icons.sep.left_filled, | |
right = icons.sep.right_filled, | |
}, | |
component_separators = { | |
left = "", | |
right = "", | |
}, | |
disabled_filetypes = { | |
statusline = { "alpha" }, | |
}, | |
}, | |
sections = { | |
lualine_a = sections.a, | |
lualine_b = sections.b, | |
lualine_c = sections.c, | |
lualine_x = sections.x, | |
lualine_y = sections.y, | |
lualine_z = sections.z, | |
}, | |
inactive_sections = { | |
lualine_a = {}, | |
lualine_b = {}, | |
lualine_c = { "filename" }, | |
lualine_x = {}, | |
lualine_y = {}, | |
lualine_z = {}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment