diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 490598f..c8fdfd7 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -82,7 +82,7 @@ M.plugin_status = { comment = true, -- universal commentor dashboard = true, -- a nice looking dashboard esc_insertmode = true, -- escape from insert mode using custom keys - galaxyline = true, -- statusline + feline = true, -- statusline gitsigns = true, -- gitsigns in statusline lspkind = true, -- lsp enhancements lspsignature = true, -- lsp enhancements diff --git a/lua/default_config.lua b/lua/default_config.lua index 7f6e355..c4920ec 100644 --- a/lua/default_config.lua +++ b/lua/default_config.lua @@ -86,7 +86,7 @@ M.plugin_status = { comment = true, -- universal commentor dashboard = true, -- a nice looking dashboard esc_insertmode = true, -- escape from insert mode using custom keys - galaxyline = true, -- statusline + feline = true, -- statusline gitsigns = true, -- gitsigns in statusline lspkind = true, -- lsp enhancements lspsignature = true, -- lsp enhancements diff --git a/lua/plugins/configs/statusline.lua b/lua/plugins/configs/statusline.lua index b2a71c8..f9b9a47 100644 --- a/lua/plugins/configs/statusline.lua +++ b/lua/plugins/configs/statusline.lua @@ -1,14 +1,5 @@ local colors = require("colors").get() - -local present1, gl = pcall(require, "galaxyline") -local present2, condition = pcall(require, "galaxyline.condition") -if not (present1 or present2) then - return -end - -local gls = gl.section - -gl.short_line_list = { " " } +local lsp = require "feline.providers.lsp" local icon_styles = { default = { @@ -18,7 +9,6 @@ local icon_styles = { vi_mode_icon = " ", position_icon = " ", }, - arrow = { left = "", right = "", @@ -55,264 +45,263 @@ local icon_styles = { local user_statusline_style = require("core.utils").load_config().ui.plugin.statusline.style local statusline_style = icon_styles[user_statusline_style] -local left_separator = statusline_style.left -local right_separator = statusline_style.right +-- Initialize the components table +local components = { + left = { active = {}, inactive = {} }, + mid = { active = {}, inactive = {} }, + right = { active = {}, inactive = {} }, +} -gls.left[1] = { - FirstElement = { - provider = function() - return "▋" - end, - highlight = { colors.nord_blue, colors.nord_blue }, +components.left.active[1] = { + provider = statusline_style.main_icon, + + hl = { + fg = colors.statusline_bg, + bg = colors.nord_blue, + }, + + right_sep = { str = statusline_style.right, hl = { + fg = colors.nord_blue, + bg = colors.one_bg2, + } }, +} + +components.left.active[2] = { + provider = statusline_style.right, + + hl = { + fg = colors.one_bg2, + bg = colors.lightbg, }, } -gls.left[2] = { - statusIcon = { - provider = function() - return statusline_style.main_icon - end, - highlight = { colors.statusline_bg, colors.nord_blue }, - separator = right_separator, - separator_highlight = { colors.nord_blue, colors.one_bg2 }, +components.left.active[3] = { + provider = function() + local filename = vim.fn.expand "%:t" + local extension = vim.fn.expand "%:e" + local icon = require("nvim-web-devicons").get_icon(filename, extension) + if icon == nil then + icon = "" + return icon + end + return icon .. " " .. filename .. " " + end, + hl = { + fg = colors.white, + bg = colors.lightbg, }, + + right_sep = { str = statusline_style.right, hl = { fg = colors.lightbg, bg = colors.lightbg2 } }, } -gls.left[3] = { - left_arow2 = { - provider = function() end, - separator = right_separator .. " ", - separator_highlight = { colors.one_bg2, colors.lightbg }, +components.left.active[4] = { + provider = function() + local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") + return " " .. dir_name .. " " + end, + + hl = { + fg = colors.grey_fg2, + bg = colors.lightbg2, }, + right_sep = { str = statusline_style.right, hi = { + fg = colors.lightbg2, + bg = colors.statusline_bg, + } }, } -gls.left[4] = { - FileIcon = { - provider = "FileIcon", - condition = condition.buffer_not_empty, - highlight = { colors.white, colors.lightbg }, +components.left.active[5] = { + provider = "git_diff_added", + hl = { + fg = colors.grey_fg2, + bg = colors.statusline_bg, }, + icon = " ", +} +-- diffModfified +components.left.active[6] = { + provider = "git_diff_changed", + hl = { + fg = colors.grey_fg2, + bg = colors.statusline_bg, + }, + icon = "  ", +} +-- diffRemove +components.left.active[7] = { + provider = "git_diff_removed", + hl = { + fg = colors.grey_fg2, + bg = colors.statusline_bg, + }, + icon = "  ", } -gls.left[5] = { - FileName = { - provider = function() - local fileinfo = require "galaxyline.provider_fileinfo" - - if vim.api.nvim_buf_get_name(0):len() == 0 then - return "" - end - - return fileinfo.get_current_file_name("", "") - end, - highlight = { colors.white, colors.lightbg }, - separator = right_separator, - separator_highlight = { colors.lightbg, colors.lightbg2 }, - }, +components.left.active[8] = { + provider = "diagnostic_errors", + enabled = function() + return lsp.diagnostics_exist "Error" + end, + hl = { fg = colors.red }, + icon = "  ", } -gls.left[6] = { - current_dir = { - provider = function() - local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") - return "  " .. dir_name .. " " - end, - highlight = { colors.grey_fg2, colors.lightbg2 }, - separator = right_separator, - separator_highlight = { colors.lightbg2, colors.statusline_bg }, - }, +components.left.active[9] = { + provider = "diagnostic_warnings", + enabled = function() + return lsp.diagnostics_exist "Warning" + end, + hl = { fg = colors.yellow }, + icon = "  ", } -local checkwidth = function() - local squeeze_width = vim.fn.winwidth(0) / 2 - if squeeze_width > 30 then - return true - end - return false -end - -gls.left[7] = { - DiffAdd = { - provider = "DiffAdd", - condition = checkwidth, - icon = "  ", - highlight = { colors.white, colors.statusline_bg }, - }, +components.left.active[10] = { + provider = "diagnostic_hints", + enabled = function() + return lsp.diagnostics_exist "Hint" + end, + hl = { fg = colors.grey_fg2 }, + icon = "  ", } -gls.left[8] = { - DiffModified = { - provider = "DiffModified", - condition = checkwidth, - icon = "  ", - highlight = { colors.grey_fg2, colors.statusline_bg }, - }, +components.left.active[11] = { + provider = "diagnostic_info", + enabled = function() + return lsp.diagnostics_exist "Information" + end, + hl = { fg = colors.green }, + icon = "  ", } -gls.left[9] = { - DiffRemove = { - provider = "DiffRemove", - condition = checkwidth, - icon = "  ", - highlight = { colors.grey_fg2, colors.statusline_bg }, - }, +components.right.active[1] = { + provider = function() + if lsp.is_lsp_attached then + return " " .. "  " .. " LSP" + end + end, + hl = { fg = colors.grey_fg2, bg = colors.statusline_bg }, } -gls.left[10] = { - DiagnosticError = { - provider = "DiagnosticError", - icon = "  ", - highlight = { colors.red, colors.statusline_bg }, +components.right.active[2] = { + provider = "git_branch", + hl = { + fg = colors.grey_fg2, + bg = colors.statusline_bg, }, + icon = "  ", } -gls.left[11] = { - DiagnosticWarn = { - provider = "DiagnosticWarn", - icon = "  ", - highlight = { colors.yellow, colors.statusline_bg }, - }, -} - -gls.right[1] = { - lsp_status = { - provider = function() - local clients = vim.lsp.get_active_clients() - if next(clients) ~= nil then - local buf_ft = vim.api.nvim_buf_get_option(0, "filetype") - for _, client in ipairs(clients) do - local filetypes = client.config.filetypes - if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then - return " " .. "  " .. " LSP" - end - end - return "" - else - return "" - end - end, - highlight = { colors.grey_fg2, colors.statusline_bg }, - }, -} - -gls.right[2] = { - GitIcon = { - provider = function() - return " " - end, - condition = require("galaxyline.condition").check_git_workspace, - highlight = { colors.grey_fg2, colors.statusline_bg }, - separator = " ", - separator_highlight = { colors.statusline_bg, colors.statusline_bg }, - }, -} - -gls.right[3] = { - GitBranch = { - provider = "GitBranch", - condition = require("galaxyline.condition").check_git_workspace, - highlight = { colors.grey_fg2, colors.statusline_bg }, +components.right.active[3] = { + provider = " " .. statusline_style.left, + hl = { + fg = colors.one_bg2, + bg = colors.statusline_bg, }, } local mode_colors = { - ['n'] = { "NORMAL", colors.red }, - ['no'] = { "N-PENDING", colors.red }, - ['i'] = { "INSERT", colors.dark_purple }, - ['ic'] = { "INSERT", colors.dark_purple }, - ['t'] = { "TERMINAL", colors.green }, - ['v'] = { "VISUAL", colors.cyan }, - ['V'] = { "V-LINE", colors.cyan }, - [''] = { "V-BLOCK", colors.cyan }, - ['R'] = { "REPLACE", colors.orange }, - ['Rv'] = { "V-REPLACE", colors.orange }, - ['s'] = { "SELECT", colors.nord_blue }, - ['S'] = { "S-LINE", colors.nord_blue }, - [''] = { "S-BLOCK", colors.nord_blue }, - ['c'] = { "COMMAND", colors.pink }, - ['cv'] = { "COMMAND", colors.pink }, - ['ce'] = { "COMMAND", colors.pink }, - ['r'] = { "PROMPT", colors.teal }, - ['rm'] = { "MORE", colors.teal }, - ['r?'] = { "CONFIRM", colors.teal }, - ['!'] = { "SHELL", colors.green }, + ["n"] = { "NORMAL", colors.red }, + ["no"] = { "N-PENDING", colors.red }, + ["i"] = { "INSERT", colors.dark_purple }, + ["ic"] = { "INSERT", colors.dark_purple }, + ["t"] = { "TERMINAL", colors.green }, + ["v"] = { "VISUAL", colors.cyan }, + ["V"] = { "V-LINE", colors.cyan }, + [""] = { "V-BLOCK", colors.cyan }, + ["R"] = { "REPLACE", colors.orange }, + ["Rv"] = { "V-REPLACE", colors.orange }, + ["s"] = { "SELECT", colors.nord_blue }, + ["S"] = { "S-LINE", colors.nord_blue }, + [""] = { "S-BLOCK", colors.nord_blue }, + ["c"] = { "COMMAND", colors.pink }, + ["cv"] = { "COMMAND", colors.pink }, + ["ce"] = { "COMMAND", colors.pink }, + ["r"] = { "PROMPT", colors.teal }, + ["rm"] = { "MORE", colors.teal }, + ["r?"] = { "CONFIRM", colors.teal }, + ["!"] = { "SHELL", colors.green }, } -local mode = function(n) - return mode_colors[vim.fn.mode()][n] +local chad_mode_hl = function() + return { + fg = mode_colors[vim.fn.mode()][2], + bg = colors.one_bg, + } end -gls.right[4] = { - left_arrow = { - provider = function() end, - separator = " " .. left_separator, - separator_highlight = { colors.one_bg2, colors.statusline_bg }, +components.right.active[4] = { + provider = statusline_style.left, + hl = function() + return { + fg = mode_colors[vim.fn.mode()][2], + bg = colors.one_bg2, + } + end, +} + +components.right.active[5] = { + provider = statusline_style.vi_mode_icon, + hl = function() + return { + fg = colors.statusline_bg, + bg = mode_colors[vim.fn.mode()][2], + } + end, +} + +components.right.active[6] = { + provider = function() + return " " .. mode_colors[vim.fn.mode()][1] .. " " + end, + hl = chad_mode_hl, +} + +components.right.active[7] = { + provider = statusline_style.left, + hl = { + fg = colors.grey, + bg = colors.one_bg, }, } -gls.right[5] = { - left_round = { - provider = function() - vim.cmd("hi Galaxyleft_round guifg=" .. mode(2)) - return left_separator - end, - highlight = { "GalaxyViMode", colors.one_bg2 }, +components.right.active[8] = { + provider = statusline_style.left, + hl = { + fg = colors.green, + bg = colors.grey, }, } -gls.right[6] = { - viMode_icon = { - provider = function() - vim.cmd("hi GalaxyviMode_icon guibg=" .. mode(2)) - return statusline_style.vi_mode_icon - end, - highlight = { colors.statusline_bg, colors.red }, +components.right.active[9] = { + provider = statusline_style.position_icon, + hl = { + fg = colors.black, + bg = colors.green, }, } -gls.right[7] = { - ViMode = { - provider = function() - vim.cmd("hi GalaxyViMode guifg=" .. mode(2)) - return " " .. mode(1) .. " " - end, - highlight = { "GalaxyViMode", colors.lightbg }, +components.right.active[10] = { + provider = function() + local current_line = vim.fn.line "." + local total_line = vim.fn.line "$" + + if current_line == 1 then + return " Top " + elseif current_line == vim.fn.line "$" then + return " Bot " + end + local result, _ = math.modf((current_line / total_line) * 100) + return " " .. result .. " % " + end, + + hl = { + fg = colors.green, + bg = colors.one_bg, }, } -gls.right[8] = { - left_arrow2 = { - provider = function() end, - separator = left_separator, - separator_highlight = { colors.grey, colors.lightbg }, - }, -} - -gls.right[9] = { - some_RoundIcon = { - provider = function() - return statusline_style.position_icon - end, - separator = left_separator, - separator_highlight = { colors.green, colors.grey }, - highlight = { colors.lightbg, colors.green }, - }, -} - -gls.right[10] = { - line_percentage = { - provider = function() - local current_line = vim.fn.line "." - local total_line = vim.fn.line "$" - - if current_line == 1 then - return " Top " - elseif current_line == vim.fn.line "$" then - return " Bot " - end - local result, _ = math.modf((current_line / total_line) * 100) - return " " .. result .. "% " - end, - highlight = { colors.green, colors.lightbg }, - }, +require("feline").setup { + default_bg = colors.statusline_bg, + default_fg = colors.fg, + components = components, } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index f760882..fd167e1 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -38,8 +38,8 @@ return packer.startup(function() } use { - "glepnir/galaxyline.nvim", - disable = not plugin_status.galaxyline, + "famiu/feline.nvim", + disable = not plugin_status.feline, after = "nvim-web-devicons", config = function() require "plugins.configs.statusline" @@ -49,7 +49,7 @@ return packer.startup(function() use { "akinsho/bufferline.nvim", disable = not plugin_status.bufferline, - after = "galaxyline.nvim", + after = "feline.nvim", config = function() require "plugins.configs.bufferline" end,