Skip to content

Commit

Permalink
update lualine config
Browse files Browse the repository at this point in the history
- rearrange a few components
- add and remove a few components
  • Loading branch information
jdhao committed Aug 1, 2024
1 parent 9efadac commit bbb8545
Showing 1 changed file with 47 additions and 17 deletions.
64 changes: 47 additions & 17 deletions lua/config/statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ end

local virtual_env = function()
-- only show virtual env for Python
if vim.bo.filetype ~= 'python' then
if vim.bo.filetype ~= "python" then
return ""
end

local conda_env = os.getenv('CONDA_DEFAULT_ENV')
local venv_path = os.getenv('VIRTUAL_ENV')
local conda_env = os.getenv("CONDA_DEFAULT_ENV")
local venv_path = os.getenv("VIRTUAL_ENV")

if venv_path == nil then
if conda_env == nil then
Expand All @@ -113,17 +113,32 @@ local virtual_env = function()
return string.format(" %s (conda)", conda_env)
end
else
local venv_name = vim.fn.fnamemodify(venv_path, ':t')
local venv_name = vim.fn.fnamemodify(venv_path, ":t")
return string.format(" %s (venv)", venv_name)
end
end

local get_active_lsp = function()
local msg = "No Active Lsp"
local buf_ft = vim.api.nvim_get_option_value("filetype", {})
local clients = vim.lsp.get_clients { bufnr = 0 }
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

require("lualine").setup {
options = {
icons_enabled = true,
theme = "auto",
-- component_separators = { left = "", right = "" },
-- section_separators = { left = "", right = "" },
section_separators = "",
component_separators = "",
disabled_filetypes = {},
Expand All @@ -132,18 +147,29 @@ require("lualine").setup {
sections = {
lualine_a = { "mode" },
lualine_b = {
"branch",
{
"diff",
source = diff,
"branch",
fmt = function(name, context)
-- truncate branch name in case the name is too long
return string.sub(name, 1, 20)
end,
},
{
virtual_env,
color = { fg = 'black', bg = "#F1CA81" }
}
color = { fg = "black", bg = "#F1CA81" },
},
},
lualine_c = {
"filename",
{
"filename",
symbols = {
readonly = "[🔒]",
},
},
{
"diff",
source = diff,
},
{
ime_state,
color = { fg = "black", bg = "#f46868" },
Expand All @@ -152,13 +178,19 @@ require("lualine").setup {
spell,
color = { fg = "black", bg = "#a7c080" },
},
},
lualine_x = {
{
get_active_lsp,
icon = " LSP:",
},
{
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = {error = '🆇 ', warn = '⚠️ ', info = 'ℹ️ ', hint = ''},
symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = "" },
},
},
lualine_x = {
lualine_y = {
"encoding",
{
"fileformat",
Expand All @@ -170,9 +202,6 @@ require("lualine").setup {
},
"filetype",
},
lualine_y = {
"location",
},
lualine_z = {
{
trailing_space,
Expand All @@ -182,6 +211,7 @@ require("lualine").setup {
mixed_indent,
color = "WarningMsg",
},
"progress"
},
},
inactive_sections = {
Expand Down

0 comments on commit bbb8545

Please sign in to comment.