Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lua/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function Highlights:get()
local colors = require("catppuccin.palettes").get_palette("mocha")
local cursor_line_bg = helpers:blend(colors.mauve, "#000000", 0.28)

---@type table<string, vim.api.keyset.highlight>
local highlights = {
Visual = { bg = helpers:blend(colors.mauve, "#000000", 0.4) },
CursorLine = { bg = cursor_line_bg },
Expand All @@ -55,6 +56,10 @@ function Highlights:get()
NavicText = { link = "lualine_c_inactive" },
NavicSeparator = { link = "lualine_c_inactive" },

-- Statusline
OverlayActive = { bg = colors.surface1 },
OverlayActiveInverted = { fg = colors.surface1 },

-- LSP
LspReferenceText = { underline = true },
["@tag.builtin"] = { link = "Special" },
Expand Down
20 changes: 0 additions & 20 deletions lua/nikero/lualine.lua

This file was deleted.

51 changes: 51 additions & 0 deletions lua/nikero/statusline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---@class StatusLine
---@field statusline_icon_hl fun(self: StatusLine, icon_hl: string, default_hl_token: string): string
local StatusLine = {}

function StatusLine:statusline_icon_hl(icon_hl, default_hl_token)
local base_hl = default_hl_token:match("%%#(.-)#") or default_hl_token
local group = ("LualineIcon_%s_%s"):format(base_hl, icon_hl):gsub("[^%w_]", "_")
local icon = vim.api.nvim_get_hl(0, { name = group, link = false })
if icon == vim.empty_dict() then return group end

local base = vim.api.nvim_get_hl(0, { name = base_hl, link = false })
local new_icon = vim.api.nvim_get_hl(0, { name = icon_hl, link = false })

vim.api.nvim_set_hl(0, group, { fg = new_icon.fg, bg = base.bg })

return group
end
Comment thread
coderabbitai[bot] marked this conversation as resolved.

function StatusLine:harpoon_widget(default_hl)
local current_file = vim.fn.expand("%:p")
local items = require("harpoon"):list().items
return vim
.iter(ipairs(items))
:map(function(index, item)
local file_path = vim.fn.fnamemodify(item.value, ":p")
local icon, base_icon_hl = require("mini.icons").get("file", file_path)

local is_active = file_path == current_file
local base_hl = default_hl
if is_active then base_hl = "%#OverlayActive#" end

local icon_hl = self:statusline_icon_hl(base_icon_hl, base_hl)
local icon_str = self:wrap(icon_hl, icon) .. base_hl

local value = string.format("%s %d", icon_str, index)

if is_active then
local side_hl = self:statusline_icon_hl("OverlayActiveInverted", default_hl)
value = self:wrap(side_hl, "") .. value .. self:wrap(side_hl, "") .. default_hl
else
value = string.format(" %s ", value)
end

return value
end)
:join("")
end

function StatusLine:wrap(hl, text) return "%#" .. hl .. "#" .. text end

return StatusLine
2 changes: 1 addition & 1 deletion lua/plugins/colorschemes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ return {
all = function(colors)
return {
normal = {
c = { bg = colors.base, fg = colors.text },
c = { bg = colors.mantle, fg = colors.text },
},
inactive = {
a = { bg = colors.base, fg = colors.blue },
Expand Down
109 changes: 50 additions & 59 deletions lua/plugins/lualine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ return {
opts = {
options = {
theme = "auto",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
statusline = {},
winbar = { "neo-tree", "snacks_dashboard", "qf", "noice", "trouble", "help" },
Expand All @@ -17,91 +17,91 @@ return {
},
sections = {
lualine_a = {},
lualine_b = {
lualine_b = {},
lualine_c = {
{
-- Separator to set the left edge
function() return "" end,
draw_empty = true,
separator = { left = "" },
"project",
format = "short",
no_project = "N/A",
color = function()
return { fg = require("catppuccin.palettes").get_palette("mocha").blue }
end,
},
{ "project", format = "short", no_project = "N/A" },
{ "branch", on_click = function() Snacks.lazygit() end },
"filetype",
},
lualine_c = {
{
-- harpoon
function(fmt)
local current_file = vim.fn.expand("%:p")
return vim
.iter(ipairs(require("harpoon"):list().items))
:map(function(index, item)
local file_path = vim.fn.fnamemodify(item.value, ":p")
local icon, hl = require("mini.icons").get("file", file_path)
local new_hl = require("nikero.lualine"):statusline_icon_hl(hl, fmt.default_hl)
local icon_str = "%#" .. new_hl .. "#" .. icon .. "%*" .. fmt.default_hl

local value = string.format("%s %d", icon_str, index)

if file_path == current_file then
value = string.format("(%s)", value)
else
value = string.format(" %s ", value)
end

return value
end)
:join("")
"branch",
icon = require("icons").git.branch,
on_click = function() Snacks.lazygit() end,
color = function()
return { fg = require("catppuccin.palettes").get_palette("mocha").green }
end,
},
{ "filetype", separator = "│" },
{
function(fmt) return require("nikero.statusline"):harpoon_widget(fmt.default_hl) end,
condition = function() return #require("harpoon"):list().items ~= 0 end,
separator = "│",
padding = 0,
},
{
"diff",
padding = { left = 2 },
diff_color = {
added = "@diff.plus",
modified = "@diff.delta",
removed = "@diff.minus",
},
symbols = {
added = require("icons").git.add .. " ",
modified = require("icons").git.modified .. " ",
removed = require("icons").git.removed .. " ",
},
separator = "",
},
{ "%=", separator = "" },
{
-- q recording
function()
local reg = vim.fn.reg_recording()
if reg == "" then return "" end
return require("icons").tools.macro_recording .. " " .. reg
return "%=" .. require("icons").tools.macro_recording .. " " .. reg
end,
cond = function() return vim.fn.reg_recording() ~= "" end,
-- TODO:
color = "SpecialChar",
},
},
lualine_x = {
{ function() return require("wtf").get_status() end },
{
function()
local linters = require("lint").get_running()
if #linters == 0 then return require("icons").status.active .. " " end
return require("icons").status.working .. " " .. table.concat(linters, ", ")
end,
cond = function() return #require("lint").get_running() ~= 0 end,
color = function()
local linters = require("lint").get_running()
return { fg = #linters == 0 and "#33aa88" or nil }
return { fg = require("catppuccin.palettes").get_palette("mocha").peach }
end,
},
{
"diagnostics",
padding = 2,
symbols = {
error = require("icons").diagnostics.error .. " ",
warn = require("icons").diagnostics.warn .. " ",
info = require("icons").diagnostics.info .. " ",
hint = require("icons").diagnostics.hint .. " ",
},
},
{
"progress",
color = function()
return { fg = require("catppuccin.palettes").get_palette("mocha").flamingo }
end,
},
{
"location",
color = function()
return { fg = require("catppuccin.palettes").get_palette("mocha").mauve }
end,
},
},
lualine_y = {
{ "progress", padding = { left = 1, right = 2 } },
{ "location", separator = { right = "" } },
},
lualine_y = {},
lualine_z = {},
},
tabline = {
Expand All @@ -126,14 +126,10 @@ return {
winbar = {
lualine_a = {},
lualine_b = {
{
"filetype",
separator = { left = "" },
padding = { left = 1, right = 0 },
icon_only = true,
},
{ "filetype", icon_only = true },
{
"filename",
separator = { right = "" },
padding = { left = 0, right = 1 },
file_status = true,
newfile_status = true,
Expand All @@ -156,15 +152,10 @@ return {
inactive_winbar = {
lualine_a = {},
lualine_b = {
{
"filetype",
separator = "",
padding = { left = 2, right = 0 },
colored = false,
icon_only = true,
},
{ "filetype", colored = false, icon_only = true },
{
"filename",
separator = { right = "" },
padding = { left = 0, right = 1 },
file_status = true,
newfile_status = true,
Expand Down
Loading