updates: (also build system back?)
This commit is contained in:
parent
2606d3f2a7
commit
8498f7d121
6 changed files with 548 additions and 481 deletions
|
|
@ -22,7 +22,7 @@ in {
|
|||
};
|
||||
|
||||
extraConfig = ''
|
||||
bold_font ${fonts.mono} Bold Italic
|
||||
bold_font ${fonts.mono} Bold
|
||||
italic_font ${fonts.mono} Italic
|
||||
bold_italic_font ${fonts.mono} Bold Italic
|
||||
'';
|
||||
|
|
|
|||
276
modules/home/apps/tools/neovim/config/lua/plugins/lualine.lua
Normal file
276
modules/home/apps/tools/neovim/config/lua/plugins/lualine.lua
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
config = function()
|
||||
-- Eviline config for lualine
|
||||
-- Author: shadmansaleh
|
||||
-- Credit: glepnir
|
||||
local lualine = require("lualine")
|
||||
local ctp = require("catppuccin.palettes").get_palette("mocha")
|
||||
|
||||
local conditions = {
|
||||
buffer_not_empty = function()
|
||||
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
|
||||
end,
|
||||
hide_in_width = function()
|
||||
return vim.fn.winwidth(0) > 80
|
||||
end,
|
||||
check_git_workspace = function()
|
||||
local filepath = vim.fn.expand("%:p:h")
|
||||
local gitdir = vim.fn.finddir(".git", filepath .. ";")
|
||||
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
||||
end,
|
||||
}
|
||||
|
||||
-- Config
|
||||
local config = {
|
||||
options = {
|
||||
-- Disable sections and component separators
|
||||
component_separators = "",
|
||||
section_separators = "",
|
||||
theme = {
|
||||
-- We are going to use lualine_c an lualine_x as left and
|
||||
-- right section. Both are highlighted by c theme . So we
|
||||
-- are just setting default looks o statusline
|
||||
normal = { c = { fg = ctp.text, bg = ctp.base } },
|
||||
inactive = { c = { fg = ctp.overlay0, bg = ctp.base } },
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
-- These will be filled later
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
}
|
||||
|
||||
-- Function to get abbreviated mode indicators for status line
|
||||
-- Returns a single character representing the current mode
|
||||
-- Usage example: local mode = get_mode_abbr()
|
||||
local function get_mode_abbr()
|
||||
local mode_map = {
|
||||
["n"] = "N", -- Normal
|
||||
["no"] = "N", -- Operator-pending
|
||||
["nov"] = "N", -- Operator-pending (forced charwise)
|
||||
["noV"] = "N", -- Operator-pending (forced linewise)
|
||||
["no\22"] = "N", -- Operator-pending (forced blockwise)
|
||||
["niI"] = "N", -- Normal using i_CTRL-O in Insert-mode
|
||||
["niR"] = "N", -- Normal using i_CTRL-O in Replace-mode
|
||||
["niV"] = "N", -- Normal using i_CTRL-O in Virtual-Replace-mode
|
||||
["nt"] = "N", -- Normal in terminal-emulator
|
||||
["v"] = "V", -- Visual
|
||||
["vs"] = "V", -- Visual using i_CTRL-O in Select-mode
|
||||
["V"] = "VL", -- Visual Line
|
||||
["Vs"] = "VL", -- Visual Line using i_CTRL-O in Select-mode
|
||||
["\22"] = "VB", -- Visual Block
|
||||
["\22s"] = "VB", -- Visual Block using i_CTRL-O in Select-mode
|
||||
["s"] = "S", -- Select
|
||||
["S"] = "SL", -- Select Line
|
||||
["\19"] = "SB", -- Select Block
|
||||
["i"] = "I", -- Insert
|
||||
["ic"] = "I", -- Insert mode completion
|
||||
["ix"] = "I", -- Insert mode i_CTRL-X
|
||||
["R"] = "R", -- Replace
|
||||
["Rc"] = "R", -- Replace mode completion
|
||||
["Rx"] = "R", -- Replace mode i_CTRL-X
|
||||
["Rv"] = "VR", -- Virtual Replace
|
||||
["Rvc"] = "VR", -- Virtual Replace mode completion
|
||||
["Rvx"] = "VR", -- Virtual Replace mode i_CTRL-X
|
||||
["c"] = "C", -- Command-line
|
||||
["cv"] = "EX", -- Vim Ex mode
|
||||
["ce"] = "EX", -- Normal Ex mode
|
||||
["r"] = "P", -- Prompt
|
||||
["rm"] = "M", -- More prompt
|
||||
["r?"] = "C", -- Confirm
|
||||
["!"] = "S", -- Shell
|
||||
["t"] = "T", -- Terminal
|
||||
}
|
||||
|
||||
local current_mode = vim.api.nvim_get_mode().mode
|
||||
return mode_map[current_mode] or current_mode
|
||||
end
|
||||
|
||||
-- Function to get Catppuccin color for the current mode
|
||||
-- Returns the appropriate color from the ctp palette based on current mode
|
||||
-- Assumes that a local 'ctp' variable has already been defined
|
||||
-- Usage example: local mode_color = get_mode_color()
|
||||
local function get_mode_color()
|
||||
local mode_colors = {
|
||||
-- Normal mode - Blue
|
||||
["n"] = ctp.blue,
|
||||
["no"] = ctp.blue,
|
||||
["nov"] = ctp.blue,
|
||||
["noV"] = ctp.blue,
|
||||
["no\22"] = ctp.blue,
|
||||
["niI"] = ctp.green,
|
||||
["niR"] = ctp.green,
|
||||
["niV"] = ctp.green,
|
||||
["nt"] = ctp.blue,
|
||||
|
||||
-- Visual modes - Mauve (purple)
|
||||
["v"] = ctp.mauve,
|
||||
["vs"] = ctp.mauve,
|
||||
["V"] = ctp.mauve,
|
||||
["Vs"] = ctp.mauve,
|
||||
["\22"] = ctp.mauve,
|
||||
["\22s"] = ctp.mauve,
|
||||
|
||||
-- Select modes - Peach
|
||||
["s"] = ctp.peach,
|
||||
["S"] = ctp.peach,
|
||||
["\19"] = ctp.peach,
|
||||
|
||||
-- Insert mode - Green
|
||||
["i"] = ctp.green,
|
||||
["ic"] = ctp.green,
|
||||
["ix"] = ctp.green,
|
||||
|
||||
-- Replace modes - Red
|
||||
["R"] = ctp.red,
|
||||
["Rc"] = ctp.red,
|
||||
["Rx"] = ctp.red,
|
||||
["Rv"] = ctp.red,
|
||||
["Rvc"] = ctp.red,
|
||||
["Rvx"] = ctp.red,
|
||||
|
||||
-- Command/Prompt modes - Yellow
|
||||
["c"] = ctp.yellow,
|
||||
["cv"] = ctp.yellow,
|
||||
["ce"] = ctp.yellow,
|
||||
["r"] = ctp.yellow,
|
||||
["rm"] = ctp.yellow,
|
||||
["r?"] = ctp.yellow,
|
||||
|
||||
-- Terminal mode - Teal
|
||||
["t"] = ctp.teal,
|
||||
|
||||
-- Shell mode - Sapphire
|
||||
["!"] = ctp.sapphire,
|
||||
}
|
||||
|
||||
local current_mode = vim.api.nvim_get_mode().mode
|
||||
return mode_colors[current_mode] or ctp.subtext0 -- Default to a neutral color if mode not found
|
||||
end
|
||||
|
||||
-- Inserts a component in lualine_c at left section
|
||||
local function ins_left(component)
|
||||
table.insert(config.sections.lualine_c, component)
|
||||
end
|
||||
|
||||
-- Inserts a component in lualine_x at right section
|
||||
local function ins_right(component)
|
||||
table.insert(config.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
ins_left({
|
||||
function()
|
||||
return get_mode_abbr()
|
||||
end,
|
||||
color = function()
|
||||
local color = get_mode_color()
|
||||
return { fg = ctp.base, bg = color, gui = "bold" }
|
||||
end, -- Sets highlighting of component
|
||||
padding = { left = 1, right = 1 }, -- We don't need space before this
|
||||
})
|
||||
|
||||
ins_left({
|
||||
"filename",
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = ctp.sapphire },
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- filesize component
|
||||
"filesize",
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = ctp.subtext0 },
|
||||
})
|
||||
|
||||
ins_left({ "location", color = { fg = ctp.subtext0 } })
|
||||
|
||||
ins_left({
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = " ", warn = " ", info = " " },
|
||||
diagnostics_color = {
|
||||
error = { fg = ctp.red },
|
||||
warn = { fg = ctp.yellow },
|
||||
info = { fg = ctp.teal },
|
||||
},
|
||||
})
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left({
|
||||
function()
|
||||
return "%="
|
||||
end,
|
||||
})
|
||||
|
||||
ins_right({
|
||||
-- Lsp server name .
|
||||
function()
|
||||
local msg = "none"
|
||||
local buf_ft = vim.api.nvim_get_option_value("filetype", { buf = 0 })
|
||||
local clients = vim.lsp.get_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end,
|
||||
icon = "",
|
||||
color = { fg = ctp.overlay1, gui = "bold" },
|
||||
})
|
||||
|
||||
-- Add components to right sections
|
||||
ins_right({
|
||||
"branch",
|
||||
icon = "",
|
||||
color = { fg = ctp.mauve, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"diff",
|
||||
-- Is it me or the symbol for modified us really weird
|
||||
symbols = { added = " ", modified = " ", removed = " " },
|
||||
diff_color = {
|
||||
added = { fg = ctp.green },
|
||||
modified = { fg = ctp.peach },
|
||||
removed = { fg = ctp.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
})
|
||||
|
||||
ins_right({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = function()
|
||||
local color = get_mode_color()
|
||||
return { fg = color }
|
||||
end, -- Sets highlighting of component
|
||||
padding = { left = 1 },
|
||||
})
|
||||
|
||||
-- Now don't forget to initialize lualine
|
||||
lualine.setup(config)
|
||||
end,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue