Skip to content

Commit

Permalink
Moved from feline to lualine
Browse files Browse the repository at this point in the history
  • Loading branch information
crivotz committed Feb 29, 2024
1 parent f24b683 commit 95d68aa
Show file tree
Hide file tree
Showing 3 changed files with 312 additions and 15 deletions.
9 changes: 5 additions & 4 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"csv.vim": { "branch": "master", "commit": "962f88787ec6873eba1c7dbbd81d2723f1ee3c4b" },
"dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" },
"edgy.nvim": { "branch": "main", "commit": "0b35dc6da4cae6cc2f724bc610eadf955cd2319b" },
"feline.nvim": { "branch": "main", "commit": "6cfbe0608d2552a7d947c6f521670b10379fbe42" },
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
"formatter.nvim": { "branch": "master", "commit": "cb4778b8432f1ae86dae4634c0b611cb269a4c2f" },
"friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" },
Expand All @@ -25,6 +24,8 @@
"indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" },
"lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" },
"lspkind-nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
"lualine-ex": { "branch": "main", "commit": "8de69fdb5f5f63bb60200503185dda9f3eb1dacf" },
"lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "21d33d69a81f6351e5a5f49078b2e4f0075c8e73" },
"mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" },
"multicursors.nvim": { "branch": "main", "commit": "8b3e14682eed06a532b155c7eae33e174846b3fd" },
Expand All @@ -47,14 +48,14 @@
"nvim-spectre": { "branch": "master", "commit": "3712ff0cdf4f9f877d9ca708d835a877d9a0abaf" },
"nvim-spider": { "branch": "main", "commit": "dc371a116041c49ae6d3813f6e1722c2dcdabdcf" },
"nvim-toggleterm.lua": { "branch": "main", "commit": "193786e0371e3286d3bc9aa0079da1cd41beaa62" },
"nvim-treesitter": { "branch": "master", "commit": "18aa5ae3fd7245137bc41b5348102fe254405509" },
"nvim-ufo": { "branch": "main", "commit": "553d8a9c611caa9f020556d4a26b760698e5b81b" },
"nvim-treesitter": { "branch": "master", "commit": "db12bd416e2764420047e4a5d6b96fe44e4377d5" },
"nvim-ufo": { "branch": "main", "commit": "239ae620d818ffa1319ca3056546df71906d4bfb" },
"nvim-web-devicons": { "branch": "master", "commit": "0bb67ef952ea3eb7b1bac9c011281471d99a27bc" },
"oil-vcs-status": { "branch": "main", "commit": "1861ad95734b438e7ff64eee4706c564c044c130" },
"oil.nvim": { "branch": "master", "commit": "132b4ea0740c417b9d717411cab4cf187e1fd095" },
"plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" },
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
"promise-async": { "branch": "main", "commit": "274edb07194ccd6cd54c04bbdd7ffdaaff20c78c" },
"promise-async": { "branch": "main", "commit": "93540c168c5ed2b030ec3e6c40ab8bbb85e36355" },
"ror.nvim": { "branch": "main", "commit": "2fd809a0e97da98334f4605326ff22f0047ff601" },
"statuscol.nvim": { "branch": "main", "commit": "d954893262a57a92e46edd87de67e2b3fe72305e" },
"suda.vim": { "branch": "master", "commit": "8b0fc3711760195aba104e2d190cff9af8267052" },
Expand Down
2 changes: 1 addition & 1 deletion lua/config/plugins/feline.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local M = {
"freddiehaddad/feline.nvim",
lazy = false,
enabled = true
enabled = false
}
function M.config()
local lsp = require('feline.providers.lsp')
Expand Down
316 changes: 306 additions & 10 deletions lua/config/plugins/lualine.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,94 @@
local M = {
"nvim-lualine/lualine.nvim",
lazy = false,
enabled = false
enabled = true
}
function M.config()
local arrow = require("arrow.statusline")
local navic = require("nvim-navic")
local lazy = require("lazy.status")
local colors = {
bg = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "Normal", link = false }).bg),
fg = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "Normal", link = false }).fg),
black = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "EndOfBuffer", link = false }).fg),
white = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "Normal", link = false }).fg),
red = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "Error", link = false }).fg),
green = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "String", link = false }).fg),
blue = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "Folded", link = false }).fg),
yellow = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "TSRainbowYellow", link = false }).fg),
cyan = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "Keyword", link = false }).fg),
orange = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "MatchParen", link = false }).fg),
purple = string.format('#%06x', vim.api.nvim_get_hl(0, { name = "IblScope", link = false }).fg),
}
local filename_with_icon = require("lualine.components.filename"):extend()
filename_with_icon.apply_icon = require("lualine.components.filetype").apply_icon
filename_with_icon.icon_hl_cache = {}

local function shorten_path(path, sep)
-- ('([^/])[^/]+%/', '%1/', 1)
return path:gsub(string.format("([^%s])[^%s]+%%%s", sep, sep, sep), "%1" .. sep, 1)
end

local function count(base, pattern)
return select(2, string.gsub(base, pattern, ""))
end

local default_options = {
symbols = { modified = "", readonly = "󰌾", unnamed = "[No Name]" },
file_status = true,
path = 0,
shorting_target = 40,
}

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,
}

local scrollbar_component = require("lualine.component"):extend()

function scrollbar_component:init(opts)
opts.reverse = opts.reverse or false
scrollbar_component.super.init(self, opts)
end

function scrollbar_component:update_status()
local scroll_bar_blocks = { '', '', '', '', '', '', '', '' }
local curr_line = vim.api.nvim_win_get_cursor(0)[1]
local lines = vim.api.nvim_buf_line_count(0)

if self.options.reverse then
return string.rep(scroll_bar_blocks[8 - math.floor(curr_line / lines * 7)], 2)
else
return string.rep(scroll_bar_blocks[math.floor(curr_line / lines * 7) + 1], 2)
end
end

local options = vim.tbl_deep_extend("keep", {}, default_options)

require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
theme = {
normal = {
a = {bg = colors.bg, fg = colors.fg},
b = {bg = colors.bg, fg = colors.fg},
c = {bg = colors.bg, fg = colors.fg}
},
},
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
statusline = { "neo-tree", "alpha" },
winbar = {},
},
ignore_focus = {},
Expand All @@ -23,13 +100,184 @@ function M.config()
winbar = 1000,
}
},
extension = {
"mason",
"lazy",
"neo-tree",
"oil",
"quickfix",
"toggleterm",
"trouble",
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
lualine_a = {
{
function()
return ''
end,
color = function()
local mode_color = {
n = colors.green,
i = colors.red,
v = colors.blue,
[""] = colors.blue,
V = colors.blue,
c = colors.purple,
no = colors.red,
s = colors.orange,
S = colors.orange,
[""] = colors.orange,
ic = colors.yellow,
R = colors.purple,
Rv = colors.purple,
cv = colors.red,
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
["r?"] = colors.cyan,
["!"] = colors.red,
t = colors.green,
}
return { fg = mode_color[vim.fn.mode()], bg = colors.bg }
end
}
},
lualine_b = {
{
function()
local dir = vim.fn.expand("%:p:h")

if dir == vim.fn.getcwd() then
return " Root"
else
local windwidth = options.globalstatus and vim.go.columns or vim.fn.winwidth(0)
local estimated_space_available = windwidth - options.shorting_target

local data = vim.fn.fnamemodify(dir, ":~:.")
for _ = 0, count(data, "/") do
if windwidth <= 84 or #data > estimated_space_available then
data = shorten_path(data, "/")
end
end

return "" .. data
end
end,
cond = conditions.buffer_not_empty,
color = { fg = colors.violet },
},
{
'filename',
symbols = { modified = "", readonly = "󰌾", unnamed = "[No Name]" },
file_status = true,
path = 0,
shorting_target = 40,
cond = conditions.buffer_not_empty,
colored = true,
color = function()
if arrow.in_on_arrow_file() then
return { fg = colors.green, gui='bold' }
else
return { fg = colors.yellow, gui='bold' }
end
end,
},
{
function()
return arrow.text_for_statusline_with_icons()
end,
color = { fg = colors.red }
}
},
lualine_c = {
{
function()
return "%="
end,
},
{
function() return require("noice").api.status.command.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end,
color = {fg = colors.red, gui='bold' }
},
{
function() return require("noice").api.status.mode.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end,
color = {fg = colors.orange, gui='bold' }
},
},
lualine_x = {
{
"diagnostics",
update_in_insert = true,
symbols = { error = "", warn = "", info = "" },

diagnostics_color = {
color_error = { fg = colors.red },
color_warn = { fg = colors.yellow },
color_info = { fg = colors.cyan },
},
color = { bg = colors.bg }
},
{
function()
local lsps = vim.lsp.get_active_clients({ bufnr = vim.fn.bufnr() })
local icon = require("nvim-web-devicons").get_icon_by_filetype(
vim.api.nvim_buf_get_option(0, "filetype")
)
if lsps and #lsps > 0 then
local names = {}
for _, lsp in ipairs(lsps) do
table.insert(names, lsp.name)
end
return string.format("%s %s", table.concat(names, ", "), icon)
else
return icon or ""
end
end,
on_click = function()
vim.api.nvim_command("LspInfo")
end,
color = function()
local _, color = require("nvim-web-devicons").get_icon_cterm_color_by_filetype(
vim.api.nvim_buf_get_option(0, "filetype")
)
return { fg = color }
end,
},
},
lualine_y = {
{
function()
return ""
end,
cond = lazy.has_updates,
color = { fg = colors.cyan },
},
{
"fileformat",
symbols = {
unix = '󰌽', -- e712
dos = '󰍲', -- e70f
mac = '', -- e711
},
color = { fg = colors.purple, gui='bold' },
},
{
"encoding",
fmt = string.upper,
color = { fg = colors.blue, gui='bold' },
},
},
lualine_z = {
{
function()
return "󰕭 %-2v"
end,
color = { fg = colors.yellow, gui='bold' },
},
scrollbar_component,
},
},
inactive_sections = {
lualine_a = {},
Expand All @@ -40,7 +288,55 @@ function M.config()
lualine_z = {}
},
tabline = {},
winbar = {},
winbar = {
lualine_a = {
{
function() return require("nvim-navic").get_location() end,
cond = function() return package.loaded["nvim-navic"] and require("nvim-navic").is_available() end,
color = { fg = colors.blue },
},
},
lualine_b = {},
lualine_c = {
{
function()
return "%="
end,
},
},
lualine_x = {},
lualine_y = {},
lualine_z = {
{
'b:gitsigns_head',
icon ='󰘬',
color = {
bg = colors.bg,
fg = colors.yellow,
}
},
{
'diff',
symbols = { added = "", modified = "", removed = "" },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
source = function()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end,
color = { bg = colors.bg }
},
}
},
inactive_winbar = {},
extensions = {}
}
Expand Down

0 comments on commit 95d68aa

Please sign in to comment.