new lualine
This commit is contained in:
parent
a6d093b841
commit
8eb1ef3081
1 changed files with 183 additions and 16 deletions
|
@ -48,6 +48,16 @@ formatters.setup {
|
|||
}
|
||||
|
||||
-- Autocommands (https://neovim.io/doc/user/autocmd.html)
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
|
||||
pattern = "*",
|
||||
command="if &nu && mode() != \"i\" | set rnu | endif"
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
|
||||
pattern = "*",
|
||||
command="if &nu | set nornu | endif"
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "zsh",
|
||||
callback = function()
|
||||
|
@ -85,34 +95,191 @@ vim.api.nvim_create_autocmd({ "BufDelete", "VimLeave" }, {
|
|||
command = "!texclear \"%:p\""
|
||||
})
|
||||
|
||||
-- Lualine
|
||||
local components = require "lvim.core.lualine.components"
|
||||
-- Evil Lualine
|
||||
local colors = require "lvim.core.lualine.colors"
|
||||
components.scrollbar = {
|
||||
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,
|
||||
}
|
||||
lvim.builtin.lualine.options = {
|
||||
component_separators = '',
|
||||
section_separators = '',
|
||||
theme = {
|
||||
normal = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
inactive = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
},
|
||||
}
|
||||
lvim.builtin.lualine.sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
}
|
||||
lvim.builtin.lualine.inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
}
|
||||
|
||||
local function ins_left(component)
|
||||
table.insert(lvim.builtin.lualine.sections.lualine_c, component)
|
||||
end
|
||||
|
||||
local function ins_right(component)
|
||||
table.insert(lvim.builtin.lualine.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
local function mode_color()
|
||||
local color = {
|
||||
n = colors.red,
|
||||
i = colors.green,
|
||||
v = colors.magenta,
|
||||
[''] = colors.magenta,
|
||||
V = colors.magenta,
|
||||
c = colors.blue,
|
||||
no = colors.red,
|
||||
s = colors.orange,
|
||||
S = colors.orange,
|
||||
[''] = colors.orange,
|
||||
ic = colors.yellow,
|
||||
R = colors.violet,
|
||||
Rv = colors.violet,
|
||||
cv = colors.red,
|
||||
ce = colors.red,
|
||||
r = colors.cyan,
|
||||
rm = colors.cyan,
|
||||
['r?'] = colors.cyan,
|
||||
['!'] = colors.red,
|
||||
t = colors.red,
|
||||
}
|
||||
return { fg = color[vim.fn.mode()] }
|
||||
end
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
return '▊'
|
||||
end,
|
||||
color = function ()
|
||||
return mode_color()
|
||||
end,
|
||||
padding = { right = 1 },
|
||||
}
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
local msg = 'No Active Lsp'
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end,
|
||||
icon = ' LSP:',
|
||||
color = { fg = colors.white, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_left {
|
||||
'diagnostics',
|
||||
sources = { 'nvim_diagnostic' },
|
||||
symbols = { error = ' ', warn = ' ', info = ' ' },
|
||||
diagnostics_color = {
|
||||
color_error = { fg = colors.red },
|
||||
color_warn = { fg = colors.yellow },
|
||||
color_info = { fg = colors.cyan },
|
||||
},
|
||||
}
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
return '%='
|
||||
end,
|
||||
}
|
||||
|
||||
ins_left {
|
||||
'filename',
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = colors.magenta, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
local current_line = vim.fn.line "."
|
||||
local total_lines = vim.fn.line "$"
|
||||
local chars = { "", "", "", "", "", "", "", "", "", "", "", "", "" }
|
||||
local line_ratio = current_line / total_lines
|
||||
local index = math.ceil(line_ratio * #chars)
|
||||
return " " .. chars[index]
|
||||
return chars[index]
|
||||
end,
|
||||
color = { fg = colors.yellow },
|
||||
cond = nil,
|
||||
color = { fg = colors.fg, gui = 'bold' }
|
||||
}
|
||||
lvim.builtin.lualine.options = {
|
||||
-- component_separators = { left = '│', right = '│' },
|
||||
-- section_separators = { left = '', right = '' },
|
||||
|
||||
ins_left {
|
||||
'%04l:%04c',
|
||||
}
|
||||
lvim.builtin.lualine.sections = {
|
||||
lualine_a = { components.filename },
|
||||
lualine_b = { components.scrollbar, components.location },
|
||||
lualine_c = { components.branch, components.diff },
|
||||
lualine_x = { components.python_env, components.spaces },
|
||||
lualine_y = { components.treesitter, components.diagnostics, components.lsp },
|
||||
lualine_z = { components.encoding, components.filetype },
|
||||
|
||||
ins_right {
|
||||
'o:encoding',
|
||||
fmt = string.upper,
|
||||
cond = conditions.hide_in_width,
|
||||
color = { fg = colors.green, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'fileformat',
|
||||
fmt = string.upper,
|
||||
icons_enabled = false,
|
||||
color = { fg = colors.green, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'branch',
|
||||
icon = '',
|
||||
color = { fg = colors.violet, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'diff',
|
||||
symbols = { added = ' ', modified = '柳 ', removed = ' ' },
|
||||
diff_color = {
|
||||
added = { fg = colors.green },
|
||||
modified = { fg = colors.orange },
|
||||
removed = { fg = colors.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
}
|
||||
|
||||
ins_right {
|
||||
function()
|
||||
return '▊'
|
||||
end,
|
||||
color = function ()
|
||||
return mode_color()
|
||||
end,
|
||||
padding = { left = 1 },
|
||||
}
|
||||
|
||||
|
||||
-- Plugins
|
||||
lvim.plugins = {
|
||||
{ "folke/tokyonight.nvim" },
|
||||
|
|
Loading…
Add table
Reference in a new issue