switched to dentritic pattern and cleaned up config

This commit is contained in:
2026-08-30 13:24:46 +02:00
parent 325f4a0e0c
commit 47325d4031
133 changed files with 565 additions and 1865 deletions
@@ -0,0 +1,275 @@
local conditions = require("heirline.conditions")
local utils = require("heirline.utils")
local devicons = require("nvim-web-devicons")
local branch = vim.fn.system("git branch --show-current 2>/dev/null")
branch = branch:gsub("\n", "")
vim.api.nvim_create_autocmd("BufWritePre", {
callback = function()
vim.schedule(function()
vim.defer_fn(function()
vim.cmd("redrawstatus")
end, 100)
end)
end,
})
local mode_names = {
n = "NORMAL",
no = "OP-PENDING",
nov = "OP-PENDING",
noV = "OP-PENDING",
["no\22"] = "OP-PENDING",
niI = "NORMAL",
niR = "NORMAL",
niV = "NORMAL",
v = "VISUAL",
V = "V-LINE",
["\22"] = "V-BLOCK", -- CTRL-V
s = "SELECT",
S = "S-LINE",
["\19"] = "S-BLOCK", -- CTRL-S
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 = "ENTER",
rm = "MORE",
["r?"] = "CONFIRM",
["!"] = "SHELL",
t = "TERMINAL",
}
local colors = {
bg = "#3B4252", -- Polar Night
fg = "#ECEFF4", -- Snow Storm
red = "#BF616A", -- Aurora
orange = "#D08770",
yellow = "#EBCB8B",
green = "#A3BE8C",
cyan = "#88C0D0",
blue = "#81A1C1",
blue_dark = "#5E81AC",
magenta = "#B48EAD",
}
local mode_colors = {
n = colors.blue_dark, -- NORMAL
i = colors.green, -- INSERT
v = colors.magenta, -- VISUAL
V = colors.magenta,
["\22"] = colors.magenta, -- V-BLOCK
c = colors.yellow, -- COMMAND
s = colors.orange, -- SELECT
S = colors.orange,
R = colors.red, -- REPLACE
r = colors.red,
t = colors.cyan, -- TERMINAL
}
local function BorderLeft(color, background)
return {
provider = "",
hl = function()
return { fg = color, bg = background }
end,
}
end
local function BorderRight(color, background)
return {
provider = "",
hl = function()
return { fg = color, bg = background }
end,
}
end
local function Mode(color)
return {
provider = function()
return " " .. mode_names[vim.fn.mode()] .. " "
end,
hl = function()
return { bg = color, fg = colors.fg, bold = true }
end,
}
end
local FileName = {
provider = function()
local name = vim.fn.expand("%:t")
if name == "" then name = "[No Name]" end
return name
end,
hl = { fg = colors.fg, bg = colors.bg },
}
local GitBranch = {
-- condition = function(self)
-- return vim.fn.system('git rev-parse --is-inside-work-tree 2>/dev/null') == "true\n"
-- end,
provider = function(self)
return "" .. branch .. " "
end,
hl = { fg = colors.blue, bg = colors.bg },
}
local FileIcon = {
init = function(self)
self.filename = vim.fn.expand("%:t")
self.extension = vim.fn.expand("%:e")
self.icon, self.icon_color = devicons.get_icon_color(self.filename, self.extension, { default = true })
end,
provider = function(self)
return " " .. self.icon .. " "
end,
hl = function(self)
return { fg = self.icon_color, bg = colors.bg }
end,
}
function SimpleSeperator(foreground, background)
return {
provider = function()
return " | "
end,
hl = function()
return { fg = foreground, bg = background }
end,
}
end
-- local Lsp = {
-- condition = function()
-- return #vim.lsp.get_active_clients({ bufnr = 0 }) > 0
-- end,
-- provider = "  LSP ",
-- hl = { fg = colors.green },
-- }
--
local function Diagnostics(background)
return {
condition = function()
return vim.diagnostic.is_enabled()
end,
init = function(self)
self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })
self.warnings = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })
self.info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO })
self.hints = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT })
end,
{
-- condition = function(self) return self.errors > 0 end,
provider = function(self) return "" .. self.errors .. " " end,
hl = { fg = colors.red, bg = background },
},
{
-- condition = function(self) return self.warnings > 0 end,
provider = function(self) return "" .. self.warnings .. " " end,
hl = { fg = colors.yellow, bg = background },
},
{
-- condition = function(self) return self.info > 0 end,
provider = function(self) return "" .. self.info .. " " end,
hl = { fg = colors.blue, bg = background },
},
{
-- condition = function(self) return self.hints > 0 end,
provider = function(self) return "" .. self.hints .. " " end,
hl = { fg = colors.cyan, bg = background },
},
}
end
local FileType = {
provider = function()
return vim.bo.filetype
end,
hl = { fg = colors.fg, bg = colors.bg },
}
local FileFlags = {
{
condition = function()
return vim.bo.modified
end,
provider = " []",
hl = { bg = colors.bg, fg = colors.fg },
-- refresh statusline on buffer changes
update = { "TextChanged", "TextChangedI", "InsertLeave", "BufEnter", "BufWritePost" },
enabled = function() return true end,
},
{
condition = function() return not vim.bo.modifiable or vim.bo.readonly end,
provider = " []",
hl = { bg = colors.bg, fg = colors.fg },
update = { "BufEnter", "BufWritePost" },
},
}
local function FilePercentage(background)
return {
provider = function()
local current = vim.fn.line(".") -- current line
local total = vim.fn.line("$") -- total lines
if total == 0 then return "Top" end
local percent = math.floor((current / total) * 100)
return percent .. "%%"
end,
hl = { fg = colors.fg, bg = background, bold = true },
}
end
local DefaultStatusline = {
BorderLeft(colors.blue),
Mode(colors.blue),
BorderRight(colors.blue, colors.bg),
FileIcon,
FileName,
FileFlags,
SimpleSeperator(colors.fg, colors.bg),
GitBranch,
BorderRight(colors.bg),
{ provider = "%=" },
BorderLeft(colors.bg),
FileIcon,
FileType,
SimpleSeperator(colors.fg, colors.bg),
Diagnostics(colors.bg),
BorderLeft(colors.blue, colors.bg),
FilePercentage(colors.blue),
BorderRight(colors.blue),
}
require("heirline").setup({ statusline = DefaultStatusline })
@@ -0,0 +1,65 @@
local M = {}
local function CurrentTime()
return os.date("%H:%M:%S")
end
local theme = require('plugins.config.lualine.nord_theme')
local opts = {
options = {
theme = theme.spec,
globalstatus = true,
component_separators = '|',
section_separators = { left = '', right = '' },
},
sections = {
lualine_a = {
{ 'mode', separator = { left = '', right = '' } },
},
lualine_b = { {
'tabs',
seperator = " ",
cond = function()
return #vim.fn.gettabinfo() >= 2
end,
tabs_color = {
inactive = { fg = theme.colors.nord5 },
active = { fg = theme.colors.nord8 },
}
}, 'filename', 'branch', 'diff' },
lualine_c = {
},
lualine_x = {},
lualine_y = { 'filetype', { 'diagnostics', always_visible = true }, 'progress' },
lualine_z = {
{ CurrentTime, separator = { right = '', left = '' } },
},
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
tabline = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
extensions = {},
}
M.setup = function()
require('lualine').setup(opts)
end
M.setup()
return M
@@ -0,0 +1,31 @@
local M = {}
M.colors = {
blue = '#80a0ff',
cyan = '#79dac8',
transparent = nil,
white = '#c6c6c6',
red = '#ff5189',
violet = '#d183e8',
grey = '#303030',
}
M.theme = {
normal = {
a = { fg = M.colors.transparent, bg = M.colors.violet },
b = { fg = M.colors.white, bg = M.colors.grey },
c = { fg = M.colors.transparent, bg = M.colors.transparent },
},
insert = { a = { fg = M.colors.transparent, bg = M.colors.blue } },
visual = { a = { fg = M.colors.transparent, bg = M.colors.cyan } },
replace = { a = { fg = M.colors.transparent, bg = M.colors.red } },
inactive = {
a = { fg = M.colors.white, bg = M.colors.transparent },
b = { fg = M.colors.white, bg = M.colors.transparent },
c = { fg = M.colors.transparent, bg = M.colors.transparent },
},
}
return M
@@ -0,0 +1,30 @@
local M = {}
M.colors = {
nord1 = '#3B4252',
nord3 = '#4C566A',
nord5 = '#E5E9F0',
nord6 = '#ECEFF4',
nord7 = '#8FBCBB',
nord8 = '#88C0D0',
nord13 = '#EBCB8B',
transparent = nil,
}
M.spec = {
normal = {
a = { fg = M.colors.nord5, bg = M.colors.nord8 },
b = { fg = M.colors.nord5, bg = M.colors.nord1 },
c = { fg = M.colors.transparent, bg = M.colors.transparent },
},
insert = { a = { fg = M.colors.transparent, bg = M.colors.nord6, gui = 'bold' } },
visual = { a = { fg = M.colors.transparent, bg = M.colors.nord7, gui = 'bold' } },
replace = { a = { fg = M.colors.transparent, bg = M.colors.nord13, gui = 'bold' } },
inactive = {
a = { fg = M.colors.nord1, bg = M.colors.transparent, gui = 'bold' },
b = { fg = M.colors.nord5, bg = M.colors.transparent },
c = { fg = M.colors.transparent, bg = M.colors.transparent },
},
}
return M
@@ -0,0 +1,29 @@
local function setup_content()
local MiniStatusline = require('mini.statusline')
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
local git = MiniStatusline.section_git({ trunc_width = 40 })
local diff = MiniStatusline.section_diff({ trunc_width = 75 })
local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })
local lsp = MiniStatusline.section_lsp({ trunc_width = 75 })
local filename = MiniStatusline.section_filename({ trunc_width = 140 })
local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
local location = MiniStatusline.section_location({ trunc_width = 75 })
local search = MiniStatusline.section_searchcount({ trunc_width = 75 })
print(filename)
return MiniStatusline.combine_groups({
{ hl = mode_hl, strings = { mode } },
{ hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } },
'%<', -- Mark general truncate point
{ hl = 'MiniStatuslineFilename', strings = { filename } },
'%=', -- End left alignment
{ hl = 'MiniStatuslineFileinfo', strings = { fileinfo } },
{ hl = mode_hl, strings = { search, location } },
})
end
require('mini.statusline').setup({
content = {
active = setup_content
}
})
@@ -0,0 +1,49 @@
require('staline').setup {
defaults = {
expand_null_ls = false, -- This expands out all the null-ls sources to be shown
left_separator = '',
right_separator = "",
full_path = false,
line_column = "[%l/%L] :%c 並%p%% ", -- `:h stl` to see all flags.
fg = "#000000", -- Foreground text color.
bg = "none", -- Default background is transparent.
inactive_color = "#303030",
inactive_bgcolor = "none",
true_colors = false, -- true lsp colors.
font_active = "none", -- "bold", "italic", "bold,italic", etc
mod_symbol = "",
lsp_client_symbol = "",
lsp_client_character_length = 12, -- Shorten LSP client names.
branch_symbol = "",
cool_symbol = "", -- Change this to override default OS icon.
null_ls_symbol = "", -- A symbol to indicate that a source is coming from null-ls
},
mode_icons = {
n = "",
i = "",
c = "",
v = "", -- etc..
},
sections = {
left = { '- ', '-mode', 'left_sep_double', ' ', 'branch', 'file_name' },
mid = {},
right = { 'cool_symbol', 'right_sep_double', '-line_column' },
},
inactive_sections = {
left = { 'branch', 'file_name' },
mid = { 'file_name' },
right = { 'line_column' }
},
special_table = {
NvimTree = { 'NvimTree', '' },
packer = { 'Packer', '' }, -- etc
},
lsp_symbols = {
Error = "",
Info = "",
Warn = "",
Hint = "",
},
}
@@ -0,0 +1,59 @@
require("witch-line").setup({
abstracts = {
"file.name",
{
id = "file", -- Abstract component for file-related info
padding = { left = 1, right = 1 }, -- Padding around the component
static = { some_key = "some_value" }, -- Static metadata
style = { fg = "#ffffff", bg = "#000000", bold = true }, -- Style override
min_screen_width = 80, -- Hide if screen width < 80
},
},
statusline = {
--- The global statusline components
global = {
"mode",
"file.name",
"git.branch",
-- {
-- id = "component_id", -- Unique identifier
-- padding = { left = 1, right = 1 }, -- Padding around the component
-- static = { some_key = "some_value" }, -- Static metadata
-- win_individual = false,
-- timing = false, -- No timing updates
-- style = { fg = "#ffffff", bg = "#000000", bold = true }, -- Style override
-- min_screen_width = 80, -- Hide if screen width < 80
-- hidden = function() -- Hide condition
-- return vim.bo.buftype == "nofile"
-- end,
-- left_style = { fg = "#ff0000" }, -- Left style override
-- update = function(self, ctx, static, session_id) -- Main content generator
-- return vim.fn.expand("%:t")
-- end,
-- ref = { -- References to other components
-- events = { "file.name" },
-- style = "file.name",
-- static = "file.name",
-- },
-- },
},
-- @type fun(winid): CombinedComponent[]|nil
win = nil
},
cache = {
-- Perform full plugin scan for cache expiration. Default false.
full_scan = false,
-- Show notification when cache is cleared. Default true.
notification = true,
-- Strip debug info when caching dumped functions. Default false.
func_strip = false,
},
disabled = {
filetypes = { "help", "TelescopePrompt" },
buftypes = { "nofile", "terminal" },
},
})