lualine.lua (5170B)
1 -- Eviline config for lualine 2 -- Author: shadmansaleh 3 -- Credit: glepnir 4 local lualine = require("lualine") 5 6 -- Color table for highlights 7 -- stylua: ignore 8 local colors = { 9 bg = 'none', 10 fg = '#DCD7BA', 11 yellow = '#E6C384', 12 cyan = '#7AA89F', 13 darkblue = '#223249', 14 green = '#98BB6C', 15 orange = '#C0A36E', 16 violet = '#938AA9', 17 magenta = '#957FB8', 18 blue = '#7E9CD8', 19 red = '#C34043', 20 } 21 22 local conditions = { 23 buffer_not_empty = function() 24 return vim.fn.empty(vim.fn.expand("%:t")) ~= 1 25 end, 26 hide_in_width = function() 27 return vim.fn.winwidth(0) > 80 28 end, 29 check_git_workspace = function() 30 local filepath = vim.fn.expand("%:p:h") 31 local gitdir = vim.fn.finddir(".git", filepath .. ";") 32 return gitdir and #gitdir > 0 and #gitdir < #filepath 33 end, 34 } 35 36 -- Config 37 local config = { 38 options = { 39 globalstatus = true, 40 disabled_filetypes = {}, 41 -- Disable sections and component separators 42 component_separators = "", 43 section_separators = "", 44 theme = { 45 -- We are going to use lualine_c an lualine_x as left and 46 -- right section. Both are highlighted by c theme . So we 47 -- are just setting default looks o statusline 48 normal = { c = { fg = colors.fg, bg = colors.bg } }, 49 inactive = { c = { fg = colors.fg, bg = colors.bg } }, 50 }, 51 }, 52 sections = { 53 -- these are to remove the defaults 54 lualine_a = {}, 55 lualine_b = {}, 56 lualine_y = {}, 57 lualine_z = {}, 58 -- These will be filled later 59 lualine_c = {}, 60 lualine_x = {}, 61 }, 62 inactive_sections = { 63 -- these are to remove the defaults 64 lualine_a = {}, 65 lualine_b = {}, 66 lualine_y = {}, 67 lualine_z = {}, 68 lualine_c = {}, 69 lualine_x = {}, 70 }, 71 } 72 73 -- Inserts a component in lualine_c at left section 74 local function ins_left(component) 75 table.insert(config.sections.lualine_c, component) 76 end 77 78 -- Inserts a component in lualine_x at right section 79 local function ins_right(component) 80 table.insert(config.sections.lualine_x, component) 81 end 82 83 ins_left({ 84 function() 85 return "▊" 86 end, 87 color = { fg = colors.blue }, 88 padding = { left = 0, right = 1 }, -- We don't need space before this 89 }) 90 91 ins_left({ 92 -- mode component 93 function() 94 return "" 95 end, 96 color = function() 97 -- auto change color according to neovims mode 98 local mode_color = { 99 n = colors.red, 100 i = colors.green, 101 v = colors.blue, 102 [""] = colors.blue, 103 V = colors.blue, 104 c = colors.magenta, 105 no = colors.red, 106 s = colors.orange, 107 S = colors.orange, 108 [""] = colors.orange, 109 ic = colors.yellow, 110 R = colors.violet, 111 Rv = colors.violet, 112 cv = colors.red, 113 ce = colors.red, 114 r = colors.cyan, 115 rm = colors.cyan, 116 ["r?"] = colors.cyan, 117 ["!"] = colors.red, 118 t = colors.red, 119 } 120 return { fg = mode_color[vim.fn.mode()] } 121 end, 122 padding = { right = 1 }, 123 }) 124 125 ins_left({ 126 -- filesize component 127 "filesize", 128 cond = conditions.buffer_not_empty, 129 }) 130 131 ins_left({ 132 "filename", 133 cond = conditions.buffer_not_empty, 134 color = { fg = colors.magenta, gui = "bold" }, 135 }) 136 137 -- ins_left({ "location" }) 138 139 ins_left({ "progress", color = { fg = colors.fg, gui = "bold" } }) 140 141 ins_left({ 142 "diagnostics", 143 sources = { "nvim_diagnostic" }, 144 symbols = { error = " ", warn = " ", info = " " }, 145 diagnostics_color = { 146 error = { fg = colors.red }, 147 warn = { fg = colors.yellow }, 148 info = { fg = colors.cyan }, 149 }, 150 }) 151 152 -- Insert mid section. You can make any number of sections in neovim :) 153 -- for lualine it's any number greater then 2 154 ins_left({ 155 function() 156 return "%=" 157 end, 158 }) 159 160 ins_right({ 161 -- Lsp server name . 162 function() 163 local bufnr = vim.api.nvim_get_current_buf() 164 local clients = vim.lsp.get_clients({ bufnr = bufnr }) 165 166 if next(clients) == nil then 167 return "No LSP" 168 end 169 170 local excluded_clients = { 171 ["GitHub Copilot"] = true, 172 -- ["null-ls"] = true, 173 } 174 175 local client_names = {} 176 for _, client in pairs(clients) do 177 if not excluded_clients[client.name] then 178 table.insert(client_names, client.name) 179 end 180 end 181 return table.concat(client_names, ", ") 182 end, 183 icon = " LSP:", 184 color = { fg = "#ffffff", gui = "bold" }, 185 }) 186 187 -- Add components to right sections 188 -- ins_right({ 189 -- "o:encoding", -- option component same as &encoding in viml 190 -- fmt = string.upper, -- I'm not sure why it's upper case either ;) 191 -- cond = conditions.hide_in_width, 192 -- color = { fg = colors.green, gui = "bold" }, 193 -- }) 194 -- 195 -- ins_right({ 196 -- "fileformat", 197 -- fmt = string.upper, 198 -- icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh 199 -- color = { fg = colors.green, gui = "bold" }, 200 -- }) 201 202 -- ins_right({ 203 -- "branch", 204 -- icon = "", 205 -- color = { fg = colors.violet, gui = "bold" }, 206 -- }) 207 -- 208 -- ins_right({ 209 -- "diff", 210 -- -- Is it me or the symbol for modified us really weird 211 -- symbols = { added = " ", modified = " ", removed = " " }, 212 -- diff_color = { 213 -- added = { fg = colors.green }, 214 -- modified = { fg = colors.orange }, 215 -- removed = { fg = colors.red }, 216 -- }, 217 -- cond = conditions.hide_in_width, 218 -- }) 219 -- 220 ins_right({ 221 function() 222 return "▊" 223 end, 224 color = { fg = colors.blue }, 225 padding = { left = 1 }, 226 }) 227 228 -- Now don't forget to initialize lualine 229 lualine.setup(config)