mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45:08 +02:00
[Feature] switch galaxyline to lualine (#1329)
This commit is contained in:
parent
5959872307
commit
85fe093efb
11 changed files with 412 additions and 378 deletions
|
@ -1,348 +0,0 @@
|
|||
-- if not package.loaded['galaxyline'] then
|
||||
-- return
|
||||
-- end
|
||||
local Log = require "core.log"
|
||||
local status_ok, gl = pcall(require, "galaxyline")
|
||||
if not status_ok then
|
||||
Log:get_default().error "Failed to load galaxyline"
|
||||
return
|
||||
end
|
||||
|
||||
-- NOTE: if someone defines colors but doesn't have them then this will break
|
||||
local palette_status_ok, colors = pcall(require, lvim.colorscheme .. ".palette")
|
||||
if not palette_status_ok then
|
||||
colors = lvim.builtin.galaxyline.colors
|
||||
end
|
||||
|
||||
local condition = require "galaxyline.condition"
|
||||
local gls = gl.section
|
||||
gl.short_line_list = { "NvimTree", "vista", "dbui", "packer" }
|
||||
|
||||
local function get_mode_name()
|
||||
local names = {
|
||||
n = "NORMAL",
|
||||
i = "INSERT",
|
||||
c = "COMMAND",
|
||||
v = "VISUAL",
|
||||
V = "VISUAL LINE",
|
||||
t = "TERMINAL",
|
||||
R = "REPLACE",
|
||||
[""] = "VISUAL BLOCK",
|
||||
}
|
||||
return names[vim.fn.mode()]
|
||||
end
|
||||
|
||||
table.insert(gls.left, {
|
||||
ViMode = {
|
||||
provider = function()
|
||||
-- auto change color according the vim mode
|
||||
local mode_color = {
|
||||
n = colors.blue,
|
||||
i = colors.green,
|
||||
v = colors.purple,
|
||||
[""] = colors.purple,
|
||||
V = colors.purple,
|
||||
c = colors.magenta,
|
||||
no = colors.blue,
|
||||
s = colors.orange,
|
||||
S = colors.orange,
|
||||
[""] = colors.orange,
|
||||
ic = colors.yellow,
|
||||
R = colors.red,
|
||||
Rv = colors.red,
|
||||
cv = colors.blue,
|
||||
ce = colors.blue,
|
||||
r = colors.cyan,
|
||||
rm = colors.cyan,
|
||||
["r?"] = colors.cyan,
|
||||
["!"] = colors.blue,
|
||||
t = colors.blue,
|
||||
}
|
||||
if lvim.builtin.galaxyline.show_mode then
|
||||
local name = get_mode_name()
|
||||
-- Fall back to the default behavior is a name is not defined
|
||||
if name ~= nil then
|
||||
vim.api.nvim_command("hi GalaxyViMode guibg=" .. mode_color[vim.fn.mode()])
|
||||
vim.api.nvim_command("hi GalaxyViMode guifg=" .. colors.alt_bg)
|
||||
return " " .. name .. " "
|
||||
end
|
||||
end
|
||||
vim.api.nvim_command("hi GalaxyViMode guibg=" .. colors.alt_bg)
|
||||
vim.api.nvim_command("hi GalaxyViMode guifg=" .. mode_color[vim.fn.mode()])
|
||||
return "▊"
|
||||
end,
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { "NONE", colors.alt_bg },
|
||||
},
|
||||
})
|
||||
-- print(vim.fn.getbufvar(0, 'ts'))
|
||||
vim.fn.getbufvar(0, "ts")
|
||||
|
||||
table.insert(gls.left, {
|
||||
GitIcon = {
|
||||
provider = function()
|
||||
return " "
|
||||
end,
|
||||
condition = condition.check_git_workspace,
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.orange, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.left, {
|
||||
GitBranch = {
|
||||
provider = "GitBranch",
|
||||
condition = condition.check_git_workspace,
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.grey, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.left, {
|
||||
DiffAdd = {
|
||||
provider = "DiffAdd",
|
||||
condition = condition.hide_in_width,
|
||||
icon = " ",
|
||||
highlight = { colors.green, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.left, {
|
||||
DiffModified = {
|
||||
provider = "DiffModified",
|
||||
condition = condition.hide_in_width,
|
||||
icon = " 柳",
|
||||
highlight = { colors.blue, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.left, {
|
||||
DiffRemove = {
|
||||
provider = "DiffRemove",
|
||||
condition = condition.hide_in_width,
|
||||
icon = " ",
|
||||
highlight = { colors.red, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.left, {
|
||||
Filler = {
|
||||
provider = function()
|
||||
return " "
|
||||
end,
|
||||
highlight = { colors.grey, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
-- get output from shell command
|
||||
function os.capture(cmd, raw)
|
||||
local f = assert(io.popen(cmd, "r"))
|
||||
local s = assert(f:read "*a")
|
||||
f:close()
|
||||
if raw then
|
||||
return s
|
||||
end
|
||||
s = string.gsub(s, "^%s+", "")
|
||||
s = string.gsub(s, "%s+$", "")
|
||||
s = string.gsub(s, "[\n\r]+", " ")
|
||||
return s
|
||||
end
|
||||
-- cleanup virtual env
|
||||
local function env_cleanup(venv)
|
||||
if string.find(venv, "/") then
|
||||
local final_venv = venv
|
||||
for w in venv:gmatch "([^/]+)" do
|
||||
final_venv = w
|
||||
end
|
||||
venv = final_venv
|
||||
end
|
||||
return venv
|
||||
end
|
||||
local PythonEnv = function()
|
||||
if vim.bo.filetype == "python" then
|
||||
local venv = os.getenv "CONDA_DEFAULT_ENV"
|
||||
if venv ~= nil then
|
||||
return " (" .. env_cleanup(venv) .. ")"
|
||||
end
|
||||
venv = os.getenv "VIRTUAL_ENV"
|
||||
if venv ~= nil then
|
||||
return " (" .. env_cleanup(venv) .. ")"
|
||||
end
|
||||
return ""
|
||||
end
|
||||
return ""
|
||||
end
|
||||
table.insert(gls.left, {
|
||||
VirtualEnv = {
|
||||
provider = PythonEnv,
|
||||
event = "BufEnter",
|
||||
highlight = { colors.green, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
DiagnosticError = {
|
||||
provider = "DiagnosticError",
|
||||
icon = " ",
|
||||
highlight = { colors.red, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
table.insert(gls.right, {
|
||||
DiagnosticWarn = {
|
||||
provider = "DiagnosticWarn",
|
||||
icon = " ",
|
||||
highlight = { colors.orange, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
DiagnosticInfo = {
|
||||
provider = "DiagnosticInfo",
|
||||
icon = " ",
|
||||
highlight = { colors.yellow, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
DiagnosticHint = {
|
||||
provider = "DiagnosticHint",
|
||||
icon = " ",
|
||||
highlight = { colors.blue, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
TreesitterIcon = {
|
||||
provider = function()
|
||||
if next(vim.treesitter.highlighter.active) ~= nil then
|
||||
return " "
|
||||
end
|
||||
return ""
|
||||
end,
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.green, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
local function get_attached_provider_name(msg)
|
||||
msg = msg or "LSP Inactive"
|
||||
|
||||
local buf_clients = vim.lsp.buf_get_clients()
|
||||
if next(buf_clients) == nil then
|
||||
return msg
|
||||
end
|
||||
|
||||
local buf_client_names = {}
|
||||
for _, client in pairs(buf_clients) do
|
||||
if client.name ~= "null-ls" then
|
||||
table.insert(buf_client_names, client.name)
|
||||
end
|
||||
end
|
||||
|
||||
local null_ls = require "lsp.null-ls"
|
||||
local null_ls_providers = null_ls.list_supported_provider_names(vim.bo.filetype)
|
||||
vim.list_extend(buf_client_names, null_ls_providers)
|
||||
|
||||
return table.concat(buf_client_names, ", ")
|
||||
end
|
||||
|
||||
table.insert(gls.right, {
|
||||
ShowLspClient = {
|
||||
provider = get_attached_provider_name,
|
||||
condition = function()
|
||||
local tbl = { ["dashboard"] = true, [" "] = true }
|
||||
if tbl[vim.bo.filetype] then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
icon = " ",
|
||||
highlight = { colors.grey, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
LineInfo = {
|
||||
provider = "LineColumn",
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.grey, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
PerCent = {
|
||||
provider = "LinePercent",
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.grey, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
Tabstop = {
|
||||
provider = function()
|
||||
local label = "Spaces: "
|
||||
if not vim.api.nvim_buf_get_option(0, "expandtab") then
|
||||
label = "Tab size: "
|
||||
end
|
||||
return label .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
|
||||
end,
|
||||
condition = condition.hide_in_width,
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.grey, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
BufferType = {
|
||||
provider = "FileTypeName",
|
||||
condition = condition.hide_in_width,
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.grey, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
FileEncode = {
|
||||
provider = "FileEncode",
|
||||
condition = condition.hide_in_width,
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.grey, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
Space = {
|
||||
provider = function()
|
||||
return " "
|
||||
end,
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.grey, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.short_line_left, {
|
||||
BufferType = {
|
||||
provider = "FileTypeName",
|
||||
separator = " ",
|
||||
separator_highlight = { "NONE", colors.alt_bg },
|
||||
highlight = { colors.alt_bg, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
table.insert(gls.short_line_left, {
|
||||
SFileName = {
|
||||
provider = "SFileName",
|
||||
condition = condition.buffer_not_empty,
|
||||
highlight = { colors.alt_bg, colors.alt_bg },
|
||||
},
|
||||
})
|
||||
|
||||
--table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.alt_bg}}})
|
16
lua/core/lualine/colors.lua
Normal file
16
lua/core/lualine/colors.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
local colors = {
|
||||
bg = "#202328",
|
||||
fg = "#bbc2cf",
|
||||
yellow = "#ECBE7B",
|
||||
cyan = "#008080",
|
||||
darkblue = "#081633",
|
||||
green = "#98be65",
|
||||
orange = "#FF8800",
|
||||
violet = "#a9a1e1",
|
||||
magenta = "#c678dd",
|
||||
purple = "#c678dd",
|
||||
blue = "#51afef",
|
||||
red = "#ec5f67",
|
||||
}
|
||||
|
||||
return colors
|
130
lua/core/lualine/components.lua
Normal file
130
lua/core/lualine/components.lua
Normal file
|
@ -0,0 +1,130 @@
|
|||
local conditions = require "core.lualine.conditions"
|
||||
local colors = require "core.lualine.colors"
|
||||
|
||||
return {
|
||||
vi_mode = {
|
||||
function()
|
||||
return " "
|
||||
end,
|
||||
left_padding = 0,
|
||||
right_padding = 0,
|
||||
condition = conditions.hide_in_width,
|
||||
},
|
||||
branch = {
|
||||
"branch",
|
||||
icon = " ",
|
||||
condition = function()
|
||||
return conditions.hide_in_width() and conditions.check_git_workspace()
|
||||
end,
|
||||
},
|
||||
diff = {
|
||||
"diff",
|
||||
symbols = { added = " ", modified = "柳", removed = " " },
|
||||
color_added = { fg = colors.green },
|
||||
color_modified = { fg = colors.yellow },
|
||||
color_removed = { fg = colors.red },
|
||||
condition = conditions.hide_in_width,
|
||||
},
|
||||
python_env = {
|
||||
function()
|
||||
local utils = require "core.lualine.utils"
|
||||
if vim.bo.filetype == "python" then
|
||||
local venv = os.getenv "CONDA_DEFAULT_ENV"
|
||||
if venv then
|
||||
return string.format(" (%s)", utils.env_cleanup(venv))
|
||||
end
|
||||
venv = os.getenv "VIRTUAL_ENV"
|
||||
if venv then
|
||||
return string.format(" (%s)", utils.env_cleanup(venv))
|
||||
end
|
||||
return ""
|
||||
end
|
||||
return ""
|
||||
end,
|
||||
color = { fg = colors.green },
|
||||
condition = conditions.hide_in_width,
|
||||
},
|
||||
diagnostics = {
|
||||
"diagnostics",
|
||||
sources = { "nvim_lsp" },
|
||||
symbols = { error = " ", warn = " ", info = " ", hint = " " },
|
||||
condition = conditions.hide_in_width,
|
||||
},
|
||||
treesitter = {
|
||||
function()
|
||||
if next(vim.treesitter.highlighter.active) then
|
||||
return " "
|
||||
end
|
||||
return ""
|
||||
end,
|
||||
color = { fg = colors.green },
|
||||
condition = conditions.hide_in_width,
|
||||
},
|
||||
lsp = {
|
||||
function(msg)
|
||||
msg = msg or "LSP Inactive"
|
||||
local buf_clients = vim.lsp.buf_get_clients()
|
||||
if next(buf_clients) == nil then
|
||||
return msg
|
||||
end
|
||||
local buf_ft = vim.bo.filetype
|
||||
local buf_client_names = {}
|
||||
|
||||
-- add client
|
||||
local utils = require "lsp.utils"
|
||||
local active_client = utils.get_active_client_by_ft(buf_ft)
|
||||
for _, client in pairs(buf_clients) do
|
||||
if client.name ~= "null-ls" then
|
||||
table.insert(buf_client_names, client.name)
|
||||
end
|
||||
end
|
||||
vim.list_extend(buf_client_names, active_client or {})
|
||||
|
||||
-- add formatter
|
||||
local formatters = require "lsp.null-ls.formatters"
|
||||
local supported_formatters = formatters.list_supported_names(buf_ft)
|
||||
vim.list_extend(buf_client_names, supported_formatters)
|
||||
|
||||
-- add linter
|
||||
local linters = require "lsp.null-ls.linters"
|
||||
local supported_linters = linters.list_supported_names(buf_ft)
|
||||
vim.list_extend(buf_client_names, supported_linters)
|
||||
|
||||
return table.concat(buf_client_names, ", ")
|
||||
end,
|
||||
condition = conditions.hide_in_width,
|
||||
icon = " ",
|
||||
color = { gui = "bold" },
|
||||
},
|
||||
location = { "location", condition = conditions.hide_in_width },
|
||||
progress = { "progress", condition = conditions.hide_in_width },
|
||||
spaces = {
|
||||
function()
|
||||
local label = "Spaces: "
|
||||
if not vim.api.nvim_buf_get_option(0, "expandtab") then
|
||||
label = "Tab size: "
|
||||
end
|
||||
return label .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
|
||||
end,
|
||||
condition = conditions.hide_in_width,
|
||||
},
|
||||
encoding = {
|
||||
"o:encoding",
|
||||
upper = true,
|
||||
condition = conditions.hide_in_width,
|
||||
},
|
||||
filetype = { "filetype", condition = conditions.hide_in_width },
|
||||
scrollbar = {
|
||||
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]
|
||||
end,
|
||||
color = { fg = colors.yellow, bg = colors.bg },
|
||||
left_padding = 0,
|
||||
right_padding = 0,
|
||||
},
|
||||
}
|
17
lua/core/lualine/conditions.lua
Normal file
17
lua/core/lualine/conditions.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
local window_width_limit = 80
|
||||
|
||||
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) > window_width_limit
|
||||
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,
|
||||
}
|
||||
|
||||
return conditions
|
47
lua/core/lualine/init.lua
Normal file
47
lua/core/lualine/init.lua
Normal file
|
@ -0,0 +1,47 @@
|
|||
local M = {}
|
||||
M.config = function()
|
||||
lvim.builtin.lualine = {
|
||||
active = true,
|
||||
style = "lvim",
|
||||
options = {
|
||||
icons_enabled = nil,
|
||||
component_separators = nil,
|
||||
section_separators = nil,
|
||||
theme = nil,
|
||||
disabled_filetypes = nil,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = nil,
|
||||
lualine_b = nil,
|
||||
lualine_c = nil,
|
||||
lualine_x = nil,
|
||||
lualine_y = nil,
|
||||
lualine_z = nil,
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = nil,
|
||||
lualine_b = nil,
|
||||
lualine_c = nil,
|
||||
lualine_x = nil,
|
||||
lualine_y = nil,
|
||||
lualine_z = nil,
|
||||
},
|
||||
tabline = nil,
|
||||
extensions = nil,
|
||||
on_config_done = nil,
|
||||
}
|
||||
end
|
||||
|
||||
M.setup = function()
|
||||
require("core.lualine.styles").update()
|
||||
require("core.lualine.utils").validate_theme()
|
||||
|
||||
local lualine = require "lualine"
|
||||
lualine.setup(lvim.builtin.lualine)
|
||||
|
||||
if lvim.builtin.lualine.on_config_done then
|
||||
lvim.builtin.lualine.on_config_done(lualine, lvim.builtin.lualine)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
170
lua/core/lualine/styles.lua
Normal file
170
lua/core/lualine/styles.lua
Normal file
|
@ -0,0 +1,170 @@
|
|||
local M = {}
|
||||
local components = require "core.lualine.components"
|
||||
|
||||
local styles = {
|
||||
lvim = nil,
|
||||
default = nil,
|
||||
none = nil,
|
||||
}
|
||||
|
||||
styles.none = {
|
||||
style = "none",
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
component_separators = "",
|
||||
section_separators = "",
|
||||
disabled_filetypes = {},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {},
|
||||
}
|
||||
|
||||
styles.default = {
|
||||
style = "default",
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
component_separators = { "", "" },
|
||||
section_separators = { "", "" },
|
||||
disabled_filetypes = {},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch" },
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "encoding", "fileformat", "filetype" },
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = { "location" },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "location" },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {},
|
||||
}
|
||||
|
||||
styles.lvim = {
|
||||
style = "lvim",
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
component_separators = "",
|
||||
section_separators = "",
|
||||
disabled_filetypes = { "dashboard", "" },
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {
|
||||
components.vi_mode,
|
||||
},
|
||||
lualine_b = {
|
||||
components.branch,
|
||||
},
|
||||
lualine_c = {
|
||||
components.diff,
|
||||
components.python_env,
|
||||
},
|
||||
lualine_x = {
|
||||
components.diagnostics,
|
||||
components.treesitter,
|
||||
components.lsp,
|
||||
-- components.location,
|
||||
-- components.progress,
|
||||
-- components.spaces,
|
||||
-- components.encoding,
|
||||
components.filetype,
|
||||
},
|
||||
lualine_y = {
|
||||
-- components.filetype,
|
||||
},
|
||||
lualine_z = {
|
||||
components.scrollbar,
|
||||
},
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {
|
||||
"filename",
|
||||
},
|
||||
lualine_b = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
extensions = { "nvim-tree" },
|
||||
}
|
||||
|
||||
function M.get_style(style)
|
||||
local style_keys = vim.tbl_keys(styles)
|
||||
if not vim.tbl_contains(style_keys, style) then
|
||||
local Log = require "core.log"
|
||||
local logger = Log:get_default()
|
||||
logger.error(
|
||||
"Invalid lualine style",
|
||||
string.format('"%s"', style),
|
||||
"options are: ",
|
||||
string.format('"%s"', table.concat(style_keys, '", "'))
|
||||
)
|
||||
logger.info '"lvim" style is applied.'
|
||||
style = "lvim"
|
||||
end
|
||||
|
||||
return vim.deepcopy(styles[style])
|
||||
end
|
||||
|
||||
function M.update()
|
||||
local config = lvim.builtin.lualine
|
||||
local style = M.get_style(config.style)
|
||||
|
||||
lvim.builtin.lualine = {
|
||||
active = true,
|
||||
style = style.style,
|
||||
options = {
|
||||
icons_enabled = config.options.icons_enabled or style.options.icons_enabled,
|
||||
component_separators = config.options.component_separators or style.options.component_separators,
|
||||
section_separators = config.options.section_separators or style.options.section_separators,
|
||||
theme = config.options.theme or lvim.colorscheme or "auto",
|
||||
disabled_filetypes = config.options.disabled_filetypes or style.options.disabled_filetypes,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = config.sections.lualine_a or style.sections.lualine_a,
|
||||
lualine_b = config.sections.lualine_b or style.sections.lualine_b,
|
||||
lualine_c = config.sections.lualine_c or style.sections.lualine_c,
|
||||
lualine_x = config.sections.lualine_x or style.sections.lualine_x,
|
||||
lualine_y = config.sections.lualine_y or style.sections.lualine_y,
|
||||
lualine_z = config.sections.lualine_z or style.sections.lualine_z,
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = config.inactive_sections.lualine_a or style.inactive_sections.lualine_a,
|
||||
lualine_b = config.inactive_sections.lualine_b or style.inactive_sections.lualine_b,
|
||||
lualine_c = config.inactive_sections.lualine_c or style.inactive_sections.lualine_c,
|
||||
lualine_x = config.inactive_sections.lualine_x or style.inactive_sections.lualine_x,
|
||||
lualine_y = config.inactive_sections.lualine_y or style.inactive_sections.lualine_y,
|
||||
lualine_z = config.inactive_sections.lualine_z or style.inactive_sections.lualine_z,
|
||||
},
|
||||
tabline = config.tabline or style.tabline,
|
||||
extensions = config.extensions or style.extensions,
|
||||
on_config_done = config.on_config_done,
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
24
lua/core/lualine/utils.lua
Normal file
24
lua/core/lualine/utils.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
local M = {}
|
||||
|
||||
function M.validate_theme()
|
||||
local theme = lvim.builtin.lualine.options.theme
|
||||
|
||||
local lualine_loader = require "lualine.utils.loader"
|
||||
local ok = pcall(lualine_loader.load_theme, theme)
|
||||
if not ok then
|
||||
lvim.builtin.lualine.options.theme = "auto"
|
||||
end
|
||||
end
|
||||
|
||||
function M.env_cleanup(venv)
|
||||
if string.find(venv, "/") then
|
||||
local final_venv = venv
|
||||
for w in venv:gmatch "([^/]+)" do
|
||||
final_venv = w
|
||||
end
|
||||
venv = final_venv
|
||||
end
|
||||
return venv
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,20 +0,0 @@
|
|||
lvim.builtin.galaxyline = {
|
||||
active = true,
|
||||
show_mode = false,
|
||||
colors = {
|
||||
alt_bg = "#2E2E2E",
|
||||
grey = "#858585",
|
||||
blue = "#569CD6",
|
||||
green = "#608B4E",
|
||||
yellow = "#DCDCAA",
|
||||
orange = "#FF8800",
|
||||
purple = "#C586C0",
|
||||
magenta = "#D16D9E",
|
||||
cyan = "#4EC9B0",
|
||||
red = "#D16969",
|
||||
error_red = "#F44747",
|
||||
warning_orange = "#FF8800",
|
||||
info_yellow = "#FFCC66",
|
||||
hint_blue = "#9CDCFE",
|
||||
},
|
||||
}
|
|
@ -27,7 +27,7 @@ lvim = {
|
|||
which_key = {},
|
||||
comment = {},
|
||||
project = {},
|
||||
galaxyline = {},
|
||||
lualine = {},
|
||||
bufferline = {},
|
||||
dap = {},
|
||||
dashboard = {},
|
||||
|
@ -1330,7 +1330,6 @@ lvim.lang = {
|
|||
|
||||
require("keymappings").config()
|
||||
require("core.which-key").config()
|
||||
require "core.status_colors"
|
||||
require("core.gitsigns").config()
|
||||
require("core.compe").config()
|
||||
require("core.dashboard").config()
|
||||
|
@ -1343,3 +1342,4 @@ require("core.project").config()
|
|||
require("core.bufferline").config()
|
||||
require("core.autopairs").config()
|
||||
require("core.comment").config()
|
||||
require("core.lualine").config()
|
||||
|
|
|
@ -164,15 +164,13 @@ return {
|
|||
|
||||
-- Status Line and Bufferline
|
||||
{
|
||||
"glepnir/galaxyline.nvim",
|
||||
-- "hoob3rt/lualine.nvim",
|
||||
"shadmansaleh/lualine.nvim",
|
||||
-- "Lunarvim/lualine.nvim",
|
||||
config = function()
|
||||
require "core.galaxyline"
|
||||
if lvim.builtin.galaxyline.on_config_done then
|
||||
lvim.builtin.galaxyline.on_config_done(require "galaxyline")
|
||||
end
|
||||
require("core.lualine").setup()
|
||||
end,
|
||||
event = "BufWinEnter",
|
||||
disable = not lvim.builtin.galaxyline.active,
|
||||
disable = not lvim.builtin.lualine.active,
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
@ -88,6 +88,7 @@ function utils.toggle_autoformat()
|
|||
end
|
||||
|
||||
function utils.reload_lv_config()
|
||||
require("core.lualine").config()
|
||||
vim.cmd "source ~/.local/share/lunarvim/lvim/lua/settings.lua"
|
||||
vim.cmd("source " .. USER_CONFIG_PATH)
|
||||
require("keymappings").setup() -- this should be done before loading the plugins
|
||||
|
@ -101,7 +102,6 @@ function utils.reload_lv_config()
|
|||
-- vim.cmd ":PackerClean"
|
||||
local null_ls = require "lsp.null-ls"
|
||||
null_ls.setup(vim.bo.filetype, { force_reload = true })
|
||||
|
||||
Log:get_default().info "Reloaded configuration"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue