nvim: plugins: Switch to lualine

This commit is contained in:
Sanchayan Maity 2021-12-07 16:42:07 +05:30
parent 13dbf4a8c1
commit 5716ca88af
3 changed files with 196 additions and 193 deletions

View File

@ -1,191 +0,0 @@
local gl = require('galaxyline')
local gls = gl.section
local condition = require('galaxyline.condition')
-- Without this, the status line for inactive window does not change.
-- We use packer anyways, else this would actually be a bug.
gl.short_line_list = {'Packer'}
local colors = {
line_bg = '#21242b',
bg = '#000000',
fg = '#dobfa1',
yellow = '#fabd2f',
cyan = '#008080',
darkblue = '#081633',
green = '#afd700',
orange = '#FF8800',
purple = '#5d4d7a',
magenta = '#c678dd',
blue = '#51afef',
red = '#ec5f67'
}
gls.left[1] = {
FirstElement = {
provider = function() return '' end,
highlight = { colors.bg, colors.line_bg }
},
}
gls.left[2] = {
ViMode = {
provider = function()
local mode_color = {
n = colors.magenta, i = colors.green, v = colors.blue, [''] = colors.blue, V = colors.blue,
c = colors.red, no = colors.magenta, 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.red
}
vim.api.nvim_command('hi GalaxyViMode guifg='..mode_color[vim.fn.mode()])
return ''
end,
highlight = { colors.red, colors.line_bg, 'bold' },
},
}
gls.left[3] = {
FileIcon = {
provider = 'FileIcon',
condition = condition.buffer_not_empty,
highlight = { require('galaxyline.providers.fileinfo').get_file_icon_color, colors.line_bg },
},
}
gls.left[4] = {
FileName = {
provider = {'FileName'},
condition = condition.buffer_not_empty,
highlight = { colors.fg, colors.line_bg, 'bold' }
}
}
gls.left[5] = {
GitIcon = {
provider = function() return '' end,
condition = condition.check_git_workspace,
highlight = { colors.orange, colors.line_bg },
}
}
gls.left[6] = {
GitBranch = {
provider = 'GitBranch',
condition = condition.check_git_workspace,
highlight = { colors.fg, colors.line_bg, 'bold' },
}
}
gls.left[7] = {
DiffAdd = {
provider = 'DiffAdd',
condition = condition.check_git_workspace and condition.hide_in_width,
icon = '',
highlight = { colors.green, colors.line_bg },
}
}
gls.left[8] = {
DiffModified = {
provider = 'DiffModified',
condition = condition.check_git_workspace and condition.hide_in_width,
icon = '',
highlight = { colors.orange, colors.line_bg },
}
}
gls.left[9] = {
DiffRemove = {
provider = 'DiffRemove',
condition = condition.check_git_workspace and condition.hide_in_width,
icon = '',
highlight = { colors.red, colors.line_bg },
}
}
gls.left[10] = {
LeftEnd = {
provider = function() return '' end,
separator = '',
separator_highlight = { colors.bg, colors.line_bg },
highlight = { colors.line_bg, colors.line_bg }
}
}
gls.left[11] = {
DiagnosticError = {
provider = 'DiagnosticError',
icon = '',
highlight = { colors.red, colors.bg }
}
}
gls.left[12] = {
DiagnosticWarn = {
provider = 'DiagnosticWarn',
icon = '',
highlight = { colors.yellow, colors.bg },
}
}
gls.left[13] = {
DiagnosticHint = {
provider = 'DiagnosticHint',
icon = '',
highlight = {colors.orange,colors.bg},
}
}
gls.left[14] = {
DiagnosticInfo = {
provider = 'DiagnosticInfo',
icon = '',
highlight = {colors.cyan,colors.bg},
}
}
gls.right[1]= {
FileFormat = {
provider = 'FileFormat',
separator = '',
separator_highlight = { colors.bg, colors.line_bg },
highlight = { colors.fg, colors.line_bg },
}
}
gls.right[2] = {
LineInfo = {
provider = 'LineColumn',
separator = ' | ',
separator_highlight = { colors.blue, colors.line_bg },
highlight = { colors.fg, colors.line_bg },
},
}
gls.right[3] = {
PerCent = {
provider = 'LinePercent',
separator = '',
separator_highlight = { colors.line_bg, colors.line_bg },
highlight = { colors.fg, colors.darkblue },
}
}
gls.short_line_left[1] = {
BufferType = {
provider = 'FileTypeName',
separator = '',
separator_highlight = { colors.purple, colors.bg },
highlight = { colors.fg, colors.purple }
}
}
gls.short_line_left[2] = {
WindowNumber = {
provider = function() return vim.fn.winnr() end,
separator = '',
separator_highlight = { colors.purple, colors.bg },
highlight = { colors.red, colors.bg }
}
}
gls.short_line_left[3] = {
FileName = {
provider = {'FileName'},
condition = condition.buffer_not_empty,
highlight = { colors.fg, colors.line_bg, 'bold' }
}
}
gls.short_line_right[1] = {
BufferIcon = {
provider = 'BufferIcon',
separator = '',
separator_highlight = { colors.purple, colors.bg },
highlight = { colors.fg, colors.purple }
}
}

