| 1 |
local colors = { |
| 2 |
red = '#ca1243', |
| 3 |
grey = '#a0a1a7', |
| 4 |
black = '#383a42', |
| 5 |
white = '#f3f3f3', |
| 6 |
light_green = '#83a598', |
| 7 |
orange = '#fe8019', |
| 8 |
green = '#8ec07c', |
| 9 |
} |
| 10 |
|
| 11 |
local theme = { |
| 12 |
normal = { |
| 13 |
a = { fg = colors.white, bg = colors.black }, |
| 14 |
b = { fg = colors.white, bg = colors.grey }, |
| 15 |
c = { fg = colors.black, bg = colors.white }, |
| 16 |
z = { fg = colors.white, bg = colors.black }, |
| 17 |
}, |
| 18 |
insert = { a = { fg = colors.black, bg = colors.light_green } }, |
| 19 |
visual = { a = { fg = colors.black, bg = colors.orange } }, |
| 20 |
replace = { a = { fg = colors.black, bg = colors.green } }, |
| 21 |
} |
| 22 |
|
| 23 |
local empty = require('lualine.component'):extend() |
| 24 |
function empty:draw(default_highlight) |
| 25 |
self.status = '' |
| 26 |
self.applied_separator = '' |
| 27 |
self:apply_highlights(default_highlight) |
| 28 |
self:apply_section_separators() |
| 29 |
return self.status |
| 30 |
end |
| 31 |
|
| 32 |
-- Put proper separators and gaps between components in sections |
| 33 |
local function process_sections(sections) |
| 34 |
for name, section in pairs(sections) do |
| 35 |
local left = name:sub(9, 10) < 'x' |
| 36 |
for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do |
| 37 |
table.insert(section, pos * 2, { empty, color = { fg = colors.white, bg = colors.white } }) |
| 38 |
end |
| 39 |
for id, comp in ipairs(section) do |
| 40 |
if type(comp) ~= 'table' then |
| 41 |
comp = { comp } |
| 42 |
section[id] = comp |
| 43 |
end |
| 44 |
comp.separator = left and { right = '' } or { left = '' } |
| 45 |
end |
| 46 |
end |
| 47 |
return sections |
| 48 |
end |
| 49 |
|
| 50 |
local function search_result() |
| 51 |
if vim.v.hlsearch == 0 then |
| 52 |
return '' |
| 53 |
end |
| 54 |
local last_search = vim.fn.getreg('/') |
| 55 |
if not last_search or last_search == '' then |
| 56 |
return '' |
| 57 |
end |
| 58 |
local searchcount = vim.fn.searchcount { maxcount = 9999 } |
| 59 |
return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' |
| 60 |
end |
| 61 |
|
| 62 |
local function modified() |
| 63 |
if vim.bo.modified then |
| 64 |
return '+' |
| 65 |
elseif vim.bo.modifiable == false or vim.bo.readonly == true then |
| 66 |
return '-' |
| 67 |
end |
| 68 |
return '' |
| 69 |
end |
| 70 |
|
| 71 |
require('lualine').setup { |
| 72 |
options = { |
| 73 |
theme = theme, |
| 74 |
component_separators = '', |
| 75 |
section_separators = { left = '', right = '' }, |
| 76 |
}, |
| 77 |
sections = process_sections { |
| 78 |
lualine_a = { 'mode' }, |
| 79 |
lualine_b = { |
| 80 |
'branch', |
| 81 |
'diff', |
| 82 |
{ |
| 83 |
'diagnostics', |
| 84 |
source = { 'nvim' }, |
| 85 |
sections = { 'error' }, |
| 86 |
diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, |
| 87 |
}, |
| 88 |
{ |
| 89 |
'diagnostics', |
| 90 |
source = { 'nvim' }, |
| 91 |
sections = { 'warn' }, |
| 92 |
diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, |
| 93 |
}, |
| 94 |
{ 'filename', file_status = false, path = 1 }, |
| 95 |
{ modified, color = { bg = colors.red } }, |
| 96 |
{ |
| 97 |
'%w', |
| 98 |
cond = function() |
| 99 |
return vim.wo.previewwindow |
| 100 |
end, |
| 101 |
}, |
| 102 |
{ |
| 103 |
'%r', |
| 104 |
cond = function() |
| 105 |
return vim.bo.readonly |
| 106 |
end, |
| 107 |
}, |
| 108 |
{ |
| 109 |
'%q', |
| 110 |
cond = function() |
| 111 |
return vim.bo.buftype == 'quickfix' |
| 112 |
end, |
| 113 |
}, |
| 114 |
}, |
| 115 |
lualine_c = {}, |
| 116 |
lualine_x = {}, |
| 117 |
lualine_y = { search_result, 'filetype' }, |
| 118 |
lualine_z = { '%l:%c', '%p%%/%L' }, |
| 119 |
}, |
| 120 |
inactive_sections = { |
| 121 |
lualine_c = { '%f %y %m' }, |
| 122 |
lualine_x = {}, |
| 123 |
}, |
| 124 |
} |