found match for the statusline after a lot of research and styled it
This commit is contained in:
246
homemanager/neovim/lua/plugins/config/heirline.lua
Normal file
246
homemanager/neovim/lua/plugins/config/heirline.lua
Normal file
@@ -0,0 +1,246 @@
|
||||
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", "")
|
||||
|
||||
|
||||
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 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,
|
||||
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 })
|
||||
29
homemanager/neovim/lua/plugins/config/mini_statusline.lua
Normal file
29
homemanager/neovim/lua/plugins/config/mini_statusline.lua
Normal file
@@ -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
|
||||
}
|
||||
})
|
||||
49
homemanager/neovim/lua/plugins/config/staline.lua
Normal file
49
homemanager/neovim/lua/plugins/config/staline.lua
Normal file
@@ -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 = "",
|
||||
},
|
||||
}
|
||||
59
homemanager/neovim/lua/plugins/config/witchline.lua
Normal file
59
homemanager/neovim/lua/plugins/config/witchline.lua
Normal file
@@ -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" },
|
||||
},
|
||||
})
|
||||
7
homemanager/neovim/lua/plugins/spec/heirline.lua
Normal file
7
homemanager/neovim/lua/plugins/spec/heirline.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
return {
|
||||
"rebelot/heirline.nvim",
|
||||
config = function()
|
||||
require("plugins.config.heirline")
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
return {
|
||||
'nvim-mini/mini.statusline',
|
||||
version = '*',
|
||||
enabled = false,
|
||||
config = function()
|
||||
require('mini.statusline').setup()
|
||||
require('plugins.config.mini_statusline')
|
||||
end
|
||||
}
|
||||
7
homemanager/neovim/lua/plugins/spec/staline.lua
Normal file
7
homemanager/neovim/lua/plugins/spec/staline.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
return {
|
||||
'tamton-aquib/staline.nvim',
|
||||
enabled = false,
|
||||
config = function()
|
||||
require('plugins.config.staline')
|
||||
end
|
||||
}
|
||||
12
homemanager/neovim/lua/plugins/spec/witchline.lua
Normal file
12
homemanager/neovim/lua/plugins/spec/witchline.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
return {
|
||||
"sontungexpt/witch-line",
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
lazy = false, -- Almost component is lazy load by default. So you can set lazy to false
|
||||
enabled = false,
|
||||
config = function()
|
||||
vim.o.laststatus = 3
|
||||
require("plugins.config.witchline")
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user