View File

@ -0,0 +1,191 @@
local colors = {
line_bg = '#21242b',
bg = '#000000',
fg = '#dobfa1',
yellow = '#fabd2f',
cyan = '#008080',
darkblue = '#081633',
green = '#afd700',
orange = '#FF8800',
purple = '#5d4d7a',
magenta = '#c678dd',
blue = '#51afef',
red = '#ec5f67'
}
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,
check_active_lsp = function()
local clients = vim.lsp.get_active_clients()
return next(clients) ~= nil
end
}
local window = {
function()
return vim.api.nvim_win_get_number(0)
end,
color = { fg = colors.red },
}
local function diffsigns_source()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed
}
end
end
local config = {
options = {
icons_enabled = true,
component_separators = '',
section_separators = '',
theme = {
normal = { c = { fg = colors.fg , bg = colors.bg } },
inactive = { c = { fg = colors.yellow, bg = colors.bg } },
},
},
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_v = {},
lualine_y = {},
lualine_z = {},
lualine_c = { window, 'filename' },
lualine_x = { 'location', 'progress' },
},
extensions = { 'fugitive', 'fzf', 'quickfix', 'toggleterm' },
}
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
function()
return ' '
end,
color = { fg = colors.blue },
padding = { left = 0, right = 1 },
}
ins_left {
function()
local mode_color = {
n = colors.red,
i = colors.green,
v = colors.blue,
[''] = colors.blue,
V = colors.blue,
c = colors.magenta,
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.red,
}
vim.api.nvim_command('hi! LualineMode guifg=' .. mode_color[vim.fn.mode()] .. ' guibg=' .. colors.bg)
return ''
end,
color = 'LualineMode',
padding = { right = 1 },
}
ins_left {
'filename',
cond = conditions.buffer_not_empty,
color = { fg = colors.blue, gui = 'bold' },
}
ins_left {
'FugitiveHead',
cond = conditions.check_git_workspace,
icon = '',
color = { fg = colors.orange, gui = 'bold' },
}
ins_left {
'diff',
source = diffsigns_source,
cond = conditions.check_git_workspace,
symbols = { added = '', modified = '', removed = '' },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
}
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = '', warn = '', info = '', hint = '' },
diagnostics_color = {
color_error = { fg = colors.red },
color_warn = { fg = colors.yellow },
color_info = { fg = colors.cyan },
color_hint = { fg = colors.orange },
},
}
ins_left {
function()
return '%='
end,
}
ins_right {
'lsp_progress',
cond = conditions.check_active_lsp and conditions.hide_in_width,
color = { fg = colors.cyan, gui = 'bold' }
}
ins_right {
'location',
color = { fg = colors.green, gui = 'bold' }
}
ins_right {
'progress',
color = { fg = colors.magenta, gui = 'bold' }
}
require'lualine'.setup(config)

View File

@ -123,8 +123,11 @@ local init = function ()
use 'vmchale/dhall-vim'
-- For statusline
use {
'NTBBloodbath/galaxyline.nvim',
requires = { 'kyazdani42/nvim-web-devicons' }
'nvim-lualine/lualine.nvim',
requires = {
'kyazdani42/nvim-web-devicons',
'arkav/lualine-lsp-progress'
}
}
-- Marks and registers
use {