summaryrefslogtreecommitdiff
path: root/lua/lvim/core/lualine
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2022-10-17 17:29:15 +0200
committerkylo252 <[email protected]>2022-10-17 17:29:15 +0200
commit4ef07315003f723bb8e97d5a91b2bde3773ec1b8 (patch)
treee9889a492f76e3f9573228343aaba647dfd48136 /lua/lvim/core/lualine
parente4a5fe97abe500bbbe78fb137d57a59f558da05a (diff)
parent6f6cbc394d2a7e64964b6067a2f42d2e6a07824e (diff)
Merge remote-tracking branch 'origin/rolling'
Diffstat (limited to 'lua/lvim/core/lualine')
-rw-r--r--lua/lvim/core/lualine/components.lua98
-rw-r--r--lua/lvim/core/lualine/conditions.lua4
-rw-r--r--lua/lvim/core/lualine/init.lua9
-rw-r--r--lua/lvim/core/lualine/styles.lua56
4 files changed, 124 insertions, 43 deletions
diff --git a/lua/lvim/core/lualine/components.lua b/lua/lvim/core/lualine/components.lua
index c88bf82b..e4148e20 100644
--- a/lua/lvim/core/lualine/components.lua
+++ b/lua/lvim/core/lualine/components.lua
@@ -12,10 +12,35 @@ local function diff_source()
end
end
+local statusline_hl = vim.api.nvim_get_hl_by_name("StatusLine", true)
+local cursorline_hl = vim.api.nvim_get_hl_by_name("CursorLine", true)
+local normal_hl = vim.api.nvim_get_hl_by_name("Normal", true)
+
+vim.api.nvim_set_hl(0, "SLCopilot", { fg = "#6CC644", bg = statusline_hl.background })
+vim.api.nvim_set_hl(0, "SLGitIcon", { fg = "#E8AB53", bg = cursorline_hl.background })
+vim.api.nvim_set_hl(0, "SLBranchName", { fg = normal_hl.foreground, bg = cursorline_hl.background })
+vim.api.nvim_set_hl(0, "SLProgress", { fg = "#ECBE7B", bg = statusline_hl.background })
+
+local location_color = nil
+local branch = lvim.icons.git.Branch
+local separator = lvim.icons.ui.LineMiddle
+
+if lvim.colorscheme == "tokyonight" then
+ location_color = "SLBranchName"
+ branch = "%#SLGitIcon#" .. lvim.icons.git.Branch .. "%*" .. "%#SLBranchName#"
+
+ local status_ok, tnc = pcall(require, "tokyonight.colors")
+ if status_ok then
+ local tncolors = tnc.setup { transform = true }
+ vim.api.nvim_set_hl(0, "SLSeparator", { fg = cursorline_hl.background, bg = tncolors.black })
+ separator = "%#SLSeparator#" .. lvim.icons.ui.LineMiddle .. "%*"
+ end
+end
+
return {
mode = {
function()
- return " "
+ return " " .. lvim.icons.ui.Target .. " "
end,
padding = { left = 0, right = 0 },
color = {},
@@ -23,9 +48,8 @@ return {
},
branch = {
"b:gitsigns_head",
- icon = " ",
+ icon = branch,
color = { gui = "bold" },
- cond = conditions.hide_in_width,
},
filename = {
"filename",
@@ -35,7 +59,12 @@ return {
diff = {
"diff",
source = diff_source,
- symbols = { added = "  ", modified = " ", removed = " " },
+ symbols = {
+ added = lvim.icons.git.LineAdded .. " ",
+ modified = lvim.icons.git.LineModified .. " ",
+ removed = lvim.icons.git.LineRemoved .. " ",
+ },
+ padding = { left = 2, right = 1 },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.yellow },
@@ -49,7 +78,9 @@ return {
if vim.bo.filetype == "python" then
local venv = os.getenv "CONDA_DEFAULT_ENV" or os.getenv "VIRTUAL_ENV"
if venv then
- return string.format("  (%s)", utils.env_cleanup(venv))
+ local icons = require "nvim-web-devicons"
+ local py_icon, _ = icons.get_icon ".py"
+ return string.format(" " .. py_icon .. " (%s)", utils.env_cleanup(venv))
end
end
return ""
@@ -60,12 +91,17 @@ return {
diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
- symbols = { error = " ", warn = " ", info = " ", hint = " " },
- cond = conditions.hide_in_width,
+ symbols = {
+ error = lvim.icons.diagnostics.BoldError .. " ",
+ warn = lvim.icons.diagnostics.BoldWarning .. " ",
+ info = lvim.icons.diagnostics.BoldInformation .. " ",
+ hint = lvim.icons.diagnostics.BoldHint .. " ",
+ },
+ -- cond = conditions.hide_in_width,
},
treesitter = {
function()
- return ""
+ return lvim.icons.ui.Tree
end,
color = function()
local buf = vim.api.nvim_get_current_buf()
@@ -87,12 +123,17 @@ return {
end
local buf_ft = vim.bo.filetype
local buf_client_names = {}
+ local copilot_active = false
-- add client
for _, client in pairs(buf_clients) do
- if client.name ~= "null-ls" then
+ if client.name ~= "null-ls" and client.name ~= "copilot" then
table.insert(buf_client_names, client.name)
end
+
+ if client.name == "copilot" then
+ copilot_active = true
+ end
end
-- add formatter
@@ -106,26 +147,35 @@ return {
vim.list_extend(buf_client_names, supported_linters)
local unique_client_names = vim.fn.uniq(buf_client_names)
- return "[" .. table.concat(unique_client_names, ", ") .. "]"
+
+ local language_servers = "[" .. table.concat(unique_client_names, ", ") .. "]"
+
+ if copilot_active then
+ language_servers = language_servers .. "%#SLCopilot#" .. " " .. lvim.icons.git.Octoface .. "%*"
+ end
+
+ return language_servers
end,
+ separator = separator,
color = { gui = "bold" },
cond = conditions.hide_in_width,
},
- location = { "location", cond = conditions.hide_in_width, color = {} },
- progress = { "progress", cond = conditions.hide_in_width, color = {} },
+ location = { "location", color = location_color },
+ progress = {
+ "progress",
+ fmt = function()
+ return "%P/%L"
+ end,
+ color = {},
+ },
+
spaces = {
function()
- if not vim.api.nvim_buf_get_option(0, "expandtab") then
- return "Tab size: " .. vim.api.nvim_buf_get_option(0, "tabstop") .. " "
- end
- local size = vim.api.nvim_buf_get_option(0, "shiftwidth")
- if size == 0 then
- size = vim.api.nvim_buf_get_option(0, "tabstop")
- end
- return "Spaces: " .. size .. " "
+ local shiftwidth = vim.api.nvim_buf_get_option(0, "shiftwidth")
+ return lvim.icons.ui.Tab .. " " .. shiftwidth
end,
- cond = conditions.hide_in_width,
- color = {},
+ separator = separator,
+ padding = 1,
},
encoding = {
"o:encoding",
@@ -133,7 +183,7 @@ return {
color = {},
cond = conditions.hide_in_width,
},
- filetype = { "filetype", cond = conditions.hide_in_width },
+ filetype = { "filetype", cond = nil, padding = { left = 1, right = 1 } },
scrollbar = {
function()
local current_line = vim.fn.line "."
@@ -144,7 +194,7 @@ return {
return chars[index]
end,
padding = { left = 0, right = 0 },
- color = { fg = colors.yellow, bg = colors.bg },
+ color = "SLProgress",
cond = nil,
},
}
diff --git a/lua/lvim/core/lualine/conditions.lua b/lua/lvim/core/lualine/conditions.lua
index 6e120b26..42d52a83 100644
--- a/lua/lvim/core/lualine/conditions.lua
+++ b/lua/lvim/core/lualine/conditions.lua
@@ -1,11 +1,11 @@
-local window_width_limit = 70
+local window_width_limit = 100
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
+ return vim.o.columns > window_width_limit
end,
-- check_git_workspace = function()
-- local filepath = vim.fn.expand "%:p:h"
diff --git a/lua/lvim/core/lualine/init.lua b/lua/lvim/core/lualine/init.lua
index e041e8a8..0ee35c04 100644
--- a/lua/lvim/core/lualine/init.lua
+++ b/lua/lvim/core/lualine/init.lua
@@ -9,7 +9,7 @@ M.config = function()
section_separators = nil,
theme = nil,
disabled_filetypes = nil,
- globalstatus = false,
+ globalstatus = true,
},
sections = {
lualine_a = nil,
@@ -34,16 +34,19 @@ M.config = function()
end
M.setup = function()
- -- avoid running in headless mode since it's harder to detect failures
if #vim.api.nvim_list_uis() == 0 then
local Log = require "lvim.core.log"
Log:debug "headless mode detected, skipping running setup for lualine"
return
end
+ local status_ok, lualine = pcall(require, "lualine")
+ if not status_ok then
+ return
+ end
+
require("lvim.core.lualine.styles").update()
- local lualine = require "lualine"
lualine.setup(lvim.builtin.lualine)
if lvim.builtin.lualine.on_config_done then
diff --git a/lua/lvim/core/lualine/styles.lua b/lua/lvim/core/lualine/styles.lua
index 8991d9d9..81dbbabb 100644
--- a/lua/lvim/core/lualine/styles.lua
+++ b/lua/lvim/core/lualine/styles.lua
@@ -11,6 +11,7 @@ styles.none = {
style = "none",
options = {
theme = "auto",
+ globalstatus = true,
icons_enabled = lvim.use_icons,
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
@@ -40,9 +41,16 @@ styles.default = {
style = "default",
options = {
theme = "auto",
+ globalstatus = true,
icons_enabled = lvim.use_icons,
- component_separators = { left = "", right = "" },
- section_separators = { left = "", right = "" },
+ component_separators = {
+ left = lvim.icons.ui.DividerRight,
+ right = lvim.icons.ui.DividerLeft,
+ },
+ section_separators = {
+ left = lvim.icons.ui.BoldDividerRight,
+ right = lvim.icons.ui.BoldDividerLeft,
+ },
disabled_filetypes = {},
},
sections = {
@@ -69,10 +77,11 @@ styles.lvim = {
style = "lvim",
options = {
theme = "auto",
+ globalstatus = true,
icons_enabled = lvim.use_icons,
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
- disabled_filetypes = { "alpha", "NvimTree", "Outline" },
+ disabled_filetypes = { "alpha" },
},
sections = {
lualine_a = {
@@ -80,7 +89,6 @@ styles.lvim = {
},
lualine_b = {
components.branch,
- components.filename,
},
lualine_c = {
components.diff,
@@ -88,27 +96,39 @@ styles.lvim = {
},
lualine_x = {
components.diagnostics,
- components.treesitter,
components.lsp,
+ components.spaces,
components.filetype,
},
- lualine_y = {},
+ lualine_y = { components.location },
lualine_z = {
- components.scrollbar,
+ components.progress,
},
},
inactive_sections = {
lualine_a = {
- "filename",
+ components.mode,
+ },
+ lualine_b = {
+ components.branch,
+ },
+ lualine_c = {
+ components.diff,
+ components.python_env,
+ },
+ lualine_x = {
+ components.diagnostics,
+ components.lsp,
+ components.spaces,
+ components.filetype,
+ },
+ lualine_y = { components.location },
+ lualine_z = {
+ components.progress,
},
- lualine_b = {},
- lualine_c = {},
- lualine_x = {},
- lualine_y = {},
- lualine_z = {},
},
tabline = {},
- extensions = { "nvim-tree" },
+ extensions = {},
}
function M.get_style(style)
@@ -132,6 +152,14 @@ function M.update()
local style = M.get_style(lvim.builtin.lualine.style)
lvim.builtin.lualine = vim.tbl_deep_extend("keep", lvim.builtin.lualine, style)
+
+ local color_template = vim.g.colors_name or lvim.colorscheme
+ local theme_supported, template = pcall(function()
+ require("lualine.utils.loader").load_theme(color_template)
+ end)
+ if theme_supported and template then
+ lvim.builtin.lualine.options.theme = color_template
+ end
end
return